Skip to content

JMariadlcs/aave-defi

Repository files navigation

AAVE - DEFI 👻

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.

PROJECT

Some scripts are created in this project to interact programmatically with Aave on a Forked Mainnet with the help of Chainlink Price Feeds.

Objetives:

  1. Deposit collateral: ETH/WETH ✅.
  2. Borrow another asset: DAI ✅.
  3. Repay the borrowed DAI back ✅.
  4. Fork Mainnet to test the scripts ✅.

CREATE SIMILAR PROJECT FROM SCRATCH

  • 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
require("hardhat-deploy");
  • Install Aave dependencies
yarn add --dev @aave/protocol-v2
import {ILendingPoolAddressesProvider} from "@aave/protocol-v2/contracts/interfaces/ILendingPoolAddressesProvider.sol";
import {DataTypes} from "@aave/protocol-v2/contracts/protocol/libraries/types/DataTypes.sol";

HOW TO FORK MAINNET

hardhat: {
          chainId: 31337,
          forking: {
              url: MAINNET_RPC_URL,
          },
      },
  • Execute scripts on forked chain:
yarn hardhat run scripts/aaveBorrow.js

REMINDERS

  • If you want to execute solhint to search for potential Solidity errors Execute:
yarn solhint contracts/*.sol
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");

Resources

About

Project for interacting programmatically with Aave (deposit collateral, borrow assets, repay borrowed assets) from Patrick Alpha's ffc.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published