import { PublicApiTransports } from "../../shared/transports.js"; import { PolyesterRequestOptions } from "../../shared/request-options.js"; import { PolyesterRealtime } from "../../realtime/types.js"; import { BaseSubscribeInput } from "../../shared/types.js"; import { SdkScales } from "../../shared/decimal-surface.js"; import { GetOrderbookInputSchema, OrderbookData } from "./orderbook.schemas.js"; import * as v from "valibot"; //#region src/services/orderbook/orderbook.d.ts interface SubscribeOrderbookInput extends BaseSubscribeInput { symbolId: number; depth?: number; bucket?: string | null; } interface OrderbookStreamHandlers extends BaseSubscribeInput {} interface OrderbookSubscription { unsubscribe: () => void; setBucket: (bucket: string | null | undefined) => void; } interface CreateOrderbookSubscriptionInput extends OrderbookStreamHandlers, Pick {} /** * Reads spot order book snapshots and maintains realtime local order book state from public delta channels. */ declare class OrderbookService { #private; constructor(transports: PublicApiTransports, realtime: PolyesterRealtime, scales: SdkScales); /** * Fetches a spot order book depth snapshot for a symbol ID and requested depth, returning best bids and asks with the backend book sequence. */ get(input: v.InferInput, options?: PolyesterRequestOptions): Promise; /** * Subscribes to the managed order book stream for a symbol ID and forwards reconstructed snapshots to onEvent. This is a convenience wrapper around createSubscription().unsubscribe. */ subscribe(input: SubscribeOrderbookInput): () => void; /** * Creates a stateful order book subscription that first fetches a snapshot, buffers proto deltas from public:spot:orderbook:deltas:depth:{depth}:{symbolId}:proto, applies sequence-checked updates, and refetches on observed sequence gaps or reconnects. The returned handle can unsubscribe or change local price bucket aggregation without reconnecting. * * `depth` is clamped to [1, 500] and rides the smallest published channel depth that covers it (see ORDERBOOK_WS_DEPTHS); levels are sliced back to the requested depth locally. * * Refetching is driven by observed sequence gaps and reconnect events only. A feed that stays subscribed but stops publishing is indistinguishable from a quiet market, so it does not trigger onError or a refetch. Callers that must detect a stalled book need their own idle watchdog plus a REST refetch. */ createSubscription(input: CreateOrderbookSubscriptionInput): OrderbookSubscription; } //#endregion export { CreateOrderbookSubscriptionInput, OrderbookService, OrderbookStreamHandlers, OrderbookSubscription }; //# sourceMappingURL=orderbook.d.ts.map