This is a project for interacting programmatically with Aave on a Forked Mainnet and using Chainlink Price Feeds from Patrick Alpha's Free Code Camp course.
The workshop followed to complete this repo is this one.
The repo that we are going to implement is like this one.
Some scripts are created in this project to interact programmatically with Aave on a Forked Mainnet with the help of Chainlink Price Feeds.
Objetives:
- Deposit collateral: ETH/WETH ✅.
- Borrow another asset: DAI ✅.
- Repay the borrowed DAI back ✅.
- Fork Mainnet to test the scripts ✅.
- Install yarn and start hardhat project:
yarn
yarn add --dev hardhat
yarn hardhat
- Install other hardhat dependencies:
yarn add --dev @nomiclabs/hardhat-waffle@^2.0.0 ethereum-waffle@^3.0.0 chai@^4.2.0 @nomiclabs/hardhat-ethers@^2.0.0 ethers@^5.0.0 @nomiclabs/hardhat-etherscan@^3.0.0 dotenv@^16.0.0 eslint@^7.29.0 eslint-config-prettier@^8.3.0 eslint-config-standard@^16.0.3 eslint-plugin-import@^2.23.4 eslint-plugin-node@^11.1.0 eslint-plugin-prettier@^3.4.0 eslint-plugin-promise@^5.1.0 hardhat-gas-reporter@^1.0.4 prettier@^2.3.2 prettier-plugin-solidity@^1.0.0-beta.13 solhint@^3.3.6 solidity-coverage@^0.7.16
- Install ethers dependencies:
yarn add --dev @nomiclabs/hardhat-ethers@npm:hardhat-deploy-ethers ethers
- Include the following like inside hardhat.config.js:
require("hardhat-deploy");
- Install Aave dependencies
yarn add --dev @aave/protocol-v2
- Inside ILendingPool.sol insert:
import {ILendingPoolAddressesProvider} from "@aave/protocol-v2/contracts/interfaces/ILendingPoolAddressesProvider.sol";
import {DataTypes} from "@aave/protocol-v2/contracts/protocol/libraries/types/DataTypes.sol";
- Inside hardhat.config.js:
hardhat: {
chainId: 31337,
forking: {
url: MAINNET_RPC_URL,
},
},
- Execute scripts on forked chain:
yarn hardhat run scripts/aaveBorrow.js
- If you want to execute solhint to search for potential Solidity errors Execute:
yarn solhint contracts/*.sol
-
If you want to use a text formarter: Check .prettierrc and .prettierignore.
-
To automatically verify our contract on etherscan:
yarn add --dev @nomiclabs/hardhat-etherscan
Then, include inside hardhat.config.js:
require("@nomiclabs/hardhat-etherscan");
Add ETHERSCAN_API_KEY
inside .env
file.
- Use Hardhat Gas Reporter:
yarn add --dev hardhat-gas-reporter
Then, include inside hardhat.config.js:
require("hardhat-gas-reporter");
- Use Solidity Coverage:
yarn add --dev solidity-coverage
Then, include inside hardhat.config.js:
require("solidity-coverage");
In order to execute it:
yarn hardhat coverage
- Use Hardhat Waffle:
yarn add @nomiclabs/hardhat-waffle
Then, include inside hardhat.config.js:
require("@nomiclabs/hardhat-waffle");
- wETH Rinkeby: Rinkeby wETH Smart Contract.
- wETH Mainnet: Mainnet wETH Smart Contract.
- Aave
- Aave docs
- Aave developers docs v2
- Aave Lending Pool: protocol that we are going to interact with.
- Aave protocols contract addresses