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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
11517c7
ci: update dependency installation in workflow
lumoswiz Feb 5, 2025
e50a2d8
feat: add zodiac module dependencies and initial trading module
lumoswiz Feb 5, 2025
b3354e1
fix: use explicit import paths for Zodiac dependencies
lumoswiz Feb 5, 2025
896f166
refactor: remove guardable
lumoswiz Feb 5, 2025
112d76e
feat: add isOrderAllowed view function
lumoswiz Feb 5, 2025
687c2f7
feat: interface for TokenAllowlist
lumoswiz Feb 5, 2025
d52a50f
chore: add cowprotocol contract dependencies
lumoswiz Feb 5, 2025
425f6bc
feat: implement AgentTradingModule with initial order validation
lumoswiz Feb 5, 2025
a16f80d
chore: install all contract dependencies
lumoswiz Feb 6, 2025
7b46444
chore: add cowprotocol dependency and update solidity version
lumoswiz Feb 6, 2025
6895da1
refactor: remove dependencies from ape-config.yaml
lumoswiz Feb 6, 2025
2d6f34d
chore: foundry init
lumoswiz Feb 6, 2025
516f401
chore: add solhint config
lumoswiz Feb 6, 2025
37649e2
chore: add foundry.toml template setup
lumoswiz Feb 6, 2025
81c8bc1
chore: add depdendencies and helper bun scripts
lumoswiz Feb 6, 2025
84d0742
chore: add remappings
lumoswiz Feb 6, 2025
7ff0c7c
chore: remove forge init template files
lumoswiz Feb 6, 2025
36af254
refactor: remove smart contracts + tests from cow-trade/
lumoswiz Feb 6, 2025
fb03bcd
chore: add solady depedency and update remappings
lumoswiz Feb 6, 2025
f5c210c
chore: simplify .gitignore and include Foundry artifacts
lumoswiz Feb 6, 2025
4a7f1f9
feat: add TokenAllowlist to Foundry project
lumoswiz Feb 6, 2025
55d24eb
feat: add interface for token allowlist
lumoswiz Feb 6, 2025
6c572bc
chore: update dependencies and remappings
lumoswiz Feb 6, 2025
5edbd30
feat: add trading module
lumoswiz Feb 6, 2025
f069aed
feat: add guardable to trading module
lumoswiz Feb 6, 2025
76387c6
feat: add guard to exec function
lumoswiz Feb 6, 2025
024b33b
feat: initial CoWSwapGuard impl
lumoswiz Feb 6, 2025
0c91393
chore: add foundry artifacts to prettier ignore
lumoswiz Feb 7, 2025
6bcaa87
chore: ignore custom errors, reason strings and no empty code blocks
lumoswiz Feb 7, 2025
e9d6aed
chore: add ankr rpcs
lumoswiz Feb 7, 2025
793f224
chore: remove template readme content
lumoswiz Feb 7, 2025
72449c1
refactor: restructure GitHub Actions for monorepo
lumoswiz Feb 7, 2025
32fa131
test: add initial test suite for TokenAllowlist
lumoswiz Feb 7, 2025
23b051f
fix: package.json linting
lumoswiz Feb 7, 2025
5e2c38d
docs: add natspect
lumoswiz Feb 7, 2025
a8000ca
refactor: separate concerns between TradingModule and CoWSwapGuard
lumoswiz Feb 7, 2025
55d1faa
fix: pass transaction data to the target
lumoswiz Feb 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 50 additions & 77 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,6 @@ on:
- 'main'

jobs:
lint:
name: 'Smart Contract Infra Lint'
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./smart-contract-infra
steps:
- name: 'Checkout the repo'
uses: actions/checkout@v4

- name: 'Install Bun'
uses: oven-sh/setup-bun@v1

- name: 'Install the node.js dependencies'
run: bun install

- name: 'Lint the code'
run: bun run lint

- name: 'Add lint summary'
run: |
echo "## Lint result" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY

trader-lint:
name: 'CoW Trader Lint'
runs-on: 'ubuntu-latest'
Expand Down Expand Up @@ -63,85 +39,82 @@ jobs:
echo "## Lint result" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY

trader-build:
name: 'CoW Trader Build'
contracts-lint:
name: 'Smart Contract Lint'
runs-on: 'ubuntu-latest'
defaults:
run:
working-directory: './cow-trader'
working-directory: './smart-contract-infra'
steps:
- name: 'Checkout the repo'
- name: 'Check out the repo'
uses: 'actions/checkout@v4'

- name: 'Install UV'
uses: 'astral-sh/setup-uv@v5'
with:
version: '0.5.26'
- name: 'Install Foundry'
uses: 'foundry-rs/foundry-toolchain@v1'

- name: 'Setup Python'
uses: 'actions/setup-python@v5'
with:
python-version-file: './cow-trader/pyproject.toml'
- name: 'Install Bun'
uses: 'oven-sh/setup-bun@v1'

