LESSON 13: const amountDaiToBorrow = availableBorrowsETH.toString() * 0.95 * (1 / daiPrice.toNumber()) #1295
-
|
Can anyone explain how we calculate the src code: https://github.com/PatrickAlphaC/hardhat-defi-fcc/blob/main/scripts/aaveBorrow.js |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
Link does not work -- leads to a 406 error. Could you paste the relevant code here? Cheers |
Beta Was this translation helpful? Give feedback.
-
availableBorrowsETH.toString()This is an available borrow amount in ETH that we can borrow. availableBorrowsETH.toString() * 0.95here we are multiplying with 95% so we can only borrow 95 of the amount, if we do 100% the (1 / daiPrice.toNumber())Here we are dividing diaPrice by 1 to convert it to 1 DAI token. And the whole line says, get the borrow amount and dia price to convert it to total DAI that we can borrow. Hope it clears your query. |
Beta Was this translation helpful? Give feedback.
@buikhacnam
This is an available borrow amount in ETH that we can borrow.
here we are multiplying with 95% so we can only borrow 95 of the amount, if we do 100% the
health factorof aave will hit and liquidate us.Here we are dividing diaPrice by 1 to convert it to 1 DAI token.
And the whole line says, get the borrow amount and dia price to convert it to total DAI that we can borrow.
Hope it clears your query.