import { BigNumber } from 'ethers'; import { AbacusCore, CoreEnvironment, CoreEnvironmentChain } from '../core/AbacusCore'; import { MultiProvider } from '../providers/MultiProvider'; import { ChainName, Remotes } from '../types'; import { TokenPriceGetter } from './token-prices'; export interface InterchainGasCalculatorConfig { /** * A multiplier applied to the estimated origin token payment amount. * This should be high enough to account for movements in token exchange * rates and gas prices. * @defaultValue 1.25 */ paymentEstimateMultiplier?: string; /** * An amount of additional gas to add to the estimated gas of processing a message. * Only used when estimating a payment from a message. * @defaultValue 50,000 */ messageGasEstimateBuffer?: string; /** * Used to get the native token prices of the origin and destination chains. * @defaultValue An instance of DefaultTokenPriceGetter. */ tokenPriceGetter?: TokenPriceGetter; } export declare type ParsedMessage = { origin: Exclude; sender: string; destination: Destination; recipient: string; body: string; }; /** * Calculates interchain gas payments. */ export declare class InterchainGasCalculator { private core; private multiProvider; private tokenPriceGetter; private paymentEstimateMultiplier; private messageGasEstimateBuffer; static fromEnvironment(env: Env, multiProvider: MultiProvider>, config?: InterchainGasCalculatorConfig): InterchainGasCalculator>; constructor(multiProvider: MultiProvider, core: AbacusCore, config?: InterchainGasCalculatorConfig); /** * Given an amount of gas to consume on the destination chain, calculates the * estimated payment denominated in the native token of the origin chain. * Considers the exchange rate between the native tokens of the origin and * destination chains and the suggested gas price of the destination chain. * @param origin The name of the origin chain. * @param destination The name of the destination chain. * @param gas The amount of gas to pay for on the destination chain. * @returns An estimated amount of origin chain tokens to cover gas costs on the * destination chain. */ estimatePaymentForGas(origin: Exclude, destination: Destination, gas: BigNumber): Promise; /** * Given an amount of gas the message's recipient `handle` function is expected * to use, calculates the estimated payment denominated in the native * token of the origin chain. Considers the exchange rate between the native * tokens of the origin and destination chains, the suggested gas price on * the destination chain, gas costs incurred by a relayer when submitting a signed * checkpoint to the destination chain, and the overhead gas cost in Inbox of processing * a message. * @param origin The name of the origin chain. * @param destination The name of the destination chain. * @param handleGas The amount of gas the recipient `handle` function * is estimated to use. * @returns An estimated amount of origin chain tokens to cover gas costs of the * message on the destination chain. */ estimatePaymentForHandleGas(origin: Exclude, destination: Destination, handleGas: BigNumber): Promise; /** * Calculates the estimated payment to process the message on its destination chain, * denominated in the native token of the origin chain. The gas used by the message's * recipient handler function is estimated in an eth_estimateGas call to the * destination chain, and is then used to calculate the payment using * Currently made private as it does not work properly for Arbitrum. * {@link estimatePaymentForHandleGasAmount}. * @param message The parsed message to estimate payment for. * @returns An estimated amount of origin chain tokens to cover gas costs of the * message on the destination chain. */ protected estimatePaymentForMessage(message: ParsedMessage): Promise; /** * Using the exchange rates provided by tokenPriceGetter, returns the amount of * `toChain` native tokens equivalent in value to the provided `fromAmount` of * `fromChain` native tokens. Accounts for differences in the decimals of the tokens. * @param fromChain The chain whose native token is being converted from. * @param toChain The chain whose native token is being converted into. * @param fromAmount The amount of `fromChain` native tokens to convert from. * @returns The amount of `toChain` native tokens whose value is equivalent to * `fromAmount` of `fromChain` native tokens. */ protected convertBetweenTokens(fromChain: Chain, toChain: Chain, value: BigNumber): Promise; /** * Gets a suggested gas price for a chain. * @param chainName The name of the chain to get the gas price for * @returns The suggested gas price in wei on the destination chain. */ protected getGasPrice(chain: Chain): Promise; /** * Gets the number of decimals of the provided chain's native token. * @param chain The chain. * @returns The number of decimals of `chain`'s native token. */ protected tokenDecimals(chain: Chain): number; /** * Estimates the amount of gas used by message's recipient `handle` function * on its destination chain. This does not assume the Inbox of the destination * chain has a checkpoint that the message is included in, and does not * consider intrinsic gas or any "overhead" gas incurred by Inbox.process. * The estimated gas returned is the sum of: * 1. The estimated gas consumption of a direct call to the `handle` * function of the recipient address using the correct parameters and * setting the `from` address of the transaction to the address of the inbox. * 2. A buffer to account for inaccuracies in the above estimation. * @param message The message to estimate recipient `handle` gas usage for. * @returns The estimated gas required by the message's recipient handle function * on the destination chain. */ protected estimateGasForHandle(message: ParsedMessage): Promise; /** * @returns A generous estimation of the gas consumption of all process * operations within Inbox.sol, including intrinsic gas. Does not include any gas * consumed within a message's recipient `handle` function. */ protected estimateGasForProcess(origin: Remotes, destination: Destination): Promise; /** * @returns The intrinsic gas of a basic transaction. Note this does not consider calldata * costs or potentially different intrinsic gas costs for different chains. */ protected intrinsicGas(): BigNumber; } //# sourceMappingURL=calculator.d.ts.map