import type { OrderBookId } from "../../shared"; import type { OrderBook } from "./wire"; export type OrderbookApplyResult = { kind: "applied"; } | { kind: "ignored"; reason: OrderbookIgnoreReason; } | { kind: "refresh_required"; reason: OrderbookRefreshReason; }; export type OrderbookIgnoreReason = { kind: "invalid_delta_sequence"; got: number; } | { kind: "stale_delta"; current: number; got: number; } | { kind: "already_awaiting_snapshot"; got: number; }; export type OrderbookRefreshReason = { kind: "missing_snapshot"; got: number; } | { kind: "sequence_gap"; expected: number; got: number; } | { kind: "server_resync"; got: number; }; export declare class OrderbookState { readonly orderbookId: OrderBookId; seq: number; private readonly bidsMap; private readonly asksMap; private cachedBestBid; private cachedBestAsk; private hasSnapshot; private awaitingSnapshot; constructor(orderbookId: OrderBookId); /** * Apply a WS orderbook message (snapshot replaces, delta merges). * * Server resync messages take precedence and return `refresh_required`. * Otherwise, snapshots are applied and deltas with a `seq` at or below the * current value are ignored to prevent stale updates. Deltas that skip one * or more expected sequence values are rejected so callers can refresh from * a fresh snapshot instead of mutating a corrupted book. */ apply(book: OrderBook): OrderbookApplyResult; bids(): ReadonlyMap; asks(): ReadonlyMap; bestBid(): string | undefined; bestAsk(): string | undefined; midPrice(): string | undefined; spread(): string | undefined; isEmpty(): boolean; clear(): void; } //# sourceMappingURL=state.d.ts.map