rubic-sdk
Version:
Simplify dApp creation
24 lines • 1.07 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getGasFeeInfo = getGasFeeInfo;
const bignumber_js_1 = __importDefault(require("bignumber.js"));
const web3_pure_1 = require("../../../../../../core/blockchain/web3-pure/web3-pure");
function getGasFeeInfo(gasPriceInfo, gasData = {}) {
const gasLimit = gasData.gasLimit
? web3_pure_1.Web3Pure.calculateGasMargin(gasData.gasLimit, 1.2)
: new bignumber_js_1.default(0);
const gasFeeInEth = gasPriceInfo?.gasPriceInEth?.multipliedBy(gasLimit);
const gasFeeInUsd = gasPriceInfo?.gasPriceInUsd?.multipliedBy(gasLimit);
return {
...(gasData.totalGas && { totalGas: gasData.totalGas }),
...(gasLimit.gt(0) && { gasLimit }),
gasPrice: gasPriceInfo?.gasPrice,
gasFeeInEth,
gasFeeInUsd,
maxFeePerGas: gasPriceInfo?.maxFeePerGas
};
}
//# sourceMappingURL=get-gas-fee-info.js.map