/// import { EventEmitter } from 'events'; import { RestPublicClient } from '#client/rest/public'; import { OrderBookRealTimeClientEvent } from '#types/enums/index'; import type * as kuma from '#index'; /** * Orderbook Client Options * * @see typedoc [Reference Documentation](https://sdk-js-docs-v1.kuma.bid/classes/OrderBookRealTimeClient.html) */ export interface OrderBookRealTimeClientOptions { /** * Optionally provide an `apiKey` for increased rate limiting */ apiKey?: string; /** * Controls whether the production or sandbox endpoints will be used */ sandbox?: boolean; /** * Optionally provide a custom url to use when making Kuma REST API requests. * * - Will override the {@link sandbox} option when given. */ baseRestApiURL?: string; /** * Optionally provide a custom WebSocket API URL to use when connecting to * the Kuma WebSocket API. * * - Will override the {@link sandbox} option when given. */ baseWebSocketURL?: string; marketsResponse?: kuma.RestResponseGetMarkets; } /** * Orderbook API client * * @see typedoc [Reference Documentation](https://sdk-js-docs-v1.kuma.bid/classes/OrderBookRealTimeClient.html) * @see options {@link OrderBookRealTimeClientOptions} * @see events {@link OrderBookRealTimeClientEvent} * * @category API Clients * * @example * ```typescript * import { * OrderBookRealTimeClient, * OrderBookRealTimeClientEvent, * type L2OrderBook * } from '@kumabid/kuma-sdk'; * * // type is just to show it will match the form string-string. * // actual type will be typed as string * type MarketSymbol = `${string}-${string}`; * * const LIMIT = 10; * const MARKETS: MarketSymbol[] = ['Kuma-USD']; * * const client = new OrderBookRealTimeClient({ * sandbox: true, * }); * * client.start(MARKETS); * * const orderbooksMap = new Map() * * async function handleOrderBookLevel2(market: MarketSymbol) { * const levelTwoOrderBook = await client.getOrderBookL2(market, LIMIT); * * orderbooksMap.set(market, levelTwoOrderBook) * * console.log('Updated OrderBook for market: ', market, levelTwoOrderBook); * } * * client.on(OrderBookRealTimeClientEvent.ready, () => { * MARKETS.forEach(market => { * handleOrderBookLevel2(market) * }) * }); * * client.on(OrderBookRealTimeClientEvent.l2, handleOrderBookLevel2); * ``` */ export declare class OrderBookRealTimeClient extends EventEmitter<{ [OrderBookRealTimeClientEvent.ready]: [market: string]; [OrderBookRealTimeClientEvent.connected]: []; [OrderBookRealTimeClientEvent.disconnected]: []; [OrderBookRealTimeClientEvent.error]: [error: Error]; [OrderBookRealTimeClientEvent.l1]: [market: string]; [OrderBookRealTimeClientEvent.l2]: [market: string]; [OrderBookRealTimeClientEvent.sync]: [market: string]; }> { private readonly l1OrderBooks; private readonly l2OrderBooks; private readonly l2OrderBookUpdates; private markets; private readonly marketsByAssetSymbol; /** * When creating an {@link OrderBookRealTimeClient}, a public client is automatically * created and can be used based to make additional public requests if needed. * * - Can be utilized to fetch public data instead of creating both clients. * * @category Accessors */ readonly public: RestPublicClient; private marketsResponse; private isTickSizesLoaded; private readonly tickSizesByMarket; private readonly webSocketClient; private webSocketConnectionListenersConfigured; private webSocketResponseListenerConfigured; /** * @see typedoc [Reference Documentation](https://sdk-js-docs-v1.kuma.bid/classes/OrderBookRealTimeClient.html) * * @category Constructor */ constructor(options?: OrderBookRealTimeClientOptions); /** * Loads initial state from REST API and begin listening to orderbook updates. * * @see typedoc [Reference Documentation](https://sdk-js-docs-v1.kuma.bid/classes/OrderBookRealTimeClient.html#start) * * @category Connection Management */ start(markets: string[], marketsResponse?: kuma.RestResponseGetMarkets): Promise; /** * Stop the order book client, and reset internal state. * Call this when you are no longer using the client, to release memory and network resources. * * @see typedoc [Reference Documentation](https://sdk-js-docs-v1.kuma.bid/classes/OrderBookRealTimeClient.html#stop) * * @category Connection Management */ stop(): void; getMaximumTickSizeUnderSpread(market: string): Promise; /** * Load the current state of the level 1 orderbook for this market. * * @param tickSize * Minimum price movement expressed in pips (10^-8), defaults to market setting * * @see typedoc [Reference Documentation](https://sdk-js-docs-v1.kuma.bid/classes/OrderBookRealTimeClient.html#getOrderBookL1) * @see response {@link RestResponseGetOrderBookLevel1} * * @category Requests */ getOrderBookL1(market: string, tickSize?: bigint | undefined): Promise; /** * Load the current state of the level 2 orderbook for this market. * * @param limit * Total number of price levels (bids + asks) to return * - Between 2 and 1000 * - Defaults to `100` * @param tickSize * Minimum price movement expressed in pips (10^-8), defaults to market setting * * @see typedoc [Reference Documentation](https://sdk-js-docs-v1.kuma.bid/classes/OrderBookRealTimeClient.html#getOrderBookL2) * @see response {@link RestResponseGetOrderBookLevel2} * * @category Requests */ getOrderBookL2(market: string, limit?: number, tickSize?: bigint | undefined): Promise; private getOrderBooks; private applyOrderBookUpdates; private synchronizeFromRestApi; private loadLevel2; private loadTickSizes; private mapTokensToMarkets; private resetInternalState; private setupInternalWebSocket; private subscribe; private unsubscribe; private webSocketHandleConnect; private webSocketHandleDisconnect; private webSocketHandleError; private webSocketHandleResponse; } //# sourceMappingURL=realTime.d.ts.map