Skip to content

Commit

Permalink
Portfolio value change calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
aliraza556 committed Aug 31, 2024
1 parent 0292afd commit 9cd94c6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/features/src/wallet/routes/overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,18 @@ export const OverviewRoute = () => {
const priceYesterday =
lastMonthPrices?.[lastMonthPrices?.length - 2]?.[1] ?? 0
const dailyPriceDiff = (priceToday - priceYesterday) / priceYesterday
const dailyPriceDiffFiat = Math.abs(
Number(account.minaBalance) * dailyPriceDiff,
const dailyPriceDiffFiat = (
Number(account.minaBalance) * dailyPriceDiff
).toFixed(2)
const dailyPriceDiffMina = (
Number(dailyPriceDiffFiat) / (minaPrice ?? 1)
).toFixed(2)
const dailyPriceDiffMina = Math.abs(dailyPriceDiff).toFixed(2)
const chartLabel =
typeof currentPriceIndex === "undefined"
? `${dailyPriceDiff >= 0 ? "+" : "-"}${
? `${dailyPriceDiff >= 0 ? "+" : ""}${
useFiatBalance ? dailyPriceDiffFiat : dailyPriceDiffMina
} (24h)`
: dayjs(lastMonthPrices[currentPriceIndex]?.[0]).format("MMM d")
: dayjs(lastMonthPrices[currentPriceIndex]?.[0]).format("MMM D")
return (
<OverviewView
lastMonthPrices={lastMonthPrices}
Expand Down

0 comments on commit 9cd94c6

Please sign in to comment.