Order Types
Limit Orders
Market Orders
Cancel Orders
Batch Updates
Combine limit orders and cancels into a single atomic transaction:
Configuration
ConfigManager
The SDK uses ConfigManager to load configuration from environment variables with sensible defaults. See the Quick Start for the full list of environment variables.
ConfigPresets
Use presets for common scenarios:
Production Guidance
Use a Dedicated RPC
The default public endpoints can be rate-limited. For production, use a dedicated RPC provider via RPC_URL and RPC_WS_URL.
Quote Cadence and Gas
Batch cancel/replace every second is expensive on-chain. Common approaches:
- Update only when mid price moves beyond a threshold
- Update at a slower cadence (e.g., 5-15s) unless volatility spikes
- Use fewer levels or smaller grids
- Enable EIP-2930 access list optimization (
KURU_USE_ACCESS_LIST=true)
If you see “out of gas” or “gas too low” transaction failures, increase the gas buffer multiplier:
Safety Checks
Always implement these safety checks before running in production.
- Stale data guard - Don’t quote if your market data feed is older than N milliseconds
- Min/max size - Ensure order sizes meet market constraints (or the tx will revert)
- Balance guard - Ensure margin balances can support your outstanding orders
- Circuit breakers - Stop quoting on repeated failures, disconnects, or extreme spreads. Use
await client.cancel_all_active_orders_for_market() to cancel all outstanding orders when the circuit breaker triggers
Running Examples