UNPKG

@broxus/js-core

Version:

MobX-based JavaScript Core library

8 lines (7 loc) 427 B
import BigNumber from 'bignumber.js'; import { DEFAULT_NATIVE_CURRENCY_DECIMALS } from '../constants'; import { toInt } from '../utils/to-int'; // fixedValue + (dynamicGas * gasPrice) + 1 ever export function gasToValue(fixedValue, dynamicGas, gasPrice = 1000, safeAmount = toInt(1, DEFAULT_NATIVE_CURRENCY_DECIMALS)) { return BigNumber(fixedValue).plus(BigNumber(dynamicGas).times(gasPrice)).plus(safeAmount).toFixed(); }