UNPKG

rubic-sdk

Version:
26 lines 1.37 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getGasPriceInfo = getGasPriceInfo; const bignumber_js_1 = __importDefault(require("bignumber.js")); const native_tokens_1 = require("../../../../../../common/tokens/constants/native-tokens"); const web3_pure_1 = require("../../../../../../core/blockchain/web3-pure/web3-pure"); const injector_1 = require("../../../../../../core/injector/injector"); async function getGasPriceInfo(blockchain) { const address = native_tokens_1.nativeTokensList[blockchain].address; const [{ gasPrice, maxFeePerGas }, nativeCoinPrice] = await Promise.all([ injector_1.Injector.gasPriceApi.getGasPrice(blockchain), injector_1.Injector.coingeckoApi.getTokenPrice({ address, blockchain }).catch(() => new bignumber_js_1.default(0)) ]); const gasPriceInEth = web3_pure_1.Web3Pure.fromWei(maxFeePerGas || gasPrice || 0); const gasPriceInUsd = gasPriceInEth.multipliedBy(nativeCoinPrice); return { gasPrice: new bignumber_js_1.default(gasPrice || 0), gasPriceInEth, gasPriceInUsd, maxFeePerGas: new bignumber_js_1.default(maxFeePerGas || 0) }; } //# sourceMappingURL=get-gas-price-info.js.map