Code Monkey home page Code Monkey logo

defisaver-v3-contracts's Introduction

defisaver-v3-contracts

All the contracts related to the Defi Saver ecosystem.

Detailed overview about the code can be found at https://docs.defisaver.com

To install

Run 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. For a quick start, you can copy .env.example with default values and rename it to .env.

Link @defisaver/sdk package

  1. Clone sdk repo (https://github.com/defisaver/defisaver-sdk)
  2. Checkout to refactor/v3.1 branch
  3. Run yarn
  4. Run yarn build
  5. Run yarn link
  6. Go back to defisaver-v3-contracts repo and run yarn link @defisaver/sdk

How to run tests

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.

Before running tests compile all contracts at start: npx hardhat compile

Run tests with default hardhat network

In hardhat.config.js hardhat network will fork mainnet by default. For example, you can run tests as:

npx hardhat test ./test/aaveV3/full-test.js --network hardhat

Run tests with separate hardhat node running

First 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 ./aaveV3/full-test.js

Running strategy core tests

npx hardhat test ./test/run-core-tests.js --network hardhat

Running foundry tests

In test-sol folder you can find foundry setup.

Before running tests make sure you have foundry installed (check it with forge --version)

To run tests execute:

forge test --fork-url <INSERT_MAINNET_FORK>

Notice: Currently, foundry tests are used just as an example. Although, we plan to add them more in the future, all protocols and core tests should be run in hardhat environment

How to deploy on a tenderly fork

  1. In the .env file add the tenderly fork id where you want to deploy

  2. In the scripts/deploy-on-fork.js add contracts you want to deploy using the redeploy() function and make sure to specify reg.address as second parameter.

  3. To deploy on fork run the following command: npm run deploy fork deploy-on-fork

Common commands

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

Custom hardhat tasks

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.

defisaver-v3-contracts's People

Contributors

yippee-ki-yay avatar majkic99 avatar kjaredic avatar rajko-z avatar nklipa13 avatar pavleprica avatar hajdukdusan avatar matijapojatar avatar mihailot01 avatar mihajlo426 avatar mijovic avatar sterlu avatar nsreckovic avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.