Class PythConnection

Reads Pyth price data from a solana web3 connection. This class uses a callback-driven model, similar to the solana web3 methods for tracking updates to accounts.

Hierarchy

  • PythConnection

Constructors

  • Create a PythConnection that reads its data from an underlying solana web3 connection. pythProgramKey is the public key of the Pyth program running on the chosen solana cluster.

    Parameters

    • connection: Connection
    • pythProgramKey: PublicKey
    • Optional commitment: Commitment

    Returns PythConnection

Properties

callbacks: PythPriceCallback[]
commitment: Commitment
connection: Connection
handleAccount: any
handlePriceAccount: any
handleProductAccount: any
priceAccountKeyToProductAccountKey: Record<string, string>
productAccountKeyToProduct: Record<string, Product>
pythProgramKey: PublicKey

Methods

  • Register callback to receive price updates.

    Parameters

    • callback: PythPriceCallback

    Returns void

  • Start receiving price updates. Once this method is called, any registered callbacks will be invoked each time a Pyth price account is updated.

    Returns Promise<void>

  • Stop receiving price updates. Note that this also currently deletes all registered callbacks.

    Returns Promise<void>

Generated using TypeDoc