WebSocketClient Setup
TheWebSocketClient connects to the Limitless Exchange WebSocket server for real-time market data, position updates, order lifecycle events, and transaction notifications.
Constructor Options
Public subscriptions (market prices) do not require authentication. Authenticated subscriptions (positions, order events, transactions) require
hmacCredentials — see Authentication to generate a token.Public Subscriptions
Market Prices
Subscribe to real-time price updates for one or more markets. No authentication required.Authenticated Subscriptions
These subscriptions requirehmacCredentials passed to the constructor. The SDK signs the WebSocket handshake automatically.
Positions
Subscribe to real-time updates when your positions change:Order Events
Subscribe to CLOB order lifecycle and settlement events for your account:orderEvent uses source as a discriminator:
source: 'OME'— off-chain order state changes: placement, update, cancellation.source: 'SETTLEMENT'— on-chain settlement results for the taker order and each matched maker order.
clientOrderId is the id of the recipient’s own orderId. If only one side of a trade supplied a clientOrderId, only that side’s event includes it. Counterparty order ids inside takerOrderId or makerMatches[] are not resolved to client ids.
Transactions
Subscribe to transaction confirmations:Events
orderbookUpdate (CLOB markets)
Fired when a CLOB market orderbook changes. Contains the full updated orderbook.newPriceData (AMM markets)
Fired when AMM market prices update.positions
Fired when any of your positions change (fill, cancel, resolution).tx
Fired on transaction events related to your account.Type Definitions
Connection Management
Disconnect handling
Listen for disconnections and clean up resources:When
autoReconnect is enabled, the client automatically attempts to reconnect. However, you must re-send your subscriptions after reconnection. Listen for the reconnect event to resubscribe.