Token Approvals
Approve Only What You Need
When creating conditional orders, you must approve theGPv2VaultRelayer contract to spend your tokens. Always approve only the exact amount needed for your orders.
For TWAP orders, approve exactly n × partSellAmount:
Review Existing Approvals
Before creating new orders:- Check existing approvals to
GPv2VaultRelayer - Revoke unnecessary or expired approvals
- Use tools like Etherscan to audit your token approvals regularly
Safe Configuration
ExtensibleFallbackHandler Setup
ComposableCoW requires proper Safe configuration:Set the fallback handler
Configure your Safe to use
ExtensibleFallbackHandler at address:
0x2f55e8b20D0B9FEFA187AA7d00B6Cbe563605bF5Set the domain verifier
Set the
domainVerifier for GPv2Settlement.domainSeparator() to ComposableCoWOrder Parameters
Validate Handler Addresses
Always use official handler addresses for conditional order types:Official handler addresses are documented in the deployment section and are the same across all supported networks.
Unique Salt Values
Each conditional order requires a unique salt:Order Validation
Verify Before Creating
Before creating orders on-chain, validate parameters: For TWAP orders:sellToken != buyToken- Cannot trade the same tokenpartSellAmount > 0- Must sell a positive amountminPartLimit > 0- Must have a minimum buy amountt0 < type(uint32).max- Start time must be validn > 1 && n <= type(uint32).max- Must have at least 2 partst > 0 && t <= 365 days- Frequency must be reasonablespan <= t- Span cannot exceed frequency
These validations are enforced on-chain, but checking them off-chain first saves gas on failed transactions.
Test With Small Amounts
When trying a new order type or configuration:- Start with minimal token amounts
- Verify the order executes correctly
- Cancel the test order
- Then create orders with real amounts
Merkle Tree Orders
Secure Proof Storage
When using merkle tree-based orders: Best practices:- Store proofs in multiple secure locations
- Use redundant backup systems
- Consider encrypted storage for sensitive trading strategies
- Document proof generation logic for reproducibility
Proof Validation
Before setting a merkle root:Swap Guards
Restrict Order Execution
Use swap guards to add additional security constraints:Custom Guards
When implementing custom swap guards:- Implement the
ISwapGuardinterface correctly - Keep logic simple and gas-efficient
- Thoroughly test all edge cases
- Consider formal verification for complex guards
Order Cancellation
Cancel Unused Orders
Regularly review and cancel orders that are no longer needed: Single orders:Canceling orders also clears associated cabinet storage, preventing any potential misuse of stored context.
Common Pitfalls
Avoid These Mistakes
Invalid Handler Detection
The contract prevents common errors:Monitoring
Watch Your Orders
After creating orders:- Monitor order execution on CoW Explorer
- Verify orders are picked up by watch towers
- Check that orders execute within expected parameters
- Review filled order details for correctness
Emergency Procedures
If Something Goes Wrong
Revoke approvals if needed
If you suspect a security issue, revoke token approvals to GPv2VaultRelayer
Additional Resources
- Review audit reports for known issues and mitigations
- Check the GitHub repository for latest security updates
- Join the CoW Protocol Discord for community support
- Monitor the bug bounty program for disclosed vulnerabilities
Security is an ongoing process. Stay informed about updates and follow best practices to protect your assets.