Overview
A typical market making bot has four concurrent loops:- Market data ingestion - Subscribe to the orderbook WebSocket for best bid/ask.
- Quote generation - Decide where to quote (spreads, levels, sizes) based on your model + inventory.
- Execution - Atomically cancel + place quotes using
client.place_orders(). - Order lifecycle & fills - Listen to on-chain events to track placements, fills, and cancellations.
Step 1 - Start the Client
client.start() performs EIP-7702 authorization and connects to the RPC WebSocket for on-chain event tracking.
Step 2 - Set Order Callback
Set an order callback to track your order lifecycle:Alternatively, read from
client.orders_manager.processed_orders_queue instead of using callbacks.Step 3 - Subscribe to Real-time Orderbook Data
FrontendOrderbookUpdate are pre-normalized to human-readable Decimal values. No manual conversion is needed.
Step 4 - Cancel and Place Quotes
Build a grid of orders, cancel stale ones, and send them in a single batch transaction:Tick Size and Rounding
On-chain prices must align tomarket_config.tick_size. When you pass float prices to place_orders(), the SDK converts them to integers using price_precision and then rounds to tick size.
price_rounding options:
Step 5 - Cancel All Orders
To cancel all active orders for the market (useful for circuit breakers or graceful shutdown):Step 6 - React to Fills and Inventory
The SDK delivers order status updates via the callback or queue:
Typical market maker reactions:
- Record fills and PnL
- Adjust inventory targets
- Skew spreads based on inventory (long base → tighten asks, widen bids)
- Refresh quotes more aggressively after fills