/****************************************************************************** * * (C) 2022 AhnLab Blockchain Company, Inc. All rights reserved. * Any part of this source code can not be copied with any method without * prior written permission from the author or authorized person. * ******************************************************************************/ import { ProviderConnectionManager } from '../../usecase/provider/connectionManager'; export declare const LEGACY_GAS_PRICES_API_URL = "https://api.metaswap.codefi.network/gasPrices"; export type unknownString = 'unknown'; export type FeeMarketEstimateType = 'fee-market'; export type LegacyEstimateType = 'legacy'; export type EthGasPriceEstimateType = 'eth_gasPrice'; export type NoEstimateType = 'none'; /** * Indicates which type of gasEstimate the controller is currently returning. * This is useful as a way of asserting that the shape of gasEstimates matches * expectations. NONE is a special case indicating that no previous gasEstimate * has been fetched. */ export declare const GAS_ESTIMATE_TYPES: { META_SWAP: "fee-market"; ALCHEMY: "fee-market"; NONE: "none"; }; export type GasEstimateType = FeeMarketEstimateType | EthGasPriceEstimateType | LegacyEstimateType | NoEstimateType; export interface EstimatedGasFeeTimeBounds { lowerTimeBound: number | null; upperTimeBound: number | unknownString; } /** * @type EthGasPriceEstimate * * A single gas price estimate for networks and accounts that don't support EIP-1559 * This estimate comes from eth_gasPrice but is converted to dec gwei to match other * return values * * @property gasPrice - A GWEI dec string */ export interface EthGasPriceEstimate { gasPrice: string; } /** * @type LegacyGasPriceEstimate * * A set of gas price estimates for networks and accounts that don't support EIP-1559 * These estimates include low, medium and high all as strings representing gwei in * decimal format. * * @property high - gasPrice, in decimal gwei string format, suggested for fast inclusion * @property medium - gasPrice, in decimal gwei string format, suggested for avg inclusion * @property low - gasPrice, in decimal gwei string format, suggested for slow inclusion */ export interface LegacyGasPriceEstimate { high: string; medium: string; low: string; } /** * @type Eip1559GasFee * * Data necessary to provide an estimate of a gas fee with a specific tip * * @property minWaitTimeEstimate - The fastest the transaction will take, in milliseconds * @property maxWaitTimeEstimate - The slowest the transaction will take, in milliseconds * @property suggestedMaxPriorityFeePerGas - A suggested "tip", a GWEI hex number * @property suggestedMaxFeePerGas - A suggested max fee, the most a user will pay. a GWEI hex number */ export interface Eip1559GasFee { minWaitTimeEstimate: number; maxWaitTimeEstimate: number; suggestedMaxPriorityFeePerGas: string; suggestedMaxFeePerGas: string; } /** * @type GasFeeEstimates * * Data necessary to provide multiple GasFee estimates, and supporting information, to the user * * @property low - A GasFee for a minimum necessary combination of tip and maxFee * @property medium - A GasFee for a recommended combination of tip and maxFee * @property high - A GasFee for a high combination of tip and maxFee * @property estimatedBaseFee - An estimate of what the base fee will be for the pending/next block. A GWEI dec number */ export interface GasFeeEstimates { low: Eip1559GasFee; medium: Eip1559GasFee; high: Eip1559GasFee; estimatedBaseFee: string; } export type GasFeeStateEthGasPrice = { gasFeeEstimates: EthGasPriceEstimate; estimatedGasFeeTimeBounds: Record; gasEstimateType: EthGasPriceEstimateType; }; export type GasFeeStateFeeMarket = { gasFeeEstimates: GasFeeEstimates; estimatedGasFeeTimeBounds: EstimatedGasFeeTimeBounds | Record; gasEstimateType: FeeMarketEstimateType; }; export type GasFeeStateLegacy = { gasFeeEstimates: LegacyGasPriceEstimate; estimatedGasFeeTimeBounds: Record; gasEstimateType: LegacyEstimateType; }; export type GasFeeStateNoEstimates = { gasFeeEstimates: Record; estimatedGasFeeTimeBounds: Record; gasEstimateType: NoEstimateType; }; export interface FetchGasFeeEstimateOptions { shouldUpdateState?: boolean; } /** * @type GasFeeState * * Gas Fee controller state * * @property gasFeeEstimates - Gas fee estimate data based on new EIP-1559 properties * @property estimatedGasFeeTimeBounds - Estimates representing the minimum and maximum */ export type GasFeeState = GasFeeStateEthGasPrice | GasFeeStateFeeMarket | GasFeeStateLegacy | GasFeeStateNoEstimates; declare const name = "GasFeeController"; export type GetGasFeeState = { type: `${typeof name}:getState`; handler: () => GasFeeState; }; /** * Controller that retrieves gas fee estimate data and polls for updated data on a set interval */ export declare class GasFeeService { private providerConnManager; private intervalId?; private intervalDelay; private pollTokens; private legacyAPIEndpoint; private EIP1559APIEndpoint; fetchGasEstimates: any; fetchAlchemyGasPriceEstimate: any; /** * Creates a GasFeeController instance * */ constructor(providerConnManager: ProviderConnectionManager); fetchGasFeeEstimates(options?: FetchGasFeeEstimateOptions): Promise; getGasFeeEstimatesAndStartPolling(pollToken?: string): Promise; /** * Gets and sets gasFeeEstimates in state * * @returns GasFeeEstimates */ _fetchGasFeeEstimateData(options?: FetchGasFeeEstimateOptions): Promise; /** * Remove the poll token, and stop polling if the set of poll tokens is empty */ disconnectPoller(pollToken: string): void; stopPolling(): void; private _startPolling; private _poll; private getEIP1559Compatibility; } export {};