mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
19 lines
562 B
TypeScript
19 lines
562 B
TypeScript
import BigNumber from 'bignumber.js';
|
|
|
|
import type { Block } from 'types/api/block';
|
|
|
|
export default function getBlockReward(block: Block) {
|
|
const txFees = BigNumber(block.tx_fees || 0);
|
|
const burntFees = BigNumber(block.burnt_fees || 0);
|
|
const minerReward = block.rewards?.find(({ type }) => type === 'Miner Reward' || type === 'Validator Reward')?.reward;
|
|
const totalReward = BigNumber(minerReward || 0);
|
|
const staticReward = totalReward.minus(txFees).plus(burntFees);
|
|
|
|
return {
|
|
totalReward,
|
|
staticReward,
|
|
txFees,
|
|
burntFees,
|
|
};
|
|
}
|