Skip to content

Commit

Permalink
Merge pull request #2650 from ecency/nt/vote-slider
Browse files Browse the repository at this point in the history
refined slider value to keep min 2 decimal and max 4 demical digits
  • Loading branch information
feruzm committed Mar 14, 2023
2 parents 2eab416 + ba8f24e commit a4aef99
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/utils/vote.ts
Expand Up @@ -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);
};

/*
Expand Down

0 comments on commit a4aef99

Please sign in to comment.