Class PriceFeed

Watches for price updates on the h2so server at oracle.handle.fi, allowing a client to subscribe to price updates.

Hierarchy

  • PriceFeed

Constructors

Properties

activityMonitor?: Timeout
client?: w3cwebsocket
clientOpenPromise?: Promise<void>
connectionId: number = 0
feed: PairMap<TimestampedPrice> = {}
internalErrorCallback?: ErrorCallback
internalPriceCallbacks: PriceCallback[] = []
isConnecting: boolean = false
lastMessageTimestamp: Date = ...
localSubscriptions: (null | LocalSubscription)[] = []

Subscriptions from local users.

options: Options
remoteSubscriptions: SubscriptionPair[] = []

Subscriptions to the remote server.

userErrorCallback?: ErrorCallback

Accessors

Methods

  • Parameters

    • reconnectDelayMillis: number = RECONNECT_DELAY

    Returns Promise<void>

  • Parameters

    • maxAttempts: number = MAX_RECONNECT_ATTEMPTS
    • reconnectDelayMillis: number = RECONNECT_DELAY

    Returns Promise<void>

  • Parameters

    • pairs: Pair[]

    Returns Promise<Record<string, undefined | BigNumber>>

  • Gets a (nullable) price from the feed, and does not subscribe to the pair if missing.

    Parameters

    • pair: Pair

    Returns undefined | BigNumber

  • Parameters

    • pair: Pair
    • price: BigNumber
    • timestamp: number

    Returns void

  • Parameters

    • reconnectDelayMillis: number
    • e: ICloseEvent

    Returns Promise<void>

  • Parameters

    • callback: ((error) => void)
        • (error): void
        • Parameters

          • error: Error

          Returns void

    Returns void

  • Parameters

    • reconnectDelayMillis: number = RECONNECT_DELAY

    Returns Promise<void>

  • Subscribes to the H2SO feed.

    Parameters

    • pairs: Pair[]

      Pairs to subscribe to.

    • callback: SubscriptionCallback

      Callback for receiving updates.

    • shouldSendExistingPrice: boolean = true

      Whether to immediately call the callback with an exiting price, if available. If this is set to false, the callback will only be called when a remote price update is received.

    Returns number

  • Subscribes to price updates from the remote server. Only returns when the prices have been received.

    Parameters

    • pairs: Pair[]

    Returns Promise<void>

  • Unsubscribes from price updates from the remote server.

    Parameters

    • pairs: Pair[]

    Returns void

  • Parameters

    • pair: Pair
    • shouldReturnExisting: boolean = false
    • timeoutMillis: number = 15_000

    Returns Promise<TimestampedPrice>

Generated using TypeDoc