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 fladepver [gas-in-gwei] [ContractName1 ContractNam2 ... ContractNameN] [nonce (optional)] --network [hardhat-settings-network-name] - will flatten to a single file (save it in contracts/flattened), deploy from it and then verify it on etherscan
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