What is CoW Protocol Services?
CoW Protocol Services is the backend infrastructure that powers CoW Protocol, a decentralized trading protocol that uses batch auctions to provide MEV protection and better prices for traders. This repository contains the core Rust-based services that handle order validation, auction management, solution computation, and settlement execution across multiple EVM networks. The services coordinate to create a trustless, decentralized exchange where orders are batched together and settled using the best available liquidity sources, including AMMs, aggregators, and direct peer-to-peer Coincidence of Wants (CoW) matches.Key Benefits
MEV Protection
Batch auctions protect traders from frontrunning and sandwich attacks by executing all orders at uniform clearing prices
Best Execution
Competition between solvers ensures the best possible prices by sourcing liquidity from multiple venues
Gasless Trading
Solvers pay gas costs upfront, enabling efficient batching and reducing per-order transaction costs
CoW Matches
Direct peer-to-peer settlement when buy and sell orders overlap, eliminating the need for external liquidity
Multi-Chain Support
CoW Protocol Services runs on multiple EVM-compatible networks:- Ethereum Mainnet - The primary deployment with the deepest liquidity
- Gnosis Chain - Low-cost transactions with fast finality
- Arbitrum One - Layer 2 scaling with lower fees
- Base - Coinbase’s Layer 2 network
- Polygon - Alternative Layer 2 with broad adoption
- BNB Chain - Binance’s smart contract platform
- And more - Linea, Ink, Sepolia testnet
Core Features
Order Management
- Flexible Order Types: Market orders, limit orders, partially fillable orders, and more
- EIP-712 Signed Orders: Off-chain order signing without on-chain gas costs
- Order Validation: Real-time checks for balance, approval, and order viability
- Order Persistence: PostgreSQL-backed storage with efficient querying
Auction Mechanism
- Periodic Auctions: New auctions every ~12-15 seconds (moving toward per-block auctions)
- Solver Competition: Multiple solvers compete to provide the best execution
- Solution Ranking: Automated selection based on execution quality and gas costs
- Fair Settlement: All orders in a batch receive uniform clearing prices
Liquidity Aggregation
- AMM Integration: Uniswap, Balancer, Curve, and other DEX protocols
- Aggregator APIs: 1inch, 0x, and other liquidity sources
- CoW Discovery: Automatically matches opposing orders for direct settlement
- Custom Solvers: External solver partners can implement custom routing strategies
System Components
CoW Protocol Services consists of four main service components:Orderbook
HTTP API for order submission, quotes, and order status queries. Validates and persists orders to PostgreSQL.
Autopilot
The protocol driver that manages auction lifecycle, cuts new auctions, sends them to solvers, and ranks solutions.
Driver
Handles liquidity collection, solution encoding, simulation, and on-chain submission. Co-located with solver engines.
Solver
Optimization engines that compute optimal routing and matching. Can be internal (baseline) or external APIs.
Architecture Overview
The services work together in a coordinated flow:- Users submit signed orders to the Orderbook via the HTTP API
- Autopilot periodically creates auctions with valid orders and sends them to solvers
- Drivers fetch liquidity, solvers compute optimal solutions
- Autopilot ranks solutions and selects the winner
- Driver simulates and submits the winning solution to the settlement contract
- Settlement Contract executes trades atomically on-chain
Technology Stack
Rust
High-performance, memory-safe systems programming
Tokio
Asynchronous runtime for concurrent operations
PostgreSQL
Reliable storage for orders, auctions, and settlements
Alloy
Modern Ethereum library for blockchain interactions
API Documentation
All HTTP APIs are documented with OpenAPI specifications:- Orderbook API - Submit orders, get quotes, query order status
- Driver API - Solver integration endpoints
- Solver API - External solver protocol
Getting Started
Quickstart
Get a local CoW Protocol environment running in minutes with Docker Compose
Architecture
Understand the system design, data flow, and component interactions
Development
Set up your development environment and learn the testing workflow
API Reference
Explore the REST API endpoints for integration
Learn More
- CoW Protocol Documentation - Protocol fundamentals and concepts
- GitHub Repository - Browse the source code
- CoW Swap - The main user interface for CoW Protocol
- Example Trading Bot - Sample integration code
The services are licensed under GPL-3.0-or-later. All binaries support
--help for comprehensive command documentation.