UNPKG

@dolomite-exchange/dolomite-margin

Version:

Ethereum Smart Contracts and TypeScript library used for the DolomiteMargin trading protocol

64 lines 3.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.ArbitrumGasInfo = void 0; const bignumber_js_1 = __importDefault(require("bignumber.js")); class ArbitrumGasInfo { constructor(contracts) { this.contracts = contracts; } // ============ State-Changing Functions ============ static mapToAllGasPricesInWei(result) { return { perL2Tx: new bignumber_js_1.default(result[0]), perL1CalldataUnit: new bignumber_js_1.default(result[1]), perStorageAllocation: new bignumber_js_1.default(result[2]), perArbGasBase: new bignumber_js_1.default(result[3]), perArbGasCongestion: new bignumber_js_1.default(result[4]), perArbGasTotal: new bignumber_js_1.default(result[5]), }; } static mapToSomeGasPricesInWei(result) { return { perL2Tx: new bignumber_js_1.default(result[0]), perL1CalldataUnit: new bignumber_js_1.default(result[1]), perStorageAllocation: new bignumber_js_1.default(result[2]), }; } async getPricesInWeiWithAggregator(aggregator, options = {}) { const result = await this.contracts.callConstantContractFunction(this.contracts.arbitrumGasInfo.methods.getPricesInWeiWithAggregator(aggregator), options); return ArbitrumGasInfo.mapToAllGasPricesInWei(result); } async getPricesInWei(options = {}) { const result = await this.contracts.callConstantContractFunction(this.contracts.arbitrumGasInfo.methods.getPricesInWei(), options); return ArbitrumGasInfo.mapToAllGasPricesInWei(result); } async getPricesInArbGasWithAggregator(aggregator, options = {}) { const result = await this.contracts.callConstantContractFunction(this.contracts.arbitrumGasInfo.methods.getPricesInArbGasWithAggregator(aggregator), options); return ArbitrumGasInfo.mapToSomeGasPricesInWei(result); } async getPricesInArbGas(options = {}) { const result = await this.contracts.callConstantContractFunction(this.contracts.arbitrumGasInfo.methods.getPricesInArbGas(), options); return ArbitrumGasInfo.mapToSomeGasPricesInWei(result); } async getGasAccountingParams(options = {}) { const result = await this.contracts.callConstantContractFunction(this.contracts.arbitrumGasInfo.methods.getGasAccountingParams(), options); return { speedLimitPerSecond: new bignumber_js_1.default(result[0]), gasPoolMax: new bignumber_js_1.default(result[1]), maxTxGasLimit: new bignumber_js_1.default(result[2]), }; } async getL1GasPriceEstimate(options = {}) { const result = await this.contracts.callConstantContractFunction(this.contracts.arbitrumGasInfo.methods.getL1GasPriceEstimate(), options); return new bignumber_js_1.default(result); } async getCurrentTxL1GasFees(options = {}) { const result = await this.contracts.callConstantContractFunction(this.contracts.arbitrumGasInfo.methods.getCurrentTxL1GasFees(), options); return new bignumber_js_1.default(result); } } exports.ArbitrumGasInfo = ArbitrumGasInfo; //# sourceMappingURL=ArbitrumGasInfo.js.map