/** * Orderbook WebSocket Events * * Defines the structure for orderbook-related WebSocket events. */ import type { OrderSide, TradingMode } from "../../trading"; import type { RawEventMessage } from "../base"; /** * Raw event message interface * This is the raw message received from the backend */ export type RawOrderbookEventMessage = RawEventMessage & { /** Event data */ data: unknown; }; /** * Orderbook price level */ export interface OrderbookLevel { /** Price level */ price: string; /** Total quantity at this price level */ quantity: string; /** Number of orders at this price level */ orderCount: number; } /** * Price change information */ export interface PriceChange { /** Order side (BUY or SELL) */ side: OrderSide; /** Old price before the change */ oldPrice?: string; /** New price after the change */ newPrice?: string; /** Whether a price level was removed */ levelRemoved: boolean; /** Whether a price level was added */ levelAdded: boolean; } /** * Orderbook update event */ export interface OrderbookEvent { /** Trading pair ID (UUID) */ tradingPairId: string; /** Trading mode (SPOT, MARGIN) */ tradingMode: TradingMode; /** Bid orders (buy orders) - Full depth */ bids: OrderbookLevel[]; /** Ask orders (sell orders) - Full depth */ asks: OrderbookLevel[]; /** Best bid price */ bestBid?: string; /** Best ask price */ bestAsk?: string; /** Total bid volume */ bidVolume?: string; /** Total ask volume */ askVolume?: string; /** Price change information */ priceChange?: PriceChange; /** Base token decimals */ baseDecimals: number; /** Quote token decimals */ quoteDecimals: number; /** Event timestamp */ timestamp: string; /** Sequence number for ordering */ sequence: number; }