$ git clone https://github.com/juliancabmar/hardhat-defi
$ yarn
or
$ npm i
$ yarn hardhat run scripts/aaveBorrow.js
or
$ npx hardhat run scripts/aaveBorrow.js
- Getting WETH from ETH
- Get the Pool address
- Approve Pool to pull my WETHs
- Make the Pool PULL my WETHs into it.
- Get user data: total deposited, total lended, total available to borrow
- Get DAI price
- Calculate how many DAI I can borrow based on the total available to borrow USD using the DAI price
- Convert the amount to borrow to WEI units
- Borrow the DAIs
- Refresh and show the new user AAVE balances
- Approve Pool to pull my DAIs back
- Repay the debt
- Refresh and show the new user AAVE balances