All the contracts related to the Defi Saver ecosystem.
Detailed overview about that code can be found https://docs.defisaver.com
Run npm install
or yarn
in the repo folder.
You will also need to create a .env file as in the .env.example and fill it in with appropriate api keys.
All of the tests are ran from the forked state of the mainnet. In the hardhat config you can change the block number the fork starts from. If it starts from an old state some tests might not work.
- Compile all contracts at start:
npx hardhat compile
- You need to start a hardhat node from the forked mainnet with the following command:
npx hardhat node --max-memory 8192 --fork ETHEREUM_NODE_URL
- After that you can run the tests, for example:
npm run test local ./mcd/mcd-supply.js
npm run test local ./run-core-tests.js
Before running tests from the latest fork block it's necessary to update the prices used in integrations tests.
node scripts/utils/price-tracker.js
-
In the .env file add the tenderly fork id where you want to deploy
-
In the
scripts/deploy-on-fork.js
add contracts you want to deploy using theredeploy()
function and make sure to specifyreg.address
as second parameter. -
To deploy on fork run the following command:
npm run deploy fork deploy-on-fork
npm run compile
- will compile all the contracts
npm run deploy [network] [deploy-script]
- will deploy to the specified network by calling the script from the /scripts
folder
npm run test [network] [test-file]
- will run a test to the specified network by calling the script from the /test
folder
npm run verify [network] [contract-name]
- will verify contract based on address and arguments from /deployments
folder
npx hardhat changeRepoNetwork [current-network-name] [new-network-name]
- will change which contract the helper contracts import and extend
npx 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 [contract-name] [gas-in-gwei] [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.