import { Logger } from 'pino'; import { Address, HexString } from '@hyperlane-xyz/utils'; import type { MultiProviderAdapter } from '../providers/MultiProviderAdapter.js'; import { TransactionFeeEstimate } from '../providers/transactionFeeEstimators.js'; import { IToken } from '../token/IToken.js'; import { Token } from '../token/Token.js'; import { TokenAmount } from '../token/TokenAmount.js'; import type { Quote } from '../quoted-calls/codec.js'; import type { QuotedCallsParams } from '../quoted-calls/types.js'; import { ChainName, ChainNameOrId } from '../types.js'; import { FeeConstantConfig, RouteBlacklist, WarpCoreFeeEstimate, WarpTypedTransaction } from './types.js'; export interface WarpCoreOptions { logger?: Logger; localFeeConstants?: FeeConstantConfig; interchainFeeConstants?: FeeConstantConfig; routeBlacklist?: RouteBlacklist; } export declare class WarpCore { readonly multiProvider: MultiProviderAdapter<{ mailbox?: Address; }>; readonly tokens: Token[]; readonly localFeeConstants: FeeConstantConfig; readonly interchainFeeConstants: FeeConstantConfig; readonly routeBlacklist: RouteBlacklist; readonly logger: Logger; constructor(multiProvider: MultiProviderAdapter<{ mailbox?: Address; }>, tokens: Token[], options?: WarpCoreOptions); /** * Takes the serialized representation of a warp config and returns a WarpCore instance * @param multiProvider the MultiProviderAdapter containing chain metadata * @param config the config object of type WarpCoreConfig */ static FromConfig(multiProvider: MultiProviderAdapter<{ mailbox?: Address; }>, config: unknown): WarpCore; /** * Queries the token router for an interchain gas quote (i.e. IGP fee). * and for token fee quote if it exists. * Sender is only required for Sealevel origins. */ getInterchainTransferFee({ originTokenAmount, destination, sender, recipient, destinationToken, }: { originTokenAmount: TokenAmount; destination: ChainNameOrId; sender?: Address; recipient: Address; destinationToken?: IToken; }): Promise<{ igpQuote: TokenAmount; tokenFeeQuote?: TokenAmount; }>; /** * Simulates a transfer to estimate 'local' gas fees on the origin chain */ getLocalTransferFee({ originToken, destination, sender, senderPubKey, interchainFee, tokenFeeQuote, destinationToken, }: { originToken: IToken; destination: ChainNameOrId; sender: Address; senderPubKey?: HexString; interchainFee?: TokenAmount; tokenFeeQuote?: TokenAmount; destinationToken?: IToken; }): Promise; /** * Similar to getLocalTransferFee in that it estimates local gas fees * but it also resolves the native token and returns a TokenAmount * @todo: rename to getLocalTransferFee for consistency (requires breaking change) */ getLocalTransferFeeAmount({ originToken, destination, sender, senderPubKey, interchainFee, tokenFeeQuote, destinationToken, }: { originToken: IToken; destination: ChainNameOrId; sender: Address; senderPubKey?: HexString; interchainFee?: TokenAmount; tokenFeeQuote?: TokenAmount; destinationToken?: IToken; }): Promise>; /** * Gets a list of populated transactions required to transfer a token to a remote chain * Typically just 1 transaction but sometimes more, like when an approval is required first */ getTransferRemoteTxs({ originTokenAmount, destination, sender, recipient, interchainFee, tokenFeeQuote, destinationToken, quotedCalls, }: { originTokenAmount: TokenAmount; destination: ChainNameOrId; sender: Address; recipient: Address; interchainFee?: TokenAmount; tokenFeeQuote?: TokenAmount; destinationToken?: IToken; /** When provided, builds an atomic QuotedCalls.execute() tx instead of separate approve+transfer */ quotedCalls?: QuotedCallsParams; }): Promise>; /** * Check if this is a CrossCollateralRouter transfer. * Returns true if both tokens are CrossCollateralRouter tokens. */ protected isCrossCollateralTransfer(originToken: IToken, destinationToken?: IToken): destinationToken is IToken; /** * Executes a CrossCollateralRouter transfer between different collateral routers. * Uses transferRemoteTo for both same-chain and cross-chain transfers. * Same-chain: calls handle() directly on target router (atomic, no relay needed). */ protected getCrossCollateralTransferTxs({ originTokenAmount, destination, sender, recipient, destinationToken, }: { originTokenAmount: TokenAmount; destination: ChainNameOrId; sender: Address; recipient: Address; destinationToken: IToken; }): Promise>; /** * Resolve common params for QuotedCalls operations. */ protected resolveQuotedCallsParams({ originTokenAmount, destination, recipient, quotedCalls, destinationToken, }: { originTokenAmount: TokenAmount; destination: ChainNameOrId; recipient: Address; quotedCalls: QuotedCallsParams; destinationToken?: IToken; }): { quotedCallsAddress: `0x${string}`; warpRoute: `0x${string}`; destination: number; recipient: `0x${string}`; amount: bigint; token: `0x${string}`; quotes: import("../quoted-calls/types.js").SubmitQuoteCommand[]; clientSalt: `0x${string}`; targetRouter: `0x${string}` | undefined; }; /** * Quote fees for a QuotedCalls transfer via quoteExecute eth_call. * Returns structured fee data (like getInterchainTransferFee) plus * the raw Quote[][] needed to build the execute tx. */ getQuotedTransferFee({ originTokenAmount, destination, sender, recipient, quotedCalls, destinationToken, }: { originTokenAmount: TokenAmount; destination: ChainNameOrId; sender: Address; recipient: Address; quotedCalls: QuotedCallsParams; destinationToken?: IToken; }): Promise<{ igpQuote: TokenAmount; tokenFeeQuote?: TokenAmount; /** Raw per-command quotes — pass to getTransferRemoteTxs */ feeQuotes: Quote[][]; }>; /** * Build transactions for a QuotedCalls atomic transfer. * Returns [approval (if needed), execute] transactions. * * @param feeQuotes Raw Quote[][] from getQuotedTransferFee. * If not provided, calls quoteExecute internally. */ protected getQuotedCallsTransferTxs({ originTokenAmount, destination, sender, recipient, quotedCalls, destinationToken, feeQuotes, }: { originTokenAmount: TokenAmount; destination: ChainNameOrId; sender: Address; recipient: Address; quotedCalls: QuotedCallsParams; destinationToken?: IToken; feeQuotes?: Quote[][]; }): Promise>; /** * Fetch local and interchain fee estimates for a remote transfer */ estimateTransferRemoteFees({ originTokenAmount, destination, recipient, sender, senderPubKey, destinationToken, }: { originTokenAmount: TokenAmount; destination: ChainNameOrId; recipient: Address; sender: Address; senderPubKey?: HexString; destinationToken?: IToken; }): Promise; /** * Estimate fees for a CrossCollateralRouter transfer. */ protected estimateCrossCollateralFees({ originTokenAmount, destination, destinationToken, recipient, sender, senderPubKey, }: { originTokenAmount: TokenAmount; destination: ChainNameOrId; destinationToken: IToken; recipient: Address; sender: Address; senderPubKey?: HexString; }): Promise; /** * Computes the max transferrable amount of the from the given * token balance, accounting for local and interchain gas fees */ getMaxTransferAmount({ balance, destination, recipient, sender, senderPubKey, feeEstimate, destinationToken, }: { balance: TokenAmount; destination: ChainNameOrId; recipient: Address; sender: Address; senderPubKey?: HexString; feeEstimate?: WarpCoreFeeEstimate; destinationToken?: IToken; }): Promise>; getTokenCollateral(token: IToken): Promise; /** * Checks if destination chain's collateral is sufficient to cover the transfer */ isDestinationCollateralSufficient({ originTokenAmount, destination, destinationToken, }: { originTokenAmount: TokenAmount; destination: ChainNameOrId; destinationToken?: IToken; }): Promise; /** * Checks if a token transfer requires an approval tx first */ isApproveRequired({ originTokenAmount, owner, }: { originTokenAmount: TokenAmount; owner: Address; }): Promise; /** * Ensure the remote token transfer would be valid for the given chains, amount, sender, and recipient */ validateTransfer({ originTokenAmount, destination, recipient, sender, senderPubKey, destinationToken, }: { originTokenAmount: TokenAmount; destination: ChainNameOrId; recipient: Address; sender: Address; senderPubKey?: HexString; destinationToken?: IToken; }): Promise | null>; /** * Ensure the origin and destination chains are valid and known by this WarpCore */ protected validateChains(origin: ChainNameOrId, destination: ChainNameOrId): Record | null; /** * Ensure recipient address is valid for the destination chain */ protected validateRecipient(recipient: Address, destination: ChainNameOrId): Record | null; /** * Ensure token amount is valid */ protected validateAmount(originTokenAmount: TokenAmount, destination: ChainNameOrId, recipient: Address, destinationToken?: IToken): Promise | null>; /** * Ensure the sender has sufficient balances for transfer and interchain gas */ protected validateTokenBalances(originTokenAmount: TokenAmount, destination: ChainNameOrId, sender: Address, recipient: Address, senderPubKey?: HexString, destinationToken?: IToken): Promise | null>; protected resolveDestinationToken({ originToken, destination, destinationToken, }: { originToken: IToken; destination: ChainNameOrId; destinationToken?: IToken; }): IToken; /** * Search through token list to find token with matching chain and address */ findToken(chainName: ChainName, addressOrDenom?: Address | string): Token | null; /** * Get the list of chains referenced by the tokens in this WarpCore */ getTokenChains(): ChainName[]; /** * Get the subset of tokens whose chain matches the given chainName */ getTokensForChain(chainName: ChainName): Token[]; /** * Get the subset of tokens whose chain matches the given chainName * and which are connected to a token on the given destination chain */ getTokensForRoute(origin: ChainName, destination: ChainName): Token[]; /** * Ensure the sender has sufficient balances for transfer and interchain gas */ protected validateDestinationCollateral(originTokenAmount: TokenAmount, destination: ChainNameOrId, destinationToken?: IToken): Promise | null>; /** * Ensure the sender has sufficient balances for minting */ protected validateDestinationRateLimit(originTokenAmount: TokenAmount, destination: ChainNameOrId, destinationToken?: IToken): Promise | null>; /** * Ensure the sender has sufficient balances for transfer and interchain gas */ protected validateOriginCollateral(originTokenAmount: TokenAmount): Promise | null>; } //# sourceMappingURL=WarpCore.d.ts.map