import { Logger } from 'pino'; import { Address, HexString } from '@hyperlane-xyz/utils'; import type { PredicateAttestation } from '../predicate/PredicateApiClient.js'; 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 { QuotedTransferProvider } from '../quoted-calls/QuotedTransferProvider.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 interface InterchainTransferFeeQuote { igpQuote: TokenAmount; tokenFeeQuote?: TokenAmount; } 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; /** * Simulates a transfer to estimate 'local' gas fees on the origin chain */ getLocalTransferFee({ originToken, destination, sender, senderPubKey, interchainFee, tokenFeeQuote, attestation, amount, destinationToken, quotedCalls, }: { originToken: IToken; destination: ChainNameOrId; sender: Address; senderPubKey?: HexString; interchainFee?: TokenAmount; tokenFeeQuote?: TokenAmount; attestation?: PredicateAttestation; amount?: bigint; destinationToken?: IToken; quotedCalls?: QuotedCallsParams; }): 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, attestation, amount, destinationToken, quotedCalls, }: { originToken: IToken; destination: ChainNameOrId; sender: Address; senderPubKey?: HexString; interchainFee?: TokenAmount; tokenFeeQuote?: TokenAmount; attestation?: PredicateAttestation; amount?: bigint; destinationToken?: IToken; quotedCalls?: QuotedCallsParams; }): 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, attestation, destinationToken, quotedCalls, quotedTransfer, }: { originTokenAmount: TokenAmount; destination: ChainNameOrId; sender: Address; recipient: Address; interchainFee?: TokenAmount; tokenFeeQuote?: TokenAmount; /** Optional Predicate attestation for compliance-gated warp routes */ attestation?: PredicateAttestation; destinationToken?: IToken; /** * @deprecated Use `quotedTransfer` instead. Backcompat sugar — wraps into * an `EvmQuotedTransferProvider` internally. EVM-only; new code should * construct a `QuotedTransferProvider` directly and pass it via * `quotedTransfer` for protocol-agnostic dispatch. */ quotedCalls?: QuotedCallsParams; /** * Protocol-agnostic offchain-quoting hook. EVM and Sealevel provide their * own implementations; WarpCore dispatches via a single branch. */ quotedTransfer?: QuotedTransferProvider; }): Promise>; /** * Check if this is a CrossCollateralRouter transfer. * Returns true if both tokens are CrossCollateralRouter tokens. */ 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, attestation, interchainFee, tokenFeeQuote, }: { originTokenAmount: TokenAmount; destination: ChainNameOrId; sender: Address; recipient: Address; destinationToken: IToken; attestation?: PredicateAttestation; interchainFee?: TokenAmount; tokenFeeQuote?: TokenAmount; }): Promise>; /** * Display-time fee quote for an offchain-quoted transfer. Caller constructs * a `QuotedTransferProvider` (EVM or Sealevel) and passes it in; WarpCore * dispatches to the provider's `getQuotedTransferFee` without per-VM * branching. * * Mirrors `getTransferRemoteTxs({ quotedTransfer })` — same provider * instance can drive both display and submit so the UI doesn't need * separate state for each. */ getQuotedTransferFee(args: { quotedTransfer: QuotedTransferProvider; originTokenAmount: TokenAmount; destination: ChainNameOrId; sender: string; recipient: string; destinationToken?: IToken; }): Promise<{ igpQuote: TokenAmount; tokenFeeQuote?: TokenAmount; }>; /** * Fetch local and interchain fee estimates for a remote transfer */ estimateTransferRemoteFees({ originTokenAmount, destination, recipient, sender, senderPubKey, attestation, destinationToken, }: { originTokenAmount: TokenAmount; destination: ChainNameOrId; recipient: Address; sender: Address; senderPubKey?: HexString; attestation?: PredicateAttestation; destinationToken?: IToken; }): Promise; /** * Estimate fees for a CrossCollateralRouter transfer. */ protected estimateCrossCollateralFees({ originTokenAmount, destination, destinationToken, recipient, sender, senderPubKey, attestation, }: { originTokenAmount: TokenAmount; destination: ChainNameOrId; destinationToken: IToken; recipient: Address; sender: Address; senderPubKey?: HexString; attestation?: PredicateAttestation; }): 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, attestation, destinationToken, }: { originTokenAmount: TokenAmount; destination: ChainNameOrId; recipient: Address; sender: Address; senderPubKey?: HexString; attestation?: PredicateAttestation; 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, attestation?: PredicateAttestation, destinationToken?: IToken, interchainFee?: InterchainTransferFeeQuote): Promise | null>; /** * 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, destination: ChainNameOrId, recipient: Address, sender?: Address, destinationToken?: IToken, interchainFee?: InterchainTransferFeeQuote): 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[]; /** * Check if a token supports Predicate attestations * @param token The token to check * @param destination Optional destination chain for the route * @returns True if the token's warp route has a PredicateRouterWrapper configured */ isPredicateSupported(token: IToken, destination?: ChainName): Promise; } //# sourceMappingURL=WarpCore.d.ts.map