Abstraction around the Switchboard-On-Demand Feed account

This account is used to store the feed data and the oracle responses for a given feed.

Constructors

Properties

gatewayUrl: string
program: Program<Idl>

The Anchor program instance.

pubkey: PublicKey

Methods

  • Fetch updates for the feed.

    Parameters

    • Optional params_: {
          crossbarClient?: CrossbarClient;
          gateway?: string;
          jobs?: IOracleJob[];
          numSignatures?: number;
      }

      The parameters object.

      • Optional crossbarClient?: CrossbarClient

        Optionally specify the CrossbarClient to use.

      • Optional gateway?: string

        Optionally specify the gateway to use. If not specified, the gateway is automatically fetched.

      • Optional jobs?: IOracleJob[]

        An array of IOracleJob representing the jobs to be executed.

      • Optional numSignatures?: number

        Number of signatures to fetch.

    • Optional recentSlothashes: [BN, string][]

      An optional array of recent slothashes as [anchor.BN, string] tuples.

    • Optional priceSignatures: FeedEvalResponse[]

      An optional array of FeedEvalResponse representing the price signatures.

    • Optional debug: boolean = false

      A boolean flag to enable or disable debug mode. Defaults to false.

    Returns Promise<[TransactionInstruction, OracleResponse[], number, any[]]>

    A promise that resolves to a tuple containing:

    • The transaction instruction to fetch updates, or undefined if not applicable.
    • An array of OracleResponse objects.
    • A number representing the successful responses.
    • An array containing usable lookup tables.
  • Compiles a transaction instruction to submit oracle signatures for a given feed.

    Parameters

    • params: {
          offsets: number[];
          payer?: PublicKey;
          resps: FeedEvalResponse[];
          slot: BN;
      }

    Returns TransactionInstruction

    A promise that resolves to the transaction instruction.

  • Initializes a pull feed account.

    Parameters

    • params: {
          maxStaleness: number;
          maxVariance: number;
          minResponses: number;
          minSampleSize: number;
          name: string;
          payer?: PublicKey;
          queue: PublicKey;
      } & ({
          feedHash: Buffer;
      } | {
          jobs: IOracleJob[];
      })

    Returns Promise<TransactionInstruction>

    A promise that resolves to a tuple containing the pull feed instance and the transaction signature.

  • Checks if the pull feed account has been initialized.

    Returns Promise<boolean>

    A promise that resolves to a boolean indicating if the account has been initialized.

  • Loads the feed configurations for this PullFeed account from on chain.

    Returns Promise<{
        feedHash: Buffer;
        maxVariance: bigint;
        minResponses: number;
        queue: PublicKey;
    }>

    A promise that resolves to the feed configurations.

    Throws

    if the feed account does not exist.

  • Loads the feed data for this PullFeed account from on chain.

    Parameters

    • onlyAfter: BN

      Call will ignore data signed before this slot.

    Returns Promise<{
        oracle: PublicKey;
        slot: BN;
        value: Big;
    }>

    A promise that resolves to the observed value as it would be seen on-chain.

  • Loads the feed data for this PullFeed account from on chain.

    Returns Promise<{
        oracle: PublicKey;
        slot: BN;
        value: Big;
    }[]>

    A promise that resolves to the values currently stored in the feed.

    Throws

    if the feed account does not exist.

  • Set configurations for the feed.

    Parameters

    • params: {
          authority?: PublicKey;
          feedHash?: Buffer;
          jobs?: IOracleJob[];
          maxStaleness?: number;
          maxVariance?: number;
          minResponses?: number;
          minSampleSize?: number;
          name?: string;
      }
      • Optional authority?: PublicKey

        The authority of the feed.

      • Optional feedHash?: Buffer

        The hash of the feed as a Uint8Array or hexadecimal string. Only results signed with this hash will be accepted.

      • Optional jobs?: IOracleJob[]
      • Optional maxStaleness?: number

        The maximum number of slots that can pass before a feed value is considered stale.

      • Optional maxVariance?: number

        The maximum variance allowed for the feed.

      • Optional minResponses?: number

        The minimum number of responses required.

      • Optional minSampleSize?: number

        The minimum number of samples required for setting feed value.

      • Optional name?: string

    Returns Promise<TransactionInstruction>

    A promise that resolves to the transaction instruction to set feed configs.

  • Watches for any on-chain updates to the feed data.

    Parameters

    • callback: any

      The callback to call when the feed data is updated.

    Returns Promise<number>

    A promise that resolves to a subscription ID.

  • Calls to initialize a pull feed account and to update the configuration account need to compute the feed hash for the account (if one is not specified).

    Parameters

    • params: {
          feedHash?: Buffer;
          jobs?: IOracleJob[];
          queue: PublicKey;
      }
      • Optional feedHash?: Buffer
      • Optional jobs?: IOracleJob[]
      • queue: PublicKey

    Returns Buffer

  • Fetch updates for the feed.

    Parameters

    • program: Program<Idl>
    • params_: {
          crossbarClient?: CrossbarClient;
          feed: PublicKey;
          gateway?: string;
          jobs?: IOracleJob[];
          maxVariance: bigint;
          minResponses: number;
          numSignatures: number;
          queue: PublicKey;
      }

      The parameters object.

      • Optional crossbarClient?: CrossbarClient

        Optionally specify the CrossbarClient to use.

      • feed: PublicKey
      • Optional gateway?: string

        Optionally specify the gateway to use. If not specified, the gateway is automatically fetched.

      • Optional jobs?: IOracleJob[]

        An array of IOracleJob representing the jobs to be executed.

      • maxVariance: bigint
      • minResponses: number
      • numSignatures: number

        Number of signatures to fetch.

      • queue: PublicKey
    • Optional recentSlothashes: [BN, string][]

      An optional array of recent slothashes as [anchor.BN, string] tuples.

    • Optional priceSignatures: FeedEvalResponse[]

      An optional array of FeedEvalResponse representing the price signatures.

    • debug: boolean = false

      A boolean flag to enable or disable debug mode. Defaults to false.

    • Optional payer: PublicKey

      Optionally specify the payer public key.

    Returns Promise<[TransactionInstruction, OracleResponse[], number, any[]]>

    A promise that resolves to a tuple containing:

    • The transaction instruction to fetch updates, or undefined if not applicable.
    • An array of OracleResponse objects.
    • A number representing the successful responses.
    • An array containing usable lookup tables.
  • Fetches updates for multiple feeds at once.

    Parameters

    • program: Program<Idl>

      The Anchor program instance.

    • params_: {
          crossbarClient?: CrossbarClient;
          feeds: PublicKey[];
          gateway?: string;
          numSignatures: number;
          payer?: PublicKey;
      }

      The parameters object.

      • Optional crossbarClient?: CrossbarClient

        Optionally specify the CrossbarClient to use.

      • feeds: PublicKey[]

        An array of feed account public keys.

      • Optional gateway?: string

        The gateway URL to use. If not provided, the gateway is automatically fetched.

      • numSignatures: number

        The number of signatures to fetch.

      • Optional payer?: PublicKey
    • Optional recentSlothashes: [BN, string][]

      An optional array of recent slothashes as [anchor.BN, string] tuples.

    • debug: boolean = false

      A boolean flag to enable or disable debug mode. Defaults to false.

    • Optional payer: PublicKey

      Optionally specify the payer public key.

    Returns Promise<[TransactionInstruction, AddressLookupTableAccount[], any]>

    A promise that resolves to a tuple containing:

    • The transaction instruction for fetching updates.
    • An array of AddressLookupTableAccount to use.
    • The raw response data.
  • Parameters

    • program: Program<Idl>
    • params: {
          maxStaleness: number;
          maxVariance: number;
          minResponses: number;
          minSampleSize: number;
          name: string;
          payer?: PublicKey;
          queue: PublicKey;
      } & ({
          feedHash: Buffer;
      } | {
          jobs: IOracleJob[];
      })

    Returns Promise<[PullFeed, VersionedTransaction]>

  • Watches for any on-chain updates to any data feed.

    Parameters

    • program: Program<Idl>

      The Anchor program instance.

    • callback: ((event) => Promise<void>)

      The callback to call when the feed data is updated.

        • (event): Promise<void>
        • Parameters

          • event: [number, {
                pubkey: PublicKey;
                submissions: FeedSubmission[];
            }]

          Returns Promise<void>

    Returns Promise<number>

    A promise that resolves to a subscription ID.

Generated using TypeDoc