Skip to content

Lesson 13 - Wrong DAI price wih the Data Feed #2326

Discussion options

You must be logged in to vote

@SebasAran16 This is the DAI/ETH price without conversion. The starting 4 digits tells the exact price, and after that it includes the additional digits. After getting it, we convert it to only DAI and WEI amount.

// * convert to dai amount user can borrow.
  const amountDaiToBorrow =
    availableBorrowsETH.toString() * 0.95 * (1 / daiPrice.toNumber());
  console.log(`You can borrow ${amountDaiToBorrow.toString()} DAI`);

  // * convert to wei
  const amountToDaiBorrowWie = ethers.utils.parseEther(
    amountDaiToBorrow.toString()
  );

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@SebasAran16
Comment options

@alymurtazamemon
Comment options

@alymurtazamemon
Comment options

@SebasAran16
Comment options

Answer selected by alymurtazamemon
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants