Skip to content

Commit

Permalink
feat: integrate with Euler V2 vaults
Browse files Browse the repository at this point in the history
* chore: import Euler v2 interfaces
* wip: compiles
* wip: getting tests to work
* wip: first tests passing
* wip: getting more tests to work
* test: fix `testGetBalance_AddingAfterProfit`
* test: fix `testGetBalance`
* test: fix `testSwap_ReturnAsset*`
* test: fix `testShares*`
* test: fix some
* test: rm unused tests
* fix: use `IERC4626` instead of the euler specific one
* feat: introduce tracking for totalShares
* feat: introduce tracking for totalShares
* test: add back `totalShares` assertions
* test: more tests
* test: use mainnet rpc url
* feat: additional rewards
* fix: arithmetic
* docs: clean up references to AAVE
* docs: clean up
* fix: optimize sloads
* docs: clarify
* fix: incorrect arithmetic
* fix: simplify invest and divest logic
* test: enhance assertion
* test: claim rewards
* lint: forge fmt
* lint: forge fmt for comments
* lib: upgrade forge-std
* lint: address lint concerns
* docs: improve docs on tests
* ci: upgrade codecov gh action to v5
* ci: introduce coverage-integration step
* ci: set fuzz seed and pin block for fork test
* ci: change rpc server
* ci: rm redundant build step
* test: enhance test to cover missed line
* ci: introduce dependency to reduce resource wastage
* test: add case to show resilience
* fix: rm unused constructor
  • Loading branch information
xenide authored Nov 28, 2024
1 parent dcdfda6 commit e51e8e5
Show file tree
Hide file tree
Showing 18 changed files with 530 additions and 650 deletions.
55 changes: 33 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,11 @@ concurrency:
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- run: forge build

lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-node@v3
Expand All @@ -36,7 +24,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: foundry-rs/foundry-toolchain@v1
Expand All @@ -47,7 +35,7 @@ jobs:
test-integration:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: foundry-rs/foundry-toolchain@v1
Expand All @@ -58,7 +46,7 @@ jobs:
test-e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: foundry-rs/foundry-toolchain@v1
Expand All @@ -70,7 +58,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: foundry-rs/foundry-toolchain@v1
Expand All @@ -88,7 +76,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: foundry-rs/foundry-toolchain@v1
Expand All @@ -103,7 +91,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: foundry-rs/foundry-toolchain@v1
Expand All @@ -115,9 +103,9 @@ jobs:

coverage:
runs-on: ubuntu-latest

needs: test-unit
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: foundry-rs/foundry-toolchain@v1
Expand All @@ -128,10 +116,33 @@ jobs:
FOUNDRY_PROFILE: coverage
- run: sudo apt install -y lcov
- run: lcov -r lcov.info "src/libraries/*" -o lcov.info
- run: lcov -r lcov.info "src/asset-management/*" -o lcov.info
- run: lcov -r lcov.info "test/*" -o lcov.info
- run: |
! lcov --summary lcov.info | grep -q 0.0%
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
files: ./lcov.info

coverage-integration:
runs-on: ubuntu-latest
needs: [test-unit, test-integration]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- run: ./script/coverage_patch_deployer.sh && forge coverage --report lcov
env:
FOUNDRY_PROFILE: coverage-integration
- run: sudo apt install -y lcov
- run: lcov -r lcov.info "test/*" -o lcov.info
- run: |
! lcov --summary lcov.info | grep -q 0.0%
- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
files: ./lcov.info
12 changes: 11 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[profile.default]
solc = "0.8.23"
evm_version = "cancun"
#via_ir = true
bytecode_hash = "ipfs"
optimizer_runs = 1_000_000
Expand All @@ -17,9 +18,15 @@ fs_permissions = [
]
ignored_error_codes = []

[profile.default.fuzz]
seed = "0xd679d565cc78d6c78308f18282cb070e065bf4c517fbd552922d47f2127a2bbc"

[profile.integration]
match_path = "test/integration/*.sol"

[profile.coverage-integration]
match_path = "test/integration/*.sol"

[profile.differential]
fs_permissions = [{ access = "read", path = "./reference/balancer-v2-monorepo" }]
match_path = "test/differential/*.sol"
Expand All @@ -32,9 +39,12 @@ runs = 10_000

[fmt]
bracket_spacing = true
wrap_comments = false
wrap_comments = true
number_underscore = "thousands"
int_types = "long"

[profile.script]
optimizer_runs = 1_000_000

[rpc_endpoints]
mainnet = "https://rpc.ankr.com/eth"
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"ci": "forge build --force && npm run lint:check && npm run test:unit && npm run gas:check && npm run slither:check",
"clean": "forge clean",
"coverage": "export FOUNDRY_PROFILE=coverage && script/coverage_patch_deployer.sh && forge coverage --report lcov",
"coverage:integration": "export FOUNDRY_PROFILE=coverage-integration && script/coverage_patch_deployer.sh && forge coverage --report lcov",
"deploy:avax:test": "forge script script/DeployScript.s.sol --target-contract DeployScript --fork-url \"http://127.0.0.1:8545\" --broadcast -vvvv --verify --ledger --mnemonic-derivation-paths \"m/44'/60'/0'/0/1\" --sender 0x2508b97B8041960ccA8AaBC7662F07EC8e285F6d",
"deploy:avax": "forge script script/DeployScript.s.sol --target-contract DeployScript --fork-url https://api.avax.network/ext/bc/C/rpc --broadcast -vvvv --verify --ledger --mnemonic-derivation-paths \"m/44'/60'/0'/0/1\" --sender 0x2508b97B8041960ccA8AaBC7662F07EC8e285F6d",
"eslint": "npm run eslint:check",
Expand Down
2 changes: 1 addition & 1 deletion script/coverage_patch_deployer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ UNOPTIMIZED_ORACLE_CALLER_HASH=$(cat script/unoptimized-deployer-meta | jq -r '.
OPTIMIZED_FACTORY_HASH=$(cat script/optimized-deployer-meta | jq -r '.factory_hash')
UNOPTIMIZED_FACTORY_HASH=$(cat script/unoptimized-deployer-meta | jq -r '.factory_hash')

if [ "$FOUNDRY_PROFILE" == "coverage" ]
if [ "$FOUNDRY_PROFILE" == "coverage" ] || [ "$FOUNDRY_PROFILE" == "coverage-integration" ]
then
echo "Running with coverage profile, patching ReservoirDeployer"
sed -i "s/$OPTIMIZED_STABLE_HASH/$UNOPTIMIZED_STABLE_HASH/g" src/ReservoirDeployer.sol
Expand Down
7 changes: 3 additions & 4 deletions script/unoptimized-deployer-meta
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"constant_product_hash": "0xb563408dadf9d0f09df38020a0fa234a0df6db131574de64ce0f94f4a0a25af3",
"factory_hash": "0xc083749f159ff0edd904efd85e57d856044cb7175b6f2f836a1ea689196c6a0b",
"oracle_caller_hash": "0x1b44c52bfac16ddbab1269ebb22b21bbb993a55587f0bca4a8035433cece2f87",
"stable_hash": "0x7ee3fb2be553a6254f7197e7ba45c2a3c45862e550d0253cbc7cab694eb116f7"
"constant_product_hash": "0xa0c82283f7cf9bcd7d4091d1c25e9c424a65f3d9602243387ef21b1cbca0864e",
"factory_hash": "0x60b680774a2e6b5f3a74c7926f7945eedbd82d533768f2cc4641712d3a9747a9",
"stable_hash": "0xcca43bf4944cac2ddebe02c1fde1a1ba13cc6f9aad27f68bdc1c9ac0cbd3b5a5"
}
6 changes: 3 additions & 3 deletions src/ReservoirDeployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ contract ReservoirDeployer {
uint256 public step = 0;

// Bytecode hashes.
bytes32 public constant FACTORY_HASH = bytes32(0x419250835880ba2bbc5535e1a66eae6c96005200131467f2033d5ca0b2e333a7);
bytes32 public constant FACTORY_HASH = bytes32(0x60b680774a2e6b5f3a74c7926f7945eedbd82d533768f2cc4641712d3a9747a9);
bytes32 public constant CONSTANT_PRODUCT_HASH =
bytes32(0xe3022cd6d0397e990bc6eb954dcf917dc7779bc75cf3ccb827e3361af8e4a4da);
bytes32 public constant STABLE_HASH = bytes32(0xfd70a1442e2709a6d366103eaf2f111bb1ffeff0b29e1ee5829165b55e4be32e);
bytes32(0xa0c82283f7cf9bcd7d4091d1c25e9c424a65f3d9602243387ef21b1cbca0864e);
bytes32 public constant STABLE_HASH = bytes32(0xcca43bf4944cac2ddebe02c1fde1a1ba13cc6f9aad27f68bdc1c9ac0cbd3b5a5);

// Deployment addresses.
GenericFactory public factory;
Expand Down
Loading

0 comments on commit e51e8e5

Please sign in to comment.