From ba8f24e3a20090861282ba0d23378a4fdaa6cfd9 Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Tue, 14 Mar 2023 14:47:24 +0500 Subject: [PATCH] refined slider value to keep min 2 decimal and max 4 demical digits --- src/utils/vote.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/utils/vote.ts b/src/utils/vote.ts index 6f1455991d..077374c9ea 100644 --- a/src/utils/vote.ts +++ b/src/utils/vote.ts @@ -15,9 +15,19 @@ export const getEstimatedAmount = (account, globalProps: GlobalProps, sliderValu const hbdMedian = base / quote; const voteEffectiveShares = calculateVoteRshares(totalVests, _votingPower, weight); const voteValue = (voteEffectiveShares / fundRecentClaims) * fundRewardBalance * hbdMedian; - const estimatedAmount = weight < 0 ? Math.min(voteValue * -1, 0) : Math.max(voteValue, 0); + const estimatedAmount = (weight < 0 ? Math.min(voteValue * -1, 0) : Math.max(voteValue, 0)) * 200; + + if (isNaN(estimatedAmount)) { + return '0.00'; + } + else if (estimatedAmount >= 1) { + return estimatedAmount.toFixed(2) + } else { + const _fixed = parseFloat(estimatedAmount.toFixed(4)); + const _precision = _fixed < 0.001 ? 1 : 2 + return _fixed.toPrecision(_precision); + } - return Number.isNaN(estimatedAmount) ? '0.00000' : estimatedAmount.toFixed(5); }; /*