Expand description
WebSocket client for dYdX v4 API.
This client provides streaming connectivity to dYdX’s WebSocket API for both public market data and private account updates.
§Authentication
dYdX v4 uses Cosmos SDK wallet-based authentication. Unlike traditional exchanges:
- Public channels require no authentication.
- Private channels (subaccounts) only require the wallet address in the subscription message.
- No signature or API key is needed for WebSocket connections themselves.
§Connection pool
The Indexer caps each WebSocket connection at 32 subscriptions per channel
(v4_trades, v4_candles, v4_orderbook, v4_markets). To scale past that
limit the client maintains a small pool of connection slots and routes each
new subscription to the first slot with capacity, lazily spawning additional
connections up to max_ws_connections. The shape mirrors
BinanceFuturesWebSocketClient (including its connect_lock race fix),
adapted so capacity is tracked per channel kind rather than as a single flat
stream count.
§References
Structs§
- Dydx
WebSocket Client - WebSocket client for dYdX v4 market data and account streams.
Constants§
- DEFAULT_
MAX_ WS_ CONNECTIONS - Default maximum number of WebSocket connections in the Indexer pool.
- DEFAULT_
PER_ CHANNEL_ SUBSCRIPTION_ LIMIT - Default per-connection subscription limit for sharded channels.
- DYDX_
WS_ TOPIC_ DELIMITER - WebSocket topic delimiter for dYdX (channel:symbol format).
Statics§
- DYDX_
RATE_ LIMIT_ KEY_ SUBSCRIPTION - Pre-interned rate limit key for subscription operations (subscribe/unsubscribe).
- DYDX_
WS_ SUBSCRIPTION_ QUOTA - Default WebSocket quota for dYdX subscriptions (2 messages per second).