Documentation Index
Fetch the complete documentation index at: https://cowswap-mintlify-seo-audit-1777280932.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
GPv2Interaction API
TheGPv2Interaction library enables settlement contracts to execute arbitrary external contract calls during trading settlements, supporting complex strategies like liquidity sourcing and protocol integrations.
Data Structure
| Field | Type | Description |
|---|---|---|
target | address | Contract address to call |
value | uint256 | ETH value to send with the call |
callData | bytes | Encoded function call data |
Functions
execute
Performs the actual contract interaction using inline assembly for gas optimization. Propagates revert reasons if calls fail.selector
Extracts the 4-byte function selector from calldata for event logging.Settlement Integration
Interactions run at three distinct phases:| Phase | Stage | Common Use Cases |
|---|---|---|
| Pre-settlement | interactions[0] | Approvals, permits, token wrapping |
| Intra-settlement | interactions[1] | DEX swaps, liquidity sourcing |
| Post-settlement | interactions[2] | Token unwrapping, fee distribution |
Common Use Cases
- DEX swaps for liquidity sourcing (Uniswap, Balancer, Curve)
- Token wrapping/unwrapping (WETH)
- Approval grants to external protocols
- Trade routing through aggregators like 1inch
- EIP-2612 permit calls for gasless approvals
Security
Best Practices
- Order interactions by settlement phase carefully
- Ensure all calls succeed (failures cause the entire settlement to revert)
- Use type-safe encoding methods (e.g.,
abi.encodeWithSelector) rather than manual byte manipulation