import { JsonRpcProvider, type TransactionRequest } from 'ethers'; export interface GasPriceConfig { baseGasPrice?: bigint; multiplierPercent?: number; minGasPrice?: bigint; maxGasPrice?: bigint; } export declare function getOptimizedGasPrice(provider: JsonRpcProvider, config?: GasPriceConfig): Promise; export interface GasEstimateConfig { multiplier?: number; fallbackGasLimit?: bigint; allowFailure?: boolean; } /** * eth_estimateGas 按 latest 状态给「刚好够」的值。捆绑里排在后面的交易执行时,前面的买卖已经改了 * 池子 / 税币状态,实际用量会更高;刚好够的上限会 OutOfGas,BlockRazor 整包判成 * non-reverting tx in bundle failed。所有估算都加 20% 余量(4.4.3 去掉后大量捆绑失败)。 */ export declare const GAS_HEADROOM_PERCENT = 120n; export declare function withGasHeadroom(gas: bigint): bigint; export declare function estimateGasWithSafety(provider: JsonRpcProvider, txRequest: TransactionRequest, config?: GasEstimateConfig): Promise; export declare function estimateGasBatch(provider: JsonRpcProvider, txRequests: TransactionRequest[], config?: GasEstimateConfig): Promise; export interface BuildTransactionOptions { from: string; to?: string; data?: string; value?: bigint; nonce: number; gasPrice: bigint; gasLimit: bigint; chainId: number; type?: 0 | 2; } export declare function buildTransaction(options: BuildTransactionOptions): TransactionRequest; /** getGasLimit 的最小 config 接口(所有链/DEX 的 config 都满足) */ export interface GasLimitConfig { gasLimit?: number | bigint; gasLimitMultiplier?: number; } export interface CommonBundleConfig { gasLimit?: number; gasLimitMultiplier?: number; minGasPriceGwei?: number; maxGasPriceGwei?: number; txType?: 0 | 2; chainId?: number; } export declare function getGasLimit(config: GasLimitConfig, defaultGas?: number): bigint; export declare function getGasPriceConfig(config: CommonBundleConfig): GasPriceConfig; export declare function getTxType(config: CommonBundleConfig): 0 | 2; export type LegacyGasFields = { type: 0; gasPrice: bigint; }; export type Eip1559GasFields = { type: 2; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; }; export type TxGasFields = LegacyGasFields | Eip1559GasFields; export declare function buildGasFields(txType: number, gasPrice: bigint): TxGasFields; /** 向节点 eth_estimateGas 要这笔 approve 的 gas 上限。节点没返回时才用 fallback。 */ export declare function estimateApproveGasLimit(provider: { estimateGas: (tx: { from?: string; to?: string; data?: string; }) => Promise; }, from: string, to: string, data: string, fallback?: bigint): Promise;