import type { MarketEvent } from "../domain/market"; import { type AuthUpdate, type UserUpdate } from "../domain/order/wire"; import type { OrderBook, WsTickerData } from "../domain/orderbook"; import { type BookAggregation } from "../domain/orderbook/aggregation"; import type { DepositAssetPriceEvent, DepositPrice, PriceHistory } from "../domain/price_history"; import type { WsTrade } from "../domain/trade"; import type { WalletDepositBalancesEvent } from "../domain/position"; import type { OrderBookId, PubkeyStr, Resolution } from "../shared"; export * from "./client.node"; export * from "./subscriptions"; export type { IWsClient } from "./types"; export type MessageOut = { method: "subscribe"; params: import("./subscriptions").SubscribeParams; } | { method: "unsubscribe"; params: import("./subscriptions").UnsubscribeParams; } | { method: "ping"; }; /** Parsed inbound channel union; wallet balances contain a strict nested event union. */ export type MessageIn = { type: "book_update"; version: number; data: OrderBook; } | { type: "pong"; version: number; data: Record; } | { type: "user"; version: number; data: UserUpdate; } | { type: "error"; version: number; data: WsError; } | { type: "price_history"; version: number; data: PriceHistory; } | { type: "trades"; version: number; data: WsTrade; } | { type: "auth"; version: number; data: AuthUpdate; } | { type: "ticker"; version: number; data: WsTickerData; } | { type: "market"; version: number; data: MarketEvent; } | { type: "deposit_price"; version: number; data: DepositPrice; } | { type: "deposit_asset_price"; version: number; data: DepositAssetPriceEvent; } | { type: "wallet_deposit_balances"; version: number; data: WalletDepositBalancesEvent; }; export type Kind = MessageIn; export interface WsError { error: string; code?: string; orderbook_id?: string; /** * Aggregation of the affected book subscription on book-scoped errors * (`ENGINE_UNAVAILABLE`, `SUBSCRIPTION_LIMIT_REACHED`, * `INVALID_ORDERBOOK_SUBSCRIPTION`). Absent = full precision; pass to * `aggregationFromFrame` to identify the `(orderbook, aggregation)` pair. */ n_sig_figs?: number; mantissa?: number; wallet_address?: string; deposit_asset?: string; hint?: string; details?: string; } export type WsEvent = { type: "Message"; message: MessageIn; } | { type: "Connected"; } | { type: "Disconnected"; code?: number; reason: string; } | { type: "Error"; error: string; } | { type: "MaxReconnectReached"; }; export interface WsConfig { url: string; reconnect: boolean; maxReconnectAttempts: number; baseReconnectDelayMs: number; pingIntervalMs: number; pongTimeoutMs: number; } export declare const WS_DEFAULT_CONFIG: WsConfig; export declare enum ReadyState { Connecting = 0, Open = 1, Closing = 2, Closed = 3 } export declare function readyStateFrom(value: number): ReadyState; export declare function ping(): MessageOut; /** * Subscribe to book snapshots, optionally aggregated (Hyperliquid-style). * * Omit `aggregation` for the raw book. The aggregation is normalized before * sending ((5, none) → (5, 1)); validate with `validateAggregation` first — * invalid combinations are rejected server-side with * `INVALID_ORDERBOOK_SUBSCRIPTION`. `undefined` fields are dropped by * `JSON.stringify`, so full precision stays byte-identical to the * pre-aggregation message. */ export declare function subscribeBooks(orderbookIds: OrderBookId[], aggregation?: BookAggregation): MessageOut; /** * Unsubscribe a book subscription. The aggregation must match the one * subscribed (normalized) or the server removes nothing. */ export declare function unsubscribeBooks(orderbookIds: OrderBookId[], aggregation?: BookAggregation): MessageOut; export declare function subscribeTrades(orderbookIds: OrderBookId[]): MessageOut; export declare function unsubscribeTrades(orderbookIds: OrderBookId[]): MessageOut; export declare function subscribeUser(walletAddress: PubkeyStr): MessageOut; export declare function unsubscribeUser(walletAddress: PubkeyStr): MessageOut; /** * Subscribe to a wallet owned by the authenticated user. * The channel begins with a complete replacement snapshot and then emits * absolute SPL/native updates plus non-mutating status events. */ export declare function subscribeWalletDepositBalances(walletAddress: PubkeyStr): MessageOut; /** * Stop the authenticated wallet stream identified by this exact wallet address. * This wire operation is separate from clearing local reconnect tracking. */ export declare function unsubscribeWalletDepositBalances(walletAddress: PubkeyStr): MessageOut; export declare function subscribePriceHistory(orderbookId: OrderBookId, resolution: Resolution): MessageOut; export declare function unsubscribePriceHistory(orderbookId: OrderBookId, resolution: Resolution): MessageOut; export declare function subscribeTicker(orderbookIds: OrderBookId[]): MessageOut; export declare function unsubscribeTicker(orderbookIds: OrderBookId[]): MessageOut; export declare function subscribeMarket(marketPubkey: PubkeyStr): MessageOut; export declare function unsubscribeMarket(marketPubkey: PubkeyStr): MessageOut; export declare function subscribeDepositPrice(depositAsset: string, resolution: Resolution): MessageOut; export declare function unsubscribeDepositPrice(depositAsset: string, resolution: Resolution): MessageOut; /** * Subscribe to the live spot price for one deposit asset (snapshot + * per-asset price ticks). Distinct from `subscribeDepositPrice`, which * carries OHLCV candles per resolution. */ export declare function subscribeDepositAssetPrice(depositAsset: string): MessageOut; export declare function unsubscribeDepositAssetPrice(depositAsset: string): MessageOut; /** * Parse and normalize one inbound frame. * * Wallet-balance payloads cross a runtime validation boundary here: malformed * nested discriminators, exact values, or slots throw a protocol `WsError` * instead of escaping behind TypeScript-only types. */ export declare function parseMessageIn(input: string): MessageIn; //# sourceMappingURL=index.d.ts.map