From 996c3401a3c349ef8ca8c83e970a287c17bdc5ae Mon Sep 17 00:00:00 2001 From: Noah Prince <83885631+ChewingGlass@users.noreply.github.com> Date: Fri, 19 Jan 2024 21:57:38 -0500 Subject: [PATCH] Fix jank (#108) --- components/ProposalVoteCard.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/components/ProposalVoteCard.tsx b/components/ProposalVoteCard.tsx index 1d99166..04fec13 100644 --- a/components/ProposalVoteCard.tsx +++ b/components/ProposalVoteCard.tsx @@ -62,10 +62,14 @@ export const ProposalVoteCard = ({ ...r, index, percent: totalVotes?.isZero() - ? BigInt(100) / BigInt(proposal?.choices.length) - : (BigInt(r.weight.toString()) / BigInt(totalVotes.toString())) * BigInt(100), + ? 100 / proposal?.choices.length + : // Calculate with 4 decimals of precision + r.weight.mul(new BN(10000)).div(totalVotes).toNumber() * + (100 / 10000), })) - .sort((a, b) => (a.percent < b.percent) ? -1 : ((a.percent > b.percent) ? 1 : 0)); + .sort((a, b) => + a.percent < b.percent ? -1 : a.percent > b.percent ? 1 : 0 + ); return { results, totalVotes }; }, [proposal?.choices]);