Skip to content

Commit

Permalink
Fix usd calculation on redeem
Browse files Browse the repository at this point in the history
  • Loading branch information
knoll3 committed Dec 7, 2024
1 parent 75ffd01 commit 662f2ef
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/mint-teth/components/Redeem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ export function Redeem() {
const ethPriceAsBigInt = ethPrice ? BigInt(ethPrice) : BigInt(0);

// Redeem amount
const redeemtAmountInEth = (redeemAmountAsBigInt * BigInt(ethPerAssetRate)) / BigInt(1e18);
const redeemAmountInUsd = (redeemtAmountInEth * ethPriceAsBigInt) / BigInt(1e8);
const redeemAmountInEth = (redeemAmountAsBigInt * BigInt(ethPerTethRate)) / BigInt(1e18);
const redeemAmountInUsd = (redeemAmountInEth * ethPriceAsBigInt) / BigInt(1e8);
const redeemAmountInUsdFormatted = Number(formatUnits(redeemAmountInUsd, 18));
const formattedRedeemAmountInUsd =
redeemAmountInUsdFormatted > 0 && redeemAmountInUsdFormatted < 0.01
Expand All @@ -144,7 +144,9 @@ export function Redeem() {
? (redeemAmountAsBigInt * BigInt(1e18)) / atomicPriceAsBigInt
: redeemAmountAsBigInt;
const formattedReceiveAmount = formatUnits(receiveAmountAsBigInt, 18);
const receiveAmountInEth = (receiveAmountAsBigInt * BigInt(ethPerTethRate)) / BigInt(1e18);
const receiveAmountInEth = ethPerAssetRate
? (receiveAmountAsBigInt * BigInt(1e18)) / BigInt(ethPerAssetRate)
: BigInt(0);
const receiveAmountInUsd = (receiveAmountInEth * ethPriceAsBigInt) / BigInt(1e8);
const receiveAmountInUsdFormatted = Number(formatUnits(receiveAmountInUsd, 18));
const formattedReceiveAmountInUsd =
Expand Down

0 comments on commit 662f2ef

Please sign in to comment.