Lesson-13 About aave.Borrow.js
#2704
-
Hi! Could anyone help me understand how mathematics is done here? I can understand how it is written but not able to grasp how it is getting calculated?
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 15 replies
-
We got the DAI price and here |
Beta Was this translation helpful? Give feedback.
-
Firstly, .toString() converts to the data-type string. Similarly, .toNumber() converts to the data-type number (int). For example: "1" vs 1 As for the mathematics involved, it is first important to know that we are calculating for the amount of $DAI we can borrow from the $ETH we have deposited. Formalization:
Evaluation: Refer to Ali's answer (esp. the example), his explanation is elaborate and should be sufficient. |
Beta Was this translation helpful? Give feedback.
@TimeKeyRoll
We got the DAI price and here
(1 / daiPrice.toNumber())
diving it with 1, so we can know the value of 1 DAI and after it, we simply multiply it withavailableBorrowsETH
that in result gave us the total DAI token we can buy of worthavailableBorrowsETH