Skip to main content

Module client

Module client 

Source
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

https://docs.dydx.trade/developers/indexer/websockets

Structs§

DydxWebSocketClient
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).