Files
explore/lib/block/getBlockTotalReward.ts
T
2022-12-21 11:29:44 +03:00

14 lines
366 B
TypeScript

import BigNumber from 'bignumber.js';
import type { Block } from 'types/api/block';
import { WEI, ZERO } from 'lib/consts';
export default function getBlockTotalReward(block: Block) {
const totalReward = block.rewards
?.map(({ reward }) => BigNumber(reward))
.reduce((result, item) => result.plus(item), ZERO) || ZERO;
return totalReward.div(WEI);
}