From bbe3ec7c0bc560780011353d60e12aa269062cdc Mon Sep 17 00:00:00 2001 From: Ali Raza <87068339+aliraza556@users.noreply.github.com> Date: Sat, 31 Aug 2024 13:18:42 +0500 Subject: [PATCH] Portfolio value change calculation is broken when using Mina values (#204) * Portfolio value change calculation * format code --- .all-contributorsrc | 32 +++++-------------- .../features/src/wallet/routes/overview.tsx | 10 +++--- 2 files changed, 14 insertions(+), 28 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 7bd92485..9da03c20 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1,7 +1,5 @@ { - "files": [ - "README.md" - ], + "files": ["README.md"], "imageSize": 100, "commit": false, "commitType": "docs", @@ -12,63 +10,49 @@ "name": "Tomek Marciniak", "avatar_url": "https://avatars.githubusercontent.com/u/16132011?v=4", "profile": "https://github.com/mrcnk", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "teddyjfpender", "name": "Teddy Pender", "avatar_url": "https://avatars.githubusercontent.com/u/92999717?v=4", "profile": "https://github.com/teddyjfpender", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "rago4", "name": "Rafał Goławski", "avatar_url": "https://avatars.githubusercontent.com/u/19167236?v=4", "profile": "https://dev.to/rgolawski", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "mich3lang3lo", "name": "Mariusz", "avatar_url": "https://avatars.githubusercontent.com/u/164676295?v=4", "profile": "https://github.com/mich3lang3lo", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "aliraza556", "name": "Ali Raza", "avatar_url": "https://avatars.githubusercontent.com/u/87068339?v=4", "profile": "https://github.com/aliraza556", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "yaodingyd", "name": "Yao Ding", "avatar_url": "https://avatars.githubusercontent.com/u/11392695?v=4", "profile": "https://yaodingyd.github.io/", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "Myestery", "name": "Chiwetelu Johnpaul Chidera", "avatar_url": "https://avatars.githubusercontent.com/u/49923152?v=4", "profile": "https://www.myestery.com", - "contributions": [ - "code" - ] + "contributions": ["code"] } ], "contributorsPerLine": 7, diff --git a/packages/features/src/wallet/routes/overview.tsx b/packages/features/src/wallet/routes/overview.tsx index 65ba5733..5df3530b 100644 --- a/packages/features/src/wallet/routes/overview.tsx +++ b/packages/features/src/wallet/routes/overview.tsx @@ -36,13 +36,15 @@ 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")