Overview
The Driver sits between Autopilot and solver engines:Responsibilities
- Liquidity Collection: Fetches AMM pools, limit orders, and other liquidity sources
- Auction Translation: Converts autopilot auction format to solver engine format
- Solution Encoding: Transforms abstract solutions into settlement calldata
- Simulation: Validates solutions work on-chain before submission
- Gas Estimation: Computes accurate gas costs for scoring
- Settlement Submission: Sends winning solutions to the blockchain
- Monitoring: Tracks solution status and reports back to Autopilot
Key Endpoints
The Driver implements the solver interface expected by Autopilot.Solve Auction
POST /solve
Request Body
Unique auction identifier (incrementing)
Solvable orders in the auction (see Orderbook Order structure)
Token information including prices and trust status
ISO 8601 UTC timestamp by which solution must be returned
Addresses whose JIT order surplus counts toward objective value
Token Structure
Response
Array of computed solutions
Solution Structure
Order Execution Details
Example Response:200: Solutions computed400: Invalid request500: Internal error
Reveal Calldata
POST /reveal
Request Body
Auction ID containing the solution
Solution ID to reveal
Response
Settlement calldata in two forms
internalized calldata omits these buffer trades, while uninternalized includes them for simulation.
Status Codes:
200: Calldata revealed400: Invalid request (e.g., unknown auction/solution ID)500: Internal error
Settle Auction
POST /settle
Request Body
Auction ID containing the solution
Solution ID to settle
Last block number in which the settlement TX can be included (typically current block + 2-3)
Response
Empty body with200 OK status indicates driver accepted the settlement request and will attempt submission.
Status Codes:
200: Settlement accepted400: Invalid request500: Internal error
Settlement Process
- Encode: Convert abstract solution to settlement calldata
- Simulate: Verify execution on-chain (using
uninternalizedcalldata) - Sign: Sign transaction with solver’s private key
- Submit: Broadcast to mempool or use private RPC
- Monitor: Track transaction until confirmation or deadline
- Report: Notify Autopilot of outcome via callback
Receive Notification
POST /notify
Request Body
Notification reason (currently only
"banned")200: Notification received
Get Quote
GET /quote
Query Parameters
Token to sell
Token to buy
Quote type:
"buy" or "sell"Amount to buy or sell (in atoms)
ISO 8601 UTC timestamp by which quote must be returned
Response
Either LegacyQuoteResponse, QuoteResponse, or Error
200: Quote computed400: Invalid request429: Solver too busy500: Internal error
Liquidity Collection
The Driver collects on-chain liquidity to provide to solver engines:Liquidity Sources
- Constant Product Pools (Uniswap V2 style)
- Token reserves, fee, router address
- Weighted Product Pools (Balancer style)
- Token weights, reserves, scaling factors
- Pool ID, version
- Stable Pools (Curve style)
- Amplification parameter
- Scaling factors
- Concentrated Liquidity (Uniswap V3 style)
- Current sqrt price, liquidity
- Tick data (liquidity net per tick)
- Foreign Limit Orders (0x style)
- Maker/taker tokens and amounts
- Fee amounts
Liquidity Object
- id: Unique identifier (within auction)
- address: On-chain address
- gasEstimate: Approximate gas cost to use this liquidity
- kind-specific fields: Pool parameters
Solution Encoding
The Driver transforms abstract solver solutions into settlement calldata:Settlement Contract Interface
Calldata is constructed for thesettle() function:
Interaction Types
- Pre-interactions: Executed before trades (e.g., token approvals)
- Intra-interactions: Executed between trades (e.g., AMM swaps)
- Post-interactions: Executed after trades (e.g., unwrap WETH)
Internalization (CIP-2)
When tokens are trusted, solvers can internalize trades:- Skip AMM swap: Use settlement contract buffer instead
- Gas Savings: Reduces transaction cost
- Two Calldata Versions:
internalized: Omits buffer trades (on-chain)uninternalized: Includes buffer trades (simulation)
Configuration
Driver behavior is configured via TOML files. Key settings:Solver Engines
Liquidity Sources
Settlement
example.toml in the driver crate for full configuration options.
Error Handling
The Driver can fail at various stages:Solve Failures
- No Liquidity: No viable route found
- Solver Timeout: Engine didn’t respond in time
- Invalid Solution: Solution violates constraints
Reveal Failures
- Unknown Solution: Solution ID not found (expired cache)
- Encoding Error: Cannot construct calldata
Settlement Failures
- Simulation Failed: Transaction would revert
- Gas Too High: Exceeds configured cap
- Deadline Passed: Block deadline already reached
- Submission Failed: RPC error or transaction dropped
- Revert On-Chain: Transaction reverted after submission
Monitoring and Metrics
The Driver exposes metrics for observability:Key Metrics
- Solve latency: Time to compute solutions
- Solution count: Number of solutions per auction
- Win rate: Percentage of auctions won
- Gas accuracy: Estimated vs actual gas usage
- Settlement success rate: Percentage of settlements that succeed
- Revert reasons: Categories of settlement failures
Logging
Structured logs include:- Auction ID
- Solution ID
- Order UIDs
- Token addresses
- Amounts and prices
- Gas estimates
- Error messages
Best Practices
- Accurate Gas Estimates: Critical for correct solution scoring
- Fast Response Times: Respect deadlines, account for network latency
- Thorough Simulation: Always simulate before submitting settlements
- Handle Reverts Gracefully: Log detailed error information
- Monitor RPC Health: Use multiple RPC endpoints for redundancy
- Manage Private Keys Securely: Use hardware wallets or secure key management
- Set Reasonable Caps: Configure gas price and slippage limits
- Cache Liquidity: Update liquidity periodically, not per auction
- Implement Backoff: Retry failed submissions with exponential backoff
- Track Metrics: Monitor performance and optimize bottlenecks