- name: 'Install dependencies'
run: 'uv sync --all-extras --dev'
- name: 'Install the Node.js dependencies'
run: 'bun install'

- name: 'Install Ape'
uses: 'ApeWorX/github-action@v3'
with:
python-version: '3.11'
ape-version-pin: '0.8.25'
ape-plugins-list: 'solidity==0.8.5 alchemy==0.8.7 etherscan==0.8.4 foundry==0.8.7'
- name: 'Lint the code'
run: 'bun run lint'

- name: 'Install contract dependencies'
run: 'ape pm install gh:Vectorized/solady --name solady --ref v0.1.3'
- name: 'Add lint summary'
run: |
echo "## Lint result" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY

- name: 'Compile contracts'
run: 'ape compile --force'
contracts-build:
name: 'Smart Contract Build'
runs-on: 'ubuntu-latest'
defaults:
run:
working-directory: './smart-contract-infra'
steps:
- name: 'Check out the repo'
uses: 'actions/checkout@v4'

- name: 'Install Foundry'
uses: 'foundry-rs/foundry-toolchain@v1'

- name: 'Install Bun'
uses: 'oven-sh/setup-bun@v1'

- name: 'Install the Node.js dependencies'
run: 'bun install'

- name: 'Build the contracts and print their size'
run: 'forge build --sizes'

- name: 'Add build summary'
run: |
echo "## Build result" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY

trader-test:
name: 'CoW Trader Test'
needs: ['trader-lint', 'trader-build']
contracts-test:
name: 'Smart Contract Test'
needs: ['contracts-lint', 'contracts-build']
runs-on: 'ubuntu-latest'
env:
UV_SYSTEM_PYTHON: 1
defaults:
run:
working-directory: './cow-trader'
working-directory: './smart-contract-infra'
steps:
- name: 'Checkout the repo'
- name: 'Check out the repo'
uses: 'actions/checkout@v4'

- name: 'Install UV'
uses: 'astral-sh/setup-uv@v5'
with:
version: '0.5.26'
- name: 'Install Foundry'
uses: 'foundry-rs/foundry-toolchain@v1'

- name: 'Setup Python'
uses: 'actions/setup-python@v5'
with:
python-version-file: './cow-trader/pyproject.toml'

- name: 'Install dependencies'
run: 'uv sync --all-extras --dev'

- name: 'Install Ape'
uses: 'ApeWorX/github-action@v3'
with:
python-version: '3.11'
ape-version-pin: '0.8.25'
ape-plugins-list: 'solidity==0.8.5 alchemy==0.8.7 etherscan==0.8.4 foundry==0.8.7'
- name: 'Install Bun'
uses: 'oven-sh/setup-bun@v1'

- name: 'Install contract dependencies'
run: 'ape pm install gh:Vectorized/solady --name solady --ref v0.1.3'
- name: 'Install the Node.js dependencies'
run: 'bun install'

- name: 'Run tests'
run: 'ape test -s'
- name: 'Run the tests'
run: 'forge test'

- name: 'Add test summary'
run: |
Expand Down
70 changes: 33 additions & 37 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,48 +1,44 @@
# Silverback
__pycache__/
*.py[oc]
# Directories
.build/
.cache
.db/
.idea/
.npm
.nyc_output/
.pytest_cache/
.silverback*
.venv
.vscode/
.yarn/
abi/
build/
cache/
coverage/
dist/
node_modules/
out/
wheels/
*.egg-info
.venv
.pytest_cache/
.build/
.silverback*
.ruff*

# Bun
node_modules/
dist/
# Files
*.egg-info
*.env
*.lcov
*.log
*.py[oc]
*.tsbuildinfo
coverage/
.npm
.DS_Store
.eslintcache
.yarn/
.pnp.*
.cache

# Logs
logs/
*.log
.ruff*
lcov.info
npm-debug.log*
package-lock.json
pnpm-lock.yaml
yarn-debug.log*
yarn-error.log*
yarn.lock

# Environment
.env
.env.*

# IDE/OS
.vscode/
.idea/
.DS_Store

# Project specific
.db/
abi/

# Test coverage
coverage/
.nyc_output/
*.lcov
# Broadcasts
!broadcast
broadcast/*
broadcast/*/31337/
8 changes: 0 additions & 8 deletions cow-trader/ape-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,3 @@ plugins:
version: 0.8.7
- name: solidity
version: 0.8.5

solidity:
version: 0.8.25

dependencies:
- name: Solady
github: Vectorized/solady
ref: v0.1.3
105 changes: 0 additions & 105 deletions cow-trader/tests/test_allowlist.py

This file was deleted.

12 changes: 9 additions & 3 deletions smart-contract-infra/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
node_modules
# directories
broadcast
cache
coverage
node_modules
out

# files
*.env
*.log
.DS_Store
.pnp.*
bun.lockb
lcov.info
package-lock.json
yarn.lock
cow-trader/
pnpm-lock.yaml
yarn.lock
Loading