mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-24 06:37:40 +03:00
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
14 lines
510 B
TypeScript
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();
|
|
}
|