import { Deposit } from "../interfaces"; import { BigNumber, BigNumberish, TransactionCostEstimate } from "../utils"; import { Transport } from "viem"; export interface QueryInterface { getGasCosts: (deposit: Deposit, relayer: string, options?: Partial<{ gasPrice: BigNumberish; gasUnits: BigNumberish; baseFeeMultiplier: BigNumber; priorityFeeMultiplier: BigNumber; opStackL1GasCostMultiplier: BigNumber; transport: Transport; }>) => Promise; getTokenPrice: (tokenSymbol: string) => Promise; getTokenDecimals: (tokenSymbol: string) => number; } export declare const expectedCapitalCostsKeys: string[]; export interface CapitalCostConfig { lowerBound: string; upperBound: string; cutoff: string; decimals: number; } type ChainIdAsString = string; export interface CapitalCostConfigOverride { default: CapitalCostConfig; routeOverrides?: Record>; } export type RelayCapitalCostConfig = CapitalCostConfigOverride | CapitalCostConfig; export interface BaseRelayFeeCalculatorConfig { nativeTokenDecimals?: number; gasDiscountPercent?: number; capitalDiscountPercent?: number; feeLimitPercent?: number; capitalCostsConfig: { [token: string]: CapitalCostConfig | CapitalCostConfigOverride; }; } export interface RelayFeeCalculatorConfigWithQueries extends BaseRelayFeeCalculatorConfig { queries: QueryInterface; } export interface RelayFeeCalculatorConfigWithMap extends BaseRelayFeeCalculatorConfig { queriesMap: Record; } export type RelayFeeCalculatorConfig = RelayFeeCalculatorConfigWithQueries | RelayFeeCalculatorConfigWithMap; export interface RelayerFeeDetails { amountToRelay: string; tokenSymbol: string; gasFeePercent: string; gasFeeTotal: string; gasDiscountPercent: number; capitalFeePercent: string; capitalFeeTotal: string; capitalDiscountPercent: number; relayFeePercent: string; relayFeeTotal: string; feeLimitPercent: number; isAmountTooLow: boolean; maxGasFeePercent: string; minDeposit: string; } export interface LoggingFunction { (data: { at: string; message: string; [key: string]: unknown; }): void; } export interface Logger { debug: LoggingFunction; info: LoggingFunction; warn: LoggingFunction; error: LoggingFunction; } export declare const DEFAULT_LOGGER: Logger; export declare class RelayFeeCalculator { private queries; private gasDiscountPercent; private capitalDiscountPercent; private feeLimitPercent; private nativeTokenDecimals; private capitalCostsConfig; private logger; constructor(config: RelayFeeCalculatorConfigWithQueries, logger?: Logger); constructor(config: RelayFeeCalculatorConfigWithMap, logger?: Logger, destinationChainId?: number); /** * Type guard to check if a config is a CapitalCostConfigOverride or a CapitalCostConfig. * @param config CapitalCostConfig or CapitalCostConfigOverride * @returns true if the config is a CapitalCostConfigOverride, false otherwise. * @private * @dev This is a type guard that is used to check if a config is a CapitalCostConfigOverride or a CapitalCostConfig. * This is needed because the config can be either a CapitalCostConfig or a CapitalCostConfigOverride. If it's a * CapitalCostConfig, then we need to convert it to a CapitalCostConfigOverride with the default config set with no route * overrides. */ private static capitalCostConfigIsOverride; /** * Validates a CapitalCostConfigOverride or a CapitalCostConfig. * @param capitalCosts CapitalCostConfig or CapitalCostConfigOverride * @returns CapitalCostConfigOverride */ static validateAndTransformCapitalCostsConfigOverride(capitalCosts: CapitalCostConfigOverride | CapitalCostConfig): CapitalCostConfigOverride; /** * Validates a CapitalCostConfig. * @param capitalCosts CapitalCostConfig */ static validateCapitalCostsConfig(capitalCosts: CapitalCostConfig): void; getTokenPrice(tokenSymbol: string): Promise; /** * Calculate the gas fee as a % of the amount to relay. * @param deposit A valid deposit object to reason about * @param amountToRelay The amount that we should fill the deposit for * @param simulateZeroFill Whether to simulate a zero fill for the gas cost simulation * A fill of 1 wei which would result in a slow/partial fill. * You should do this if you're not worried about simulating a proper fill of a deposit * with a message or if you are worried a fill amount that could exceed the balance of * the relayer. * @param relayerAddress The relayer that will be used for the gas cost simulation * @param _tokenPrice The token price for normalizing fees * @returns The fee as a % of the amount to relay. * @note Setting simulateZeroFill to true will result on the gas costs being estimated * on a zero fill. However, the percentage will be returned as a percentage of the * amount to relay. This is useful for determining the maximum gas fee % that a * relayer may need to make on a regular fill. You will get differing results if * a message & recipient contract is provided as this function may not simulate with * the correct parameters to see a full fill. */ gasFeePercent(deposit: Deposit, amountToRelay: BigNumberish, simulateZeroFill?: boolean, relayerAddress?: string, _tokenPrice?: number, tokenMapping?: { ACX: { name: string; symbol: string; decimals: number; addresses: { [x: number]: string; }; coingeckoId: string; }; ARB: { name: string; symbol: string; decimals: number; addresses: { [x: number]: string; }; coingeckoId: string; }; AZERO: { name: string; symbol: string; decimals: number; addresses: { [x: number]: string; }; coingeckoId: string; }; BADGER: { name: string; symbol: string; decimals: number; addresses: { [x: number]: string; }; coingeckoId: string; }; BAL: { name: string; symbol: string; decimals: number; addresses: { [x: number]: string; }; coingeckoId: string; }; BOBA: { name: string; symbol: string; decimals: number; addresses: { [x: number]: string; }; coingeckoId: string; }; DAI: { name: string; symbol: string; decimals: number; addresses: { [x: number]: string; }; coingeckoId: string; }; ETH: { name: string; symbol: string; decimals: number; addresses: { [x: number]: string; }; coingeckoId: string; }; GHO: { name: string; symbol: string; decimals: number; addresses: { [x: number]: string; }; coingeckoId: string; }; GRASS: { name: string; symbol: string; decimals: number; addresses: { [x: number]: string; }; coingeckoId: string; }; LSK: { name: string; symbol: string; decimals: number; addresses: { [x: number]: string; }; coingeckoId: string; }; MATIC: { name: string; symbol: string; decimals: number; addresses: { [x: number]: string; }; coingeckoId: string; }; OP: { name: string; symbol: string; decimals: number; addresses: { [x: number]: string; }; coingeckoId: string; }; POOL: { name: string; symbol: string; decimals: number; addresses: { [x: number]: string; }; coingeckoId: string; }; SNX: { name: string; symbol: string; decimals: number; addresses: { [x: number]: string; }; coingeckoId: string; }; UMA: { name: string; symbol: string; decimals: number; addresses: { [x: number]: string; }; coingeckoId: string; }; USDB: { name: string; symbol: string; decimals: number; addresses: { [x: number]: string; }; coingeckoId: string; }; USDC: { name: string; symbol: string; decimals: number; addresses: { [x: number]: string; }; coingeckoId: string; }; "USDC.e": { name: string; symbol: string; decimals: number; addresses: { [x: number]: string; }; coingeckoId: string; }; USDbC: { name: string; symbol: string; decimals: number; addresses: { [x: number]: string; }; coingeckoId: string; }; USDzC: { name: string; symbol: string; decimals: number; addresses: { [x: number]: string; }; coingeckoId: string; }; USDT: { name: string; symbol: string; decimals: number; addresses: { [x: number]: string; }; coingeckoId: string; }; WAZERO: { name: string; symbol: string; decimals: number; addresses: { [x: number]: string; }; coingeckoId: string; }; WBTC: { name: string; symbol: string; decimals: number; addresses: { [x: number]: string; }; coingeckoId: string; }; WETH: { name: string; symbol: string; decimals: number; addresses: { [x: number]: string; }; coingeckoId: string; }; WGRASS: { name: string; symbol: string; decimals: number; addresses: { [x: number]: string; }; coingeckoId: string; }; WMATIC: { name: string; symbol: string; decimals: number; addresses: { [x: number]: string; }; coingeckoId: string; }; }, gasPrice?: BigNumberish, gasLimit?: BigNumberish, _tokenGasCost?: BigNumberish, transport?: Transport): Promise; capitalFeePercent(_amountToRelay: BigNumberish, _tokenSymbol: string, _originRoute?: ChainIdAsString, _destinationRoute?: ChainIdAsString): BigNumber; /** * Retrieves the relayer fee details for a deposit. * @param deposit A valid deposit object to reason about * @param amountToRelay The amount that the relayer would simulate a fill for * @param simulateZeroFill Whether to simulate a zero fill for the gas cost simulation * For simulateZeroFill: A fill of 1 wei which would result in a slow/partial fill. * You should do this if you're not worried about simulating a proper fill of a deposit * with a message or if you are worried a fill amount that could exceed the balance of * the relayer. * @param relayerAddress The relayer that will be used for the gas cost simulation * @param _tokenPrice The token price for normalizing fees * @param gasPrice Optional gas price to use for the simulation * @param gasUnits Optional gas units to use for the simulation * @returns A resulting `RelayerFeeDetails` object */ relayerFeeDetails(deposit: Deposit, amountToRelay?: BigNumberish, simulateZeroFill?: boolean, relayerAddress?: string, _tokenPrice?: number, gasPrice?: BigNumberish, gasUnits?: BigNumberish, tokenGasCost?: BigNumberish): Promise; } export {};