Documentation Index
Fetch the complete documentation index at: https://cowswap-mintlify-docs-audit-1775035615.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
GPv2Settlement Contract
TheGPv2Settlement contract serves as CoW Protocol’s core infrastructure, inheriting from GPv2Signing, ReentrancyGuard, and StorageAccessible to enable batch settlements and order validation.
Source: src/contracts/GPv2Settlement.sol
License: LGPL-3.0-or-later
Solidity: >=0.7.6 <0.9.0
State Variables
Immutable
| Variable | Type | Description |
|---|---|---|
authenticator | GPv2Authentication | Determines solver authorization |
vault | IVault | Balancer Vault for fund management |
vaultRelayer | GPv2VaultRelayer | Enables vault interactions on behalf of users |
Storage
| Variable | Type | Description |
|---|---|---|
filledAmount | mapping(bytes => uint256) | Tracks per-order fill amounts to prevent over-filling |
Primary Functions
settle()
Executes batch orders at uniform clearing prices with pre/intra/post-settlement interactions.swap()
Matches orders directly against Balancer V2 pools for optimized single-pool trades.invalidateOrder()
Allows order owners to revoke on-chain orders by invalidating the order UID.Storage Cleanup
Gas refund functions for expired orders:Settlement Execution Flow
Security Protections
- All orders include a
validTotimestamp checked on execution - Filled amount tracking prevents over-filling
- Limit price validation ensures trades respect order parameters
- Solver authorization restricts settlement access via
onlySolvermodifier nonReentrantmodifier prevents reentrancy attacks