Overview
Venue adapters connect Notional’s event-driven architecture to external exchanges. The adapter pattern enables:- Multi-venue support - Trade across multiple exchanges
- Unified interface - Consistent API regardless of venue
- Async execution - Non-blocking order submission
- Automatic reconciliation - Detect and correct state drift
Architecture
Hyperliquid Adapter
The primary venue adapter integrates with Hyperliquid, managing order submission, fill reconciliation, and connection reliability.Order Management
The adapter implements priority queuing and concurrent order limits (Hyperliquid supports max 100 concurrent orders). Priority System:- System-initiated orders (liquidations): Priority 0 (highest)
- User orders: Priority 1
- Orders queued with priority
- Respects 100 concurrent order limit
- Converts internal format to Hyperliquid wire format
- Tracks in-flight orders by order ID
Retry Logic
Exponential backoff:Delay = min(2^n × 100ms + Jitter, 10s). Maximum 5 retries before escalating to dead letter queue.
Connection Reliability
WebSocket: Automatic reconnection with 30s heartbeat timeout. Position reconciliation on reconnect to verify state. Dual-channel architecture: REST for order submission (synchronous ack), WebSocket for fills (real-time).Fill Reconciliation
Matches venue fills to internal orders via order ID tracking. Handles out-of-order notifications and logs discrepancies for manual review.Event Flow
Wire Format Conversion
Hyperliquid uses shortened field names for efficiency. Internal orders are converted to wire format: Internal Format:asset: Asset name (e.g., “BTC”)side: “buy” or “sell”limitPx: Limit price as stringsz: Order sizereduceOnly: Boolean flag
a: Asset index (integer)b: Buy flag (true/false)p: Price (trailing zeros removed)s: Sizer: Reduce only flagt: Time-in-force specificationc: Client order ID (for tracking)