From 97d10740f55589d23d018e914b3f75d636e5bc02 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Sun, 8 Aug 2021 02:54:42 -0300 Subject: [PATCH] Fix rounding digits on miner reward percentage --- src/transaction/RewardSplit.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/transaction/RewardSplit.tsx b/src/transaction/RewardSplit.tsx index 7ff4a57..23c527d 100644 --- a/src/transaction/RewardSplit.tsx +++ b/src/transaction/RewardSplit.tsx @@ -10,11 +10,13 @@ type RewardSplitProps = { }; const RewardSplit: React.FC = ({ txData }) => { + const paidFees = txData.gasPrice.mul(txData.gasUsed); const burntFees = txData.blockBaseFeePerGas!.mul(txData.gasUsed); - const minerReward = txData.gasPrice.mul(txData.gasUsed).sub(burntFees); + + const minerReward = paidFees.sub(burntFees); const burntPerc = - burntFees.mul(10000).div(txData.gasPrice.mul(txData.gasUsed)).toNumber() / - 100; + Math.round(burntFees.mul(10000).div(paidFees).toNumber()) / 100; + const minerPerc = Math.round((100 - burntPerc) * 100) / 100; return (
@@ -39,7 +41,7 @@ const RewardSplit: React.FC = ({ txData }) => {