Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refined slider value to keep min 2 decimal and max 4 demical digits #2650

Merged
merged 1 commit into from Mar 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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