2021-07-28 21:44:50 +00:00
|
|
|
import React from "react";
|
|
|
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
2021-08-08 06:51:21 +00:00
|
|
|
import { faBurn } from "@fortawesome/free-solid-svg-icons/faBurn";
|
|
|
|
import { faCoins } from "@fortawesome/free-solid-svg-icons/faCoins";
|
2021-07-28 21:44:50 +00:00
|
|
|
import FormattedBalance from "../components/FormattedBalance";
|
|
|
|
import { TransactionData } from "../types";
|
2021-07-29 00:28:02 +00:00
|
|
|
import PercentageGauge from "../components/PercentageGauge";
|
2021-07-28 21:44:50 +00:00
|
|
|
|
|
|
|
type RewardSplitProps = {
|
|
|
|
txData: TransactionData;
|
|
|
|
};
|
|
|
|
|
|
|
|
const RewardSplit: React.FC<RewardSplitProps> = ({ txData }) => {
|
2021-09-04 06:19:42 +00:00
|
|
|
const paidFees = txData.gasPrice.mul(txData.confirmedData!.gasUsed);
|
|
|
|
const burntFees = txData.confirmedData!.blockBaseFeePerGas!.mul(
|
|
|
|
txData.confirmedData!.gasUsed
|
|
|
|
);
|
2021-08-08 05:54:42 +00:00
|
|
|
|
|
|
|
const minerReward = paidFees.sub(burntFees);
|
2021-07-28 21:44:50 +00:00
|
|
|
const burntPerc =
|
2021-08-08 05:54:42 +00:00
|
|
|
Math.round(burntFees.mul(10000).div(paidFees).toNumber()) / 100;
|
|
|
|
const minerPerc = Math.round((100 - burntPerc) * 100) / 100;
|
2021-07-28 21:44:50 +00:00
|
|
|
|
|
|
|
return (
|
2021-07-29 00:28:02 +00:00
|
|
|
<div className="inline-block">
|
|
|
|
<div className="grid grid-cols-2 gap-x-2 gap-y-1 items-center text-sm">
|
|
|
|
<PercentageGauge
|
|
|
|
perc={burntPerc}
|
2021-08-08 05:36:26 +00:00
|
|
|
bgColor="bg-orange-100"
|
|
|
|
bgColorPerc="bg-orange-500"
|
|
|
|
textColor="text-orange-800"
|
2021-07-29 00:28:02 +00:00
|
|
|
/>
|
|
|
|
<div className="flex items-baseline space-x-1">
|
|
|
|
<span className="flex space-x-1 text-orange-500">
|
|
|
|
<span title="Burnt fees">
|
|
|
|
<FontAwesomeIcon icon={faBurn} size="1x" />
|
|
|
|
</span>
|
|
|
|
<span>
|
|
|
|
<span className="line-through">
|
|
|
|
<FormattedBalance value={burntFees} />
|
|
|
|
</span>{" "}
|
|
|
|
Ether
|
|
|
|
</span>
|
2021-07-28 22:16:02 +00:00
|
|
|
</span>
|
2021-07-29 00:28:02 +00:00
|
|
|
</div>
|
|
|
|
<PercentageGauge
|
2021-08-08 05:54:42 +00:00
|
|
|
perc={minerPerc}
|
2021-08-08 05:36:26 +00:00
|
|
|
bgColor="bg-yellow-100"
|
|
|
|
bgColorPerc="bg-yellow-300"
|
|
|
|
textColor="text-yellow-700"
|
2021-07-29 00:28:02 +00:00
|
|
|
/>
|
|
|
|
<div className="flex items-baseline space-x-1">
|
|
|
|
<span className="flex space-x-1">
|
|
|
|
<span className="text-yellow-300" title="Miner fees">
|
|
|
|
<FontAwesomeIcon icon={faCoins} size="1x" />
|
|
|
|
</span>
|
|
|
|
<span>
|
|
|
|
<FormattedBalance value={minerReward} /> Ether
|
|
|
|
</span>
|
2021-07-28 22:16:02 +00:00
|
|
|
</span>
|
2021-07-29 00:28:02 +00:00
|
|
|
</div>
|
2021-07-28 22:16:02 +00:00
|
|
|
</div>
|
2021-07-28 21:44:50 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default React.memo(RewardSplit);
|