Purpose and Responsibilities
Autopilot acts as the protocol’s auctioneer and coordinator:- Auction Management: Runs auctions every ~12-15 seconds (eventually every block)
- Order Filtering: Selects solvable orders from the orderbook based on validity and balances
- Fee Policy Application: Applies protocol fee policies to orders
- Solver Competition: Distributes auctions to drivers and collects solutions
- Winner Selection: Ranks solutions and picks the best settlement(s)
- Settlement Monitoring: Tracks on-chain execution and settlement outcomes
Auction Management
Auction Cycle
Autopilot runs a continuous loop with the following phases:- Block synchronization (0-2s): Wait for new block
- Maintenance (0-5s): Update prices, indexed events, and CoW AMMs
- Order preparation (0-1s): Fetch and filter solvable orders
- Solver competition (12-15s): Send auction to drivers, collect solutions
- Winner selection (0-1s): Rank solutions and pick winner(s)
- Settlement execution (1-60s): Winning driver(s) submit to chain
The
solve_deadline parameter controls how long solvers have to compute solutions. Default is 15 seconds.Auction Creation
The autopilot creates auctions from solvable orders:Order Inclusion Logic
The autopilot filters orders to include in each auction:Filtering Criteria
Valid orders must meet:- ✅ Valid signature
- ✅ Not expired (valid until timestamp not reached)
- ✅ Sufficient balance (unless
disable_order_balance_filteris set) - ✅ Not from banned addresses
- ✅ Not using denied tokens
- ✅ Minimum validity period remaining
- ✅ Compatible with current auction ID
Order Types
The autopilot handles multiple order types:- Market orders: Fill-or-kill orders seeking immediate execution
- Limit orders: Partial-fill allowed, can remain in orderbook
- EthFlow orders: Orders created via ETH deposits
- CoW AMM orders: Automated market maker orders
Solver Competition Coordination
Driver Communication
Autopilot distributes auctions to all configured drivers:Competition Process
Request Compression
For large auctions, autopilot can compress/solve request bodies:
Fee Policies
Autopilot applies protocol fee policies to orders based on their characteristics:Fee Policy Types
Fromcrates/autopilot/src/config/fee_policy.rs:
Fee Configuration
Fee policies are configured per order class:Partner Fees
The protocol supports partner fee caps:Upcoming Fee Changes
Fee policies can be scheduled for future activation:Configuration Options
Command-Line Arguments
Key parameters fromcrates/autopilot/src/arguments.rs:
| Argument | Environment Variable | Default | Description |
|---|---|---|---|
--config | CONFIG | Required | Path to TOML config |
--metrics-address | METRICS_ADDRESS | 0.0.0.0:9589 | Metrics server address |
--api-address | API_ADDRESS | 0.0.0.0:12088 | API server address |
--db-write-url | DB_WRITE_URL | postgresql:// | Database URL |
--solve-deadline | SOLVE_DEADLINE | 15s | Solver time limit |
--submission-deadline | SUBMISSION_DEADLINE | 5 | Max blocks for settlement |
--max-settlement-transaction-wait | MAX_SETTLEMENT_TRANSACTION_WAIT | 1m | Settlement wait time |
--max-auction-age | MAX_AUCTION_AGE | 5m | Max time since last auction |
--max-winners-per-auction | MAX_WINNERS_PER_AUCTION | 20 | Max parallel winners |
--max-solutions-per-solver | MAX_SOLUTIONS_PER_SOLVER | 3 | Solutions per solver |
--max-run-loop-delay | MAX_RUN_LOOP_DELAY | 2s | Max delay before resync |
--enable-leader-lock | ENABLE_LEADER_LOCK | false | Enable HA leader election |
--compress-solve-request | COMPRESS_SOLVE_REQUEST | false | Compress auction data |
--skip-event-sync | SKIP_EVENT_SYNC | false | Skip historical events |
Configuration File
The autopilot requires a TOML configuration file:Running the Service
Basic Setup
Shadow Mode
For testing without actual settlements:High Availability
Enable leader election for multiple autopilot instances:Database Schema Usage
Autopilot interacts with several PostgreSQL tables:Core Tables
orders: Stores all submitted ordersorder_events: Tracks order lifecycle eventstrades: Records executed tradessettlements: Stores settlement transaction datasolver_competitions: Archives competition resultsauction_prices: Caches native token prices
Event Indexing
Autopilot indexes on-chain events:- Settlement events from GPv2Settlement contract
- EthFlow order creation and refunds
- CoW AMM pool deployments and updates
Cleanup Tasks
Periodic database maintenance:Observability
Metrics
Prometheus metrics available athttp://localhost:9589/metrics:
autopilot_auction_duration_seconds- Time to complete auctionautopilot_solutions_received- Solutions per auctionautopilot_settlement_submissions- Settlement submission attemptsautopilot_last_auction_timestamp- Last successful auction time
Liveness Checks
The service implements liveness checking:max_auction_age.
Logging
Structured logging with contextual information:Advanced Features
CoW AMM Integration
Autopilot can index and include CoW AMM pools:factory_address|helper_address|start_block
EthFlow Support
Enable EthFlow order handling:Archive Node
For historical event indexing:Performance Tuning
Solver Deadline
Balance between solution quality and auction frequency:
Maintenance Timeout
Limit maintenance time to avoid stalling:
Database Pool
Tune connection pool for load:
Request Compression
Enable for large auctions:
Troubleshooting
Auctions Not Running
Check:- Database connectivity
- Ethereum node sync status
- Driver availability
- Liveness check status
No Solvable Orders
Common causes:- All orders expired
- Insufficient balances
- Token deny list blocking trades
- Price estimation failures
Settlement Failures
Investigate:- Driver logs for error details
- On-chain transaction status
- Gas price estimation
- Smart contract event logs
