Files
orionprotocol-sdk/src/utils/calculateNetworkFee.ts
Oleg Nechiporenko c2a4084158 feat: update ethers@6
fix: bigint errors

fix: TS errors

fix: gasLimit fetch

fix: review comments

fix: contracts errors

chore: bump rc version

fix: revert wrong fix

fix: ts config

fix: ts config

fix: ts config

feat: update signer
2023-09-28 11:43:27 +02:00

14 lines
510 B
TypeScript

import { BigNumber } from 'bignumber.js';
import { ethers } from 'ethers';
import { NATIVE_CURRENCY_PRECISION } from '../constants/precisions.js';
export default function calculateNetworkFee(
gasPriceGwei: BigNumber.Value,
gasLimit: BigNumber.Value,
) {
const networkFeeGwei = new BigNumber(gasPriceGwei).multipliedBy(gasLimit);
const bn = new BigNumber(ethers.parseUnits(networkFeeGwei.toString(), 'gwei').toString());
return bn.div(new BigNumber(10).pow(NATIVE_CURRENCY_PRECISION)).toString();
}