PullFeed account management for persistent price feeds

The PullFeed class manages on-chain feed accounts that store price history and configuration. While the quote approach is more efficient for most use cases, feeds are useful when you need:

  • Persistent price history on-chain
  • Standardized addresses for multiple consumers
  • Price archives and analytics
  • Compatibility with programs expecting traditional feeds
  • Price History: Stores historical price data on-chain
  • Job Management: Configure data sources via IPFS-stored jobs
  • Update Control: Fine-grained control over update parameters
  • LUT Integration: Automatic lookup table management
// Create a new feed
const [pullFeed, feedKp] = PullFeed.generate(program);
await pullFeed.initIx({
name: "BTC/USD",
queue: queuePubkey,
maxVariance: 1.0,
minResponses: 3,
feedHash: jobHash,
});

// Update the feed
const [updateIx, responses] = await pullFeed.fetchUpdateIx();

PullFeed

Constructors

Methods

  • Manually set the network for this feed

    This method allows you to explicitly set the network type, which will be used by methods that need network-specific configuration.

    Parameters

    • network: CrossbarNetwork

      The network to use (SolanaMainnet or SolanaDevnet)

    Returns void

    const feed = new PullFeed(program, feedPubkey);
    feed.setNetwork(CrossbarNetwork.SolanaDevnet);
  • Prefetch all lookup tables needed for the feed and queue.

    Returns Promise<AddressLookupTableAccount[]>

    A promise that resolves to an array of lookup tables.

    if the lookup tables cannot be loaded.

  • Parameters

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

    Returns Promise<[PullFeed, VersionedTransaction]>

  • Initializes a pull feed account.

    Parameters

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

    Returns Promise<TransactionInstruction>

    A promise that resolves to the transaction instruction.

  • Set configurations for the feed.

    Parameters

    • params: {
          name?: string;
          authority?: PublicKey;
          maxVariance?: number;
          minResponses?: number;
          feedHash?: Buffer<ArrayBufferLike>;
          jobs?: IOracleJob[];
          minSampleSize?: number;
          maxStaleness?: number;
          permitWriteByAuthority?: boolean;
      }
      • Optionalname?: string
      • Optionalauthority?: PublicKey

        The authority of the feed.

      • OptionalmaxVariance?: number

        The maximum variance allowed for the feed.

      • OptionalminResponses?: number

        The minimum number of responses required.

      • OptionalfeedHash?: Buffer<ArrayBufferLike>

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

      • Optionaljobs?: IOracleJob[]
      • OptionalminSampleSize?: number

        The minimum number of samples required for setting feed value.

      • OptionalmaxStaleness?: number

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

      • OptionalpermitWriteByAuthority?: boolean

    Returns Promise<TransactionInstruction>

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

  • Fetches update instructions for this feed

    Retrieves fresh oracle data and creates the instructions to update the on-chain feed account. This method handles all the complexity of oracle communication and signature verification.

    Parameters

    • params: {
          numSignatures?: number;
          jobs?: IOracleJob[];
          crossbarClient?: CrossbarClient;
          retries?: number;
          variableOverrides?: Record<string, string>;
      }

      Update parameters

      • OptionalnumSignatures?: number

        Number of oracle signatures (defaults to minSampleSize + 33%)

      • Optionaljobs?: IOracleJob[]

        Optional job overrides

      • OptionalcrossbarClient?: CrossbarClient

        Optional Crossbar client

      • Optionalretries?: number

        Number of retry attempts

      • OptionalvariableOverrides?: Record<string, string>

        Optional variable overrides for task execution

    Returns Promise<
        [
            undefined
            | TransactionInstruction[],
            OracleResponse[],
            number,
            AddressLookupTableAccount[],
            string[],
        ],
    >

    Update transaction components

    const [pullIx, responses, success, luts] = await pullFeed.fetchUpdateIx({
    gateway: 'https://gateway.switchboard.xyz',
    numSignatures: 3,
    });

    if (pullIx) {
    const tx = await asV0Tx({
    connection,
    ixs: pullIx,
    signers: [payer],
    lookupTables: luts,
    });
    }
  • Loads the feed configurations (if not already cached) for this PullFeed account from on chain.

    Parameters

    • Optionalforce: boolean

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

    A promise that resolves to the feed configurations.

    if the feed account does not exist.

  • Fetches updates for a feed, returning instructions that must be executed in order at the front of the transaction.

    Parameters

    • params: {
          pullFeed: PullFeed;
          numSignatures: number;
          crossbarClient?: CrossbarClient;
          variableOverrides?: Record<string, string>;
      }

      The parameters object

      • pullFeed: PullFeed
      • numSignatures: number

        Number of signatures to fetch

      • OptionalcrossbarClient?: CrossbarClient

        Optional CrossbarClient instance to use

      • OptionalvariableOverrides?: Record<string, string>

    Returns Promise<
        [
            undefined
            | TransactionInstruction[],
            OracleResponse[],
            number,
            AddressLookupTableAccount[],
            string[],
        ],
    >

    Promise resolving to:

    • instructions: Array of instructions that must be executed in order: [0] = Ed25519 program verification instruction [1] = feed update instruction
    • oracleResponses: Array of responses from oracles
    • numSuccesses: Number of successful responses
    • luts: Array of AddressLookupTableAccount to include
    • failures: Array of errors that occurred during the fetch
  • Fetches updates for multiple feeds at once into a SINGLE tightly packed instruction. Returns instructions that must be executed in order, with the Ed25519 verification instruction placed at the front of the transaction.

    Parameters

    • program: Program

      The Anchor program instance.

    • params: {
          feeds: PullFeed[];
          numSignatures: number;
          crossbarClient?: CrossbarClient;
          variableOverrides?: Record<string, string>;
          signatureInstructionIdx?: number;
      }

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

    A promise that resolves to a tuple containing:

    • An array of transaction instructions that must be executed in order: [0] = Ed25519 program verification instruction [1] = feed update instruction
    • An array of AddressLookupTableAccount to use.
    • The raw response data.
  • Parameters

    • program: Program
    • params: {
          feeds: PullFeed[];
          chain?: string;
          network?: "mainnet" | "devnet" | "mainnet-beta" | "testnet";
          recentSlothashes?: [BN, string][];
          numSignatures: number;
          crossbarClient?: CrossbarClient;
          payer?: PublicKey;
          variableOverrides?: Record<string, string>;
      }
    • debug: boolean = false

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

  • Compiles a transaction instruction to submit oracle signatures for a given feed.

    Parameters

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

    Returns TransactionInstruction

    A promise that resolves to the transaction instruction.

  • 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.

Properties

gatewayUrl: string
pubkey: PublicKey
configs:
    | null
    | {
        queue: PublicKey;
        maxVariance: number;
        minResponses: number;
        feedHash: Buffer;
        minSampleSize: number;
    }
data: null | PullFeedAccountData
jobs: null | IOracleJob[]
lut: null | AddressLookupTableAccount
program: Program

The Anchor program instance.