Borrow
We need to find out how much we can borrow against our deposits/collateral.
getUserAccountData()
function getUserAccountData(address user)
values are returned in WEI, we will convert to ETH
return multiple variables using tuple syntax.
float allows for decimal places.
Into main()
add the following code
DAI
We now know much we can borrow in terms of ETH, {available_borrow_ETH}, from above.
How much is that in terms of DAI?
We will need to get DAI/ETH price and convert -> via chainlink pricefeed contract
Price of DAI/ETH
Chainlink has a standard interface contract AggregatorV3Interface which works with all of its different price feed contracts.
With this interface, we simply need to pass the corresponding price feed address into it, to create the contract object in brownie.
create price feed contract object
calls latestRoundData from price feed contract, slicing out price variable from return tuple
convert price from Wei to Ether (decimal place modification)
Into main()
Lending_pool.borrow
call borrow() from lendingPool contract
We will need to add the DAI token address into brownie-config.yaml
mainnet-fork: get DAI address off etherscan
Kovan/Rinkeby: refer to Aave documentation to get their testnet version of DAI
For assets on testnets, we use different versions of the token (e.g. testnet Dai). This is to ensure enough liquidity for our reserves and to easily mint more tokens when needed.
If you are developing on a testnet and require tokens, go to https://testnet.aave.com/faucet, making sure that your wallet is set to the relevant testnet.
Testnet assets addresses are different depending on stable vs variable rate of borrowing
Last updated