import type { Logger } from 'pino'; import type { ChainMap, ChainMetadata } from '@hyperlane-xyz/sdk'; import { ProtocolType } from '@hyperlane-xyz/utils'; import type { ExternalBridgeType } from '../config/types.js'; /** * Configuration for an external bridge. */ export interface ExternalBridgeConfig { integrator: string; apiKey?: string; defaultSlippage?: number; chainMetadata?: ChainMap; } /** * Parameters for requesting a bridge quote. * Either fromAmount OR toAmount must be provided (mutually exclusive). * - fromAmount: "I'm sending X, what do I get?" (standard quote) * - toAmount: "I want X on destination, how much do I send?" (reverse quote) */ export interface BridgeQuoteParams { fromChain: number; toChain: number; fromToken: string; toToken: string; fromAmount?: bigint; toAmount?: bigint; fromAddress: string; toAddress?: string; slippage?: number; } /** * Quote response from a bridge. */ export interface BridgeQuote { id: string; tool: string; fromAmount: bigint; toAmount: bigint; toAmountMin: bigint; executionDuration: number; gasCosts: bigint; feeCosts: bigint; route: R; requestParams: BridgeQuoteParams; } /** * Result of executing a bridge transfer. */ export interface BridgeTransferResult { txHash: string; fromChain: number; toChain: number; transferId?: string; } /** * Status of a bridge transfer. */ export type BridgeTransferStatus = { status: 'pending'; substatus?: string; } | { status: 'complete'; receivingTxHash: string; receivedAmount: bigint; } | { status: 'failed'; error?: string; } | { status: 'not_found'; }; /** * Interface for external bridge implementations (e.g., LiFi, Socket). * * External bridges are used for inventory rebalancing when chains don't support * MovableCollateralRouter. The flow is: * 1. quote() - Get a quote for bridging tokens * 2. execute() - Execute the bridge transfer * 3. getStatus() - Poll for transfer completion */ export interface IExternalBridge { readonly externalBridgeId: string; readonly logger: Logger; getNativeTokenAddress?(): string; quote(params: BridgeQuoteParams): Promise; /** * Execute a bridge transfer using a previously obtained quote. * @param quote - Quote obtained from quote() * @param privateKeys - Private keys keyed by ProtocolType (e.g., { [ProtocolType.Ethereum]: '0x...' }) */ execute(quote: BridgeQuote, privateKeys: Partial>): Promise; /** * Get the status of a bridge transfer. * @param txHash - Origin chain transaction hash * @param fromChain - Source chain ID * @param toChain - Destination chain ID */ getStatus(txHash: string, fromChain: number, toChain: number): Promise; } /** * Registry mapping external bridge types to their implementations. */ export type ExternalBridgeRegistry = Record; //# sourceMappingURL=IExternalBridge.d.ts.map