How nexus-xyz/nexus-exchange-rs works
nexus-exchange is an official Rust SDK for Nexus Exchange, wrapping its REST API and two distinct WebSocket protocols. The main workflow is an application configuring a client, making public or authenticated market/account/trading requests, then consuming typed results or live events. Signed calls use the authentication abstractions; cursor-based list calls can be paged lazily. The sampled source confirms these boundaries, but does not expose every endpoint implementation, so the graph keeps REST capabilities grouped rather than inferring internal route-to-route calls.
Main entry points: client.rs HTTP client · typed.rs Typed subscriptions · rest.rs REST endpoints · pagination.rs Cursor pagination
Components 18
REST API
- REST endpoints
src/rest.rs - Market utilities
src/markets.rs - Cursor pagination
src/rest/pagination.rs
Authentication
- API credentials
src/auth/mod.rs - Agent signing
src/auth/agent.rs - Wallet signing
src/auth/eth.rs
Streaming
- Market stream
src/stream.rs - Account WebSocket
src/ws.rs - Typed subscriptions
src/ws/typed.rs - WS protocol
src/ws/protocol.rs - Reconnect backoff
src/ws/backoff.rs
Client core
- HTTP client
src/client.rs - Network config
src/config.rs - Rate limiting
src/ratelimit.rs - Typed models
src/types.rs
Other components
- SDK caller
- Nexus REST API
- Nexus WebSocket API
Connections 23
- SDK caller → HTTP client: configures
- SDK caller → REST endpoints: requests data
- SDK caller → Market stream: opens stream
- SDK caller → Typed subscriptions: subscribes
- REST endpoints → HTTP client: sends requests
- HTTP client → Network config: uses settings
- HTTP client → API credentials: signs requests
- HTTP client → Rate limiting: paces requests
- HTTP client → Nexus REST API: sends HTTP
- Nexus REST API → HTTP client: returns responses
- REST endpoints → Cursor pagination: builds pagers
- Cursor pagination → HTTP client: fetches pages
- REST endpoints → Market utilities: uses rounding
- Wallet signing → SDK caller: returns signed bodies
- Agent signing → HTTP client: provides signatures
- Market stream → Nexus WebSocket API: connects publicly
- Account WebSocket → Nexus WebSocket API: connects privately
- Typed subscriptions → WS protocol: encodes and decodes
- Typed subscriptions → HTTP client: mints stream token
- Typed subscriptions → Reconnect backoff: retries connections
- Typed subscriptions → Nexus WebSocket API: subscribes
- Nexus WebSocket API → Typed subscriptions: delivers events
- Nexus REST API → Typed models: JSON follows types