All the contracts related to the Defi Saver ecosystem.
A detailed overview of the code can be found at Defi Saver Docs.
Run yarn in the repository folder.
You will also need to create a .env file based on .env.example and fill it in with the appropriate API keys.
For a quick start, you can copy .env.example (which contains default values) and rename it to .env.
- Ensure you have Foundry installed (check with
forge --version). - Set the
ETHEREUM_NODEvariable in the.envfile with a mainnet RPC URL. - Install dependencies:
forge install foundry-rs/forge-std dapphub/ds-test
- Run tests:
forge test
All tests are run from a forked state of mainnet.
You can specify the block number in test-sol/config/config.json.
To run only core tests:
forge test --mc TestCoreTo run coverage on core:
bash run-core-coverage.shBefore running tests, compile all contracts:
npx hardhat compileIn hardhat.config.js hardhat network will fork mainnet by default.
You can change the block number from which the fork starts in the Hardhat config; note that if it starts from an old state, some tests might not work.
Running core tests:
npx hardhat test ./test/run-core-tests.jsExample of running tests with a specified network:
npx hardhat test ./test/aaveV3/full-test.js --network hardhatnpx hardhat customFlatten [contract-name] - will flatten contract that is ready for deployment and put it in contracts/flattened folder
npx hardhat customVerify [contract-address] [contract-name] --network [hardhat-settings-network-name] - will verify on etherscan if a contract was deployed using a single file from customFlatten task
npx hardhat encryptPrivateKey - will encrypt the key with the secretWord. Put the output in .env as ENCRYPTED_KEY. Later on during deployment process it will ask you for secret word to decrypt the key for deployment use.
npx hardhat deployOnFork [Contract1] [Contract2] [ContractN] - deploys the specified contracts on a Tenderly fork. Before running this command, add the Tenderly fork ID to the .env file where you want to deploy.
node ./cmd/change-repo-network [current-network-name] [new-network-name] - will change which contract the helper contracts import and extend
Flatten, deploy and verify on one network. Gas is in gwei; add --nonce 123 to set the starting nonce.
npx hardhat fladepver 3 Contract1 Contract2 --network mainnetBuild, deploy and verify across networks without switching the repo. Gas caps are in gwei; only zero-argument constructors are supported.
One contract, one network:
node ./cmd/deploy-multi.js Contract1 --networks mainnet --gas 3Multiple contracts, one network:
node ./cmd/deploy-multi.js Contract1 Contract2 --networks base --gas 0.01One contract, multiple networks — explicit gas caps or a shared cap with an override:
node ./cmd/deploy-multi.js Contract1 \
--networks mainnet,arbitrum,base --gas mainnet=3,arbitrum=0.02,base=0.01
node ./cmd/deploy-multi.js Contract1 \
--networks mainnet,arbitrum,base --gas all=1.1,mainnet=3Different contract groups per network, with gas overrides:
node ./cmd/deploy-multi.js \
Contract1,Contract2,Contract3@mainnet,arbitrum,base \
Contract4,Contract5@optimism \
Contract6@base,optimism \
--gas all=1.1,mainnet=3,base=0.01Contract1 on all networks, Contract2 only on Optimism:
node ./cmd/deploy-multi.js Contract1 Contract2@optimism \
--networks all --gas all=1.1,mainnet=3--networks applies only to names without @. Groups also support @all; overlapping groups deploy each contract once per network. --gas 1.1 is shorthand for --gas all=1.1.
Build only, then set MANIFEST to the path printed on the Manifest: line. Use the same path to resume an interrupted run.
node ./cmd/deploy-multi.js Contract1 --networks mainnet,base --build-only
MANIFEST="path/to/your/manifest.json"
node ./cmd/deploy-multi.js --resume "$MANIFEST" --gas all=1.1,mainnet=3For every command and deployment mode, see the deploy-multi handbook.