Skip to content

feat: Implement Zodiac Module for CoW Swap Trading with Token Allowlist #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 37 commits into from
Feb 7, 2025

Conversation

lumoswiz
Copy link
Owner

@lumoswiz lumoswiz commented Feb 5, 2025

This PR introduces a new Zodiac Module for managing automated trading on CoW Swap with safety controls.

Key Changes

  • Implement TradingModule with order validation capabilities
  • Add isOrderAllowed function to check if token pairs are allowed to trade
  • Setup Foundry-based testing infrastructure

Implementation Details

TradingModule:

  • Validates order UIDs against supplied parameters
  • Executes setPreSignature calls through Safe avatar
  • Integrates with CoWSwapGuard for trade validation

CoWSwapGuard enforces:

  • Target must be GPv2Settlement
  • Token pairs must be allowlisted
  • Only setPreSignature function calls allowed

Technical Notes

  • CoW Protocol's GPv2Order library used for order validation
  • TradingModule inherits from Zodiac's Module and Guardable contracts
  • Dependencies managed through bun and forge remappings

Update CI workflow to install all project dependencies via 'ape pm install'
Previously only installed solady dependency
Add Gnosis Guild Zodiac Module dependencies to contracts/dependencies
Create initial AgentTradingModule contract
Update remappings in ape-config.yaml for new dependencies
Temporarily include Zodiac contract dependencies locally to resolve compilation issues
Replace remapping-based imports with explicit relative paths
Add missing Zodiac guard contracts and interfaces
Add OpenZeppelin contracts for IERC165
Update ape-config.yaml remapping configuration
Add constructor and setUp initializer with required dependencies
Implement initial setOrderTradeable function with core validations
Remove abstract template in favor of concrete implementation
Remove trader-build and trader-test jobs
Add Foundry-based contract testing pipeline
Simplify workflow to lint/build/test smart contracts
Keep Python linting for cow-trader
Add basic test setup with:
- Base test contract with common setup
- Constants contract for addresses
- Utils contract for test helpers
- Initial TokenAllowlist unit tests
TradingModule now focuses on order validation and execution
CoWSwapGuard enforces CoW Swap specific rules:
- Target contract must be GPv2Settlement
- Tokens must be CoW DAO allowed
- Function must be setPreSignature
@lumoswiz lumoswiz marked this pull request as ready for review February 7, 2025 23:17
@lumoswiz lumoswiz merged commit 8a45aed into main Feb 7, 2025
4 checks passed
@lumoswiz lumoswiz deleted the feat/zodiac-module branch February 7, 2025 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant