/** * Li.Fi Types - Translated from portal-android Kotlin types */ /** * The way the resulting quote should be ordered */ export type LifiQuoteOrder = 'FASTEST' | 'CHEAPEST' /** * Used to request a quote for a transfer of one token to another, cross chain or not */ export interface LifiQuoteRequest { /** * The sending chain. Can be the chain id or chain key (required) */ fromChain: string /** * The receiving chain. Can be the chain id or chain key (required) */ toChain: string /** * The token that should be transferred. Can be the address or the symbol (required) */ fromToken: string /** * The token that should be transferred to. Can be the address or the symbol (required) */ toToken: string /** * The sending wallet address (required) */ fromAddress: string /** * The amount that should be sent including all decimals (e.g. 1000000 for 1 USDC (6 decimals)) (required) */ fromAmount: string /** * The receiving wallet address. If none is provided, the fromAddress will be used */ toAddress?: string /** * Which kind of route should be preferred (FASTEST or CHEAPEST) */ order?: LifiQuoteOrder /** * The maximum allowed slippage for the transaction as a decimal value. 0.005 represents 0.5%. Range: 0 <= x <= 1 */ slippage?: number /** * A string containing tracking information about the integrator of the API */ integrator?: string /** * The percent of the integrator's fee that is taken from every transaction. 0.02 represents 2%. Range: 0 <= x < 1 */ fee?: number /** * A string containing tracking information about the referrer of the integrator */ referrer?: string /** * List of bridges that are allowed for this transaction */ allowBridges?: string[] /** * List of exchanges that are allowed for this transaction */ allowExchanges?: string[] /** * List of bridges that are not allowed for this transaction */ denyBridges?: string[] /** * List of exchanges that are not allowed for this transaction */ denyExchanges?: string[] /** * List of bridges that should be preferred for this transaction */ preferBridges?: string[] /** * List of exchanges that should be preferred for this transaction */ preferExchanges?: string[] /** * Whether swaps or other contract calls should be allowed as part of the destination transaction of a bridge transfer (default: true) */ allowDestinationCall?: boolean /** * The amount of the token to convert to gas on the destination side */ fromAmountForGas?: string /** * The price impact threshold above which routes are hidden. As an example, one should specify 0.15 (15%) to hide routes with more than 15% price impact. The default is 10%. */ maxPriceImpact?: number /** * Timing setting to wait for a certain amount of swap rates. Format: "minWaitTime-${minWaitTimeMs}-${startingExpectedResults}-${reduceEveryMs}" */ swapStepTimingStrategies?: string[] /** * Timing setting to wait for a certain amount of routes to be generated before choosing the best one. Format: "minWaitTime-${minWaitTimeMs}-${startingExpectedResults}-${reduceEveryMs}" */ routeTimingStrategies?: string[] /** * Parameter to skip transaction simulation. The quote will be returned faster but the transaction gas limit won't be accurate. */ skipSimulation?: boolean } /** * Response containing a quote from the Lifi integration */ export interface LifiQuoteResponse { data?: LifiQuoteData error?: string } export interface LifiQuoteData { rawResponse: LifiStep } /** * Error response when unable to find a quote for the requested transfer (404) */ export interface LifiQuoteErrorResponse { /** * The error message */ message: string /** * Error details containing unavailable routes information */ errors?: LifiUnavailableRoutes } /** * The way the resulting routes should be ordered */ export type LifiRoutesOrder = 'FASTEST' | 'CHEAPEST' /** * Type of timing strategy */ export type LifiTimingStrategyType = 'minWaitTime' /** * Describes a desired any-to-any transfer and contains all information necessary to calculate the most efficient routes */ export interface LifiRoutesRequest { /** * The sending chain id (required) */ fromChainId: string /** * The amount that should be transferred including all decimals (e.g. 1000000 for 1 USDC (6 decimals)) (required) */ fromAmount: string /** * The address of the sending Token (required) */ fromTokenAddress: string /** * The id of the receiving chain (required) */ toChainId: string /** * The address of the receiving Token (required) */ toTokenAddress: string /** * Optional configuration for the routes */ options?: LifiRoutesRequestOptions /** * The sending wallet address */ fromAddress?: string /** * The receiving wallet address */ toAddress?: string /** * The amount of the token to convert to gas on the destination side */ fromAmountForGas?: string } /** * Optional configuration for the routes */ export interface LifiRoutesRequestOptions { /** * Facilitates transfer insurance via insurace.io, ensuring secure and insured transfer of assets (deprecated) */ insurance?: boolean /** * Custom string the developer who integrates LiFi can set */ integrator?: string /** * The maximum allowed slippage */ slippage?: number /** * Object configuring the bridges that should or should not be taken into consideration for the possibilities */ bridges?: LifiToolsConfiguration /** * Object configuring the exchanges that should or should not be taken into consideration for the possibilities */ exchanges?: LifiToolsConfiguration /** * The way the resulting routes should be ordered */ order?: LifiRoutesOrder /** * Whether chain switches should be allowed in the routes (default: false) */ allowSwitchChain?: boolean /** * Defines if we should return routes with a cross-chain bridge protocol (Connext, etc.) destination calls or not (default: true) */ allowDestinationCall?: boolean /** * Integrators can set a wallet address as referrer to track them */ referrer?: string /** * The percent of the integrator's fee that is taken from every transaction. The maximum fee amount should be less than 100%. Required range: 0 <= x < 1 */ fee?: number /** * The price impact threshold above which routes are hidden. As an example, one should specify 0.15 (15%) to hide routes with more than 15% price impact. The default is 10%. */ maxPriceImpact?: number /** * Timing settings for route and swap steps */ timing?: LifiTimingOptions } /** * Configuration for bridges or exchanges (allow, deny, prefer) */ export interface LifiToolsConfiguration { /** * Allowed tools */ allow?: string[] /** * Forbidden tools */ deny?: string[] /** * Preferred tools */ prefer?: string[] } /** * Timing options for routes and swap steps */ export interface LifiTimingOptions { /** * Timing setting to wait for a certain amount of swap rates */ swapStepTimingStrategies?: LifiTimingStrategy[] /** * Timing setting to wait for a certain amount of routes to be generated before choosing the best one */ routeTimingStrategies?: LifiTimingStrategy[] } /** * Timing strategy configuration */ export interface LifiTimingStrategy { /** * The timing strategy type */ strategy?: LifiTimingStrategyType /** * Minimum wait time in milliseconds (range: 0 <= x <= 15000) */ minWaitTimeMs?: number /** * Starting expected results (range: 0 <= x <= 100) */ startingExpectedResults?: number /** * Reduce every milliseconds (range: 0 <= x <= 15000) */ reduceEveryMs?: number } /** * Response containing routes from the Lifi integration */ export interface LifiRoutesResponse { data?: LifiRoutesData error?: string } export interface LifiRoutesData { rawResponse: LifiRoutesRawResponse } /** * - Note: `routes` is required, `unavailableRoutes` is optional */ export interface LifiRoutesRawResponse { /** * List of possible routes for the given transfer (required) */ routes: LifiRoute[] /** * Routes that are unavailable for the given transfer (optional) */ unavailableRoutes?: LifiUnavailableRoutes } /** * A route that can be used to realize a token transfer */ export interface LifiRoute { /** * Unique identifier of the route */ id: string /** * The id of the sending chain */ fromChainId: string /** * The amount that should be transferred in USD */ fromAmountUSD: string /** * The amount that should be transferred including all decimals */ fromAmount: string /** * The sending Token */ fromToken: LifiToken /** * The id of the receiving chain */ toChainId: string /** * The estimated resulting amount of the toToken in USD as float with two decimals */ toAmountUSD: string /** * The estimated resulting amount of the toToken including all decimals */ toAmount: string /** * The minimal resulting amount of the toToken including all decimals */ toAmountMin: string /** * The Token that should be transferred to */ toToken: LifiToken /** * The steps required to fulfill the transfer */ steps: LifiStep[] /** * Aggregation of the underlying gas costs in USD */ gasCostUSD?: string /** * The sending wallet address */ fromAddress?: string /** * The receiving wallet address */ toAddress?: string /** * Whether a chain switch is part of the route */ containsSwitchChain?: boolean /** * Tags associated with the route (e.g., "RECOMMENDED", "CHEAPEST", "FASTEST") */ tags?: string[] } /** * Token information */ export interface LifiToken { /** * Address of the token */ address: string /** * Symbol of the token */ symbol: string /** * Number of decimals the token uses */ decimals: number /** * Id of the token's chain */ chainId: string /** * Name of the token */ name: string /** * Identifier for the token */ coinKey?: string /** * Logo of the token */ logoURI?: string /** * Token price in USD */ priceUSD?: string } /** * Type of step in a route */ export type LifiStepType = 'swap' | 'cross' | 'lifi' | 'protocol' /** * Step in a route */ export interface LifiStep { /** * Unique identifier of the step */ id: string /** * The type of the step (swap, cross, or lifi) */ type: LifiStepType /** * The tool used for this step. E.g. relay */ tool: string /** * The action of the step */ action: LifiAction /** * The details of the tool used for this step. E.g. relay */ toolDetails?: LifiToolDetails /** * The estimation for the step */ estimate?: LifiEstimate /** * Internal steps included in this step */ includedSteps?: LifiInternalStep[] /** * A string containing tracking information about the integrator of the API */ integrator?: string /** * A string containing tracking information about the referrer of the integrator */ referrer?: string /** * An object containing status information about the execution: https://docs.li.fi/api-reference/advanced/populate-a-step-with-transaction-data#body-execution */ execution?: any /** * An ether.js TransactionRequest that can be triggered using a wallet provider */ transactionRequest?: LifiTransactionRequest /** * The unique transaction ID for tracking */ transactionId?: string /** * Aggregation of the underlying gas costs in USD */ gasCostUSD?: string /** * The sending wallet address */ fromAddress?: string /** * The receiving wallet address */ toAddress?: string /** * Whether a chain switch is part of the route */ containsSwitchChain?: boolean } export interface LifiTransactionRequest { chainId?: string data: string from?: string gasLimit?: string gasPrice?: string maxFeePerGas?: string maxPriorityFeePerGas?: string to?: string value?: string } /** * Tool details */ export interface LifiToolDetails { /** * The tool key */ key?: string /** * The tool name */ name?: string /** * The tool logo URL */ logoURI?: string /** * The tool website URL */ webUrl?: string } /** * Action within a step */ export interface LifiAction { /** * The id of the chain where the transfer should start */ fromChainId: string /** * The amount that should be transferred including all decimals */ fromAmount: string /** * The sending token */ fromToken: LifiToken /** * The id of the chain where the transfer should end */ toChainId: string /** * The token that should be transferred to */ toToken: LifiToken /** * The maximum allowed slippage */ slippage?: number /** * The sending wallet address */ fromAddress?: string /** * The receiving wallet address */ toAddress?: string /** * The amount of gas to be consumed on the destination chain */ destinationGasConsumption?: string } /** * Estimate for a step */ export interface LifiEstimate { /** * The tool that is being used for this step */ tool: string /** * The amount that should be transferred including all decimals */ fromAmount: string /** * The estimated resulting amount of the toToken including all decimals */ toAmount: string /** * The minimal outcome of the transfer including all decimals */ toAmountMin: string /** * The contract address for the approval */ approvalAddress: string /** * The time needed to complete the following step (in seconds) */ executionDuration: number /** * The amount that should be transferred in USD equivalent */ fromAmountUSD?: string /** * The estimated resulting amount of the toToken in USD equivalent */ toAmountUSD?: string /** * Fees included in the transfer */ feeCosts?: LifiFeeCost[] /** * Gas costs included in the transfer */ gasCosts?: LifiGasCost[] /** * Arbitrary data that depends on the used tool */ data?: LifiEstimateData } /** * Fee cost information */ export interface LifiFeeCost { /** * Name of the fee */ name: string /** * Percentage of how much fees are taken */ percentage: string /** * The Token in which the fees are taken */ token: LifiToken /** * The amount of fees in USD */ amountUSD: string /** * Whether fee is included into transfer's fromAmount */ included: boolean /** * Description of the fee costs */ description?: string /** * The amount of fees */ amount?: string /** * Fee split details between integrator and Li.Fi */ feeSplit?: LifiFeeSplit } /** * Fee split between integrator and Li.Fi */ export interface LifiFeeSplit { /** * The integrator's portion of the fee */ integratorFee?: string /** * The Li.Fi portion of the fee */ lifiFee?: string } /** * Type of gas cost */ export type LifiGasCostType = 'SUM' | 'APPROVE' | 'SEND' /** * Gas cost information */ export interface LifiGasCost { /** * Can be one of SUM, APPROVE or SEND */ type: LifiGasCostType /** * Amount of the gas cost */ amount: string /** * The used gas token */ token: LifiToken /** * Suggested current standard price for the chain */ price?: string /** * Estimation how much gas will be needed */ estimate?: string /** * Suggested gas limit */ limit?: string /** * Amount of the gas cost in USD */ amountUSD?: string } /** * Estimate data (arbitrary data that depends on the tool) */ export interface LifiEstimateData { /** * Bid information for the transfer */ bid?: LifiBid /** * Bid signature */ bidSignature?: string /** * Gas fee in receiving token */ gasFeeInReceivingToken?: string /** * Total fee */ totalFee?: string /** * Meta transaction relayer fee */ metaTxRelayerFee?: string /** * Router fee */ routerFee?: string } /** * Bid information */ export interface LifiBid { /** * User address */ user?: string /** * Router address */ router?: string /** * Initiator address */ initiator?: string /** * Sending chain ID */ sendingChainId?: string /** * Sending asset ID (token address) */ sendingAssetId?: string /** * Amount to send */ amount?: string /** * Receiving chain ID */ receivingChainId?: string /** * Receiving asset ID (token address) */ receivingAssetId?: string /** * Amount to receive */ amountReceived?: string /** * Receiving address */ receivingAddress?: string /** * Transaction ID */ transactionId?: string /** * Expiry timestamp */ expiry?: number /** * Call data hash */ callDataHash?: string /** * Call to address */ callTo?: string /** * Encrypted call data */ encryptedCallData?: string /** * Sending chain transaction manager address */ sendingChainTxManagerAddress?: string /** * Receiving chain transaction manager address */ receivingChainTxManagerAddress?: string /** * Bid expiry timestamp */ bidExpiry?: number } /** * Internal step (used in includedSteps) */ export interface LifiInternalStep { /** * Unique identifier of the step */ id: string /** * The type of the step (swap, cross, or lifi) */ type: LifiStepType /** * The tool used for this step. E.g. allbridge */ tool: string /** * The details of the tool used for this step. E.g. allbridge */ toolDetails: LifiToolDetails /** * Object describing what happens in a Step */ action: LifiAction /** * An estimate for the current transfer */ estimate: LifiEstimate } /** * Unavailable routes information */ export interface LifiUnavailableRoutes { /** * An object containing information about routes that were intentionally filtered out */ filteredOut?: LifiFilteredRoute[] /** * An object containing information about failed routes */ failed?: LifiFailedRoute[] } /** * Filtered out route */ export interface LifiFilteredRoute { /** * The complete representation of the attempted route (e.g., "100:USDC-hop-137:USDC-137:USDC~137:SUSHI") */ overallPath?: string /** * Our best attempt at describing the failure */ reason?: string } /** * Failed route */ export interface LifiFailedRoute { /** * The complete representation of the attempted route (e.g., "100:USDC-hop-137:USDC-137:USDC~137:SUSHI") */ overallPath?: string /** * An object with all subpaths that generated one or more errors */ subpaths?: Record } /** * Subpath error information */ export interface LifiSubpathError { /** * The type of error that occurred */ errorType?: LifiErrorType /** * The error code */ code?: LifiErrorCode /** * Object describing what happens in a Step */ action?: LifiAction /** * The tool that emitted the error */ tool?: string /** * A human-readable message describing the error */ message?: string } /** * Error type */ export type LifiErrorType = 'NO_QUOTE' /** * Error code */ export type LifiErrorCode = | 'NO_POSSIBLE_ROUTE' | 'INSUFFICIENT_LIQUIDITY' | 'TOOL_TIMEOUT' | 'UNKNOWN_ERROR' | 'RPC_ERROR' | 'AMOUNT_TOO_LOW' | 'AMOUNT_TOO_HIGH' | 'FEES_HIGHER_THAN_AMOUNT' | 'DIFFERENT_RECIPIENT_NOT_SUPPORTED' | 'TOOL_SPECIFIC_ERROR' | 'CANNOT_GUARANTEE_MIN_AMOUNT' | 'RATE_LIMIT_EXCEEDED' /** * Bridging tools supported for status check */ export type LifiStatusBridge = | 'hop' | 'cbridge' | 'celercircle' | 'optimism' | 'polygon' | 'arbitrum' | 'avalanche' | 'across' | 'gnosis' | 'omni' | 'relay' | 'celerim' | 'symbiosis' | 'thorswap' | 'squid' | 'allbridge' | 'mayan' | 'debridge' | 'chainflip' /** * Used to check the status of a cross chain transfer */ export interface LifiStatusRequest { /** * The transaction hash on the sending chain, destination chain or lifi step id (required) */ txHash: string /** * The bridging tool used for the transfer */ bridge?: LifiStatusBridge /** * The sending chain. Can be the chain id or chain key */ fromChain?: string /** * The receiving chain. Can be the chain id or chain key */ toChain?: string } /** * Response containing the status of a cross chain transfer from the Lifi integration */ export interface LifiStatusResponse { data?: LifiStatusData error?: string } export interface LifiStatusData { rawResponse: LifiStatusRawResponse } /** * The current status of the transfer */ export type LifiTransferStatus = | 'NOT_FOUND' | 'INVALID' | 'PENDING' | 'DONE' | 'FAILED' /** * A more specific substatus for PENDING and DONE statuses */ export type LifiTransferSubstatus = | 'WAIT_SOURCE_CONFIRMATIONS' | 'WAIT_DESTINATION_TRANSACTION' | 'BRIDGE_NOT_AVAILABLE' | 'CHAIN_NOT_AVAILABLE' | 'REFUND_IN_PROGRESS' | 'UNKNOWN_ERROR' | 'COMPLETED' | 'PARTIAL' | 'REFUNDED' /** * Contains the current status of a cross chain transfer */ export interface LifiStatusRawResponse { /** * The transaction on the sending chain (required) */ sending: LifiTransactionInfo /** * The transaction on the receiving chain (can be partial with just chainId) */ receiving?: LifiReceivingInfo /** * An array of fee costs for the transaction */ feeCosts?: LifiFeeCost[] /** * The current status of the transfer (required) */ status: LifiTransferStatus /** * A more specific substatus (available for PENDING and DONE statuses) */ substatus?: LifiTransferSubstatus /** * A message that describes the substatus */ substatusMessage?: string /** * The tool used for this transfer (required) */ tool: string /** * The ID of this transfer (NOT a transaction hash) */ transactionId?: string /** * The address of the sender */ fromAddress?: string /** * The address of the receiver */ toAddress?: string /** * The link to the Li.Fi explorer */ lifiExplorerLink?: string /** * The link to the bridge explorer */ bridgeExplorerLink?: string /** * The transaction metadata which includes integrator's string, etc. */ metadata?: LifiMetadata } /** * Receiving chain information (can be partial or full transaction info) */ export interface LifiReceivingInfo { /** * The id of the chain */ chainId?: string /** * Full transaction information (if available) */ txHash?: string txLink?: string token?: LifiToken amount?: string gasToken?: LifiToken gasAmount?: string gasAmountUSD?: string gasPrice?: string gasUsed?: string timestamp?: number value?: string includedSteps?: LifiIncludedSwapStep[] } /** * Transaction information */ export interface LifiTransactionInfo { /** * The hash of the transaction (required) */ txHash: string /** * Link to a block explorer showing the transaction (required) */ txLink: string /** * The amount of the transaction (required) */ amount: string /** * The amount of the transaction in USD */ amountUSD?: string /** * Information about the token (required) */ token: LifiToken /** * The id of the chain (required) */ chainId: string /** * The token in which gas was paid */ gasToken?: LifiToken /** * The amount of the gas that was paid */ gasAmount?: string /** * The amount of the gas that was paid in USD */ gasAmountUSD?: string /** * The price of the gas */ gasPrice?: string /** * The amount of the gas that was used */ gasUsed?: string /** * The transaction timestamp */ timestamp?: number /** * The transaction value */ value?: string /** * An array of swap or protocol steps included in the Li.Fi transaction */ includedSteps?: LifiIncludedSwapStep[] } /** * Included swap or protocol step in the status response */ export interface LifiIncludedSwapStep { /** * The tool used for this step */ tool?: string /** * The details of the tool used for this step (e.g. `1inch` or `feeProtocol`) */ toolDetails?: LifiToolDetails /** * The amount that was sent to the tool */ fromAmount?: string /** * The token that was sent to the tool */ fromToken?: LifiToken /** * The amount that was received from the tool */ toAmount?: string /** * The token that was received from the tool */ toToken?: LifiToken /** * The amount that was sent to the bridge */ bridgedAmount?: string } /** * Transaction metadata */ export interface LifiMetadata { /** * Integrator ID */ integrator?: string } /** * Request for step transaction - type alias for LifiStep */ export type LifiStepTransactionRequest = LifiStep /** * Response containing a step with transaction data from the Lifi integration */ export interface LifiStepTransactionResponse { data?: LifiStepTransactionData error?: string } export interface LifiStepTransactionData { rawResponse: LifiStep } // --- High-level LiFi trade and route/step polling types --- export type LifiTradeAssetProgressStatus = | 'fetching_routes' | 'route_selected' | 'preparing_step' | 'signing' | 'submitted' | 'confirming' | 'lifi_pending' | 'step_done' | 'complete' | 'failed' export interface LifiTradeAssetProgressData { errorMessage?: string routeIndex?: number route?: LifiRoute stepIndex?: number totalSteps?: number step?: LifiStep txHash?: string lifiStatus?: LifiStatusRawResponse transaction?: unknown } export interface LifiTradeAssetParams { fromChain: string toChain: string fromToken: string toToken: string amount: string fromAddress: string toAddress?: string routeOptions?: LifiRoutesRequestOptions routeIndex?: number onProgress?: ( status: LifiTradeAssetProgressStatus, data?: LifiTradeAssetProgressData, ) => void statusPoll?: LifiPollStatusOptions } export interface LifiTradeAssetOptions { signAndSendTransaction?: ( transaction: unknown, network: string, ) => Promise waitForConfirmation?: ( txHash: string, network: string, ) => Promise evmRequestFn?: ( method: string, params: unknown[], network: string, ) => Promise evmPollerOptions?: { pollIntervalMs?: number timeoutMs?: number } } export interface LifiTradeAssetResult { hashes: string[] steps: LifiStep[] route: LifiRoute } export interface LifiPollStatusOptions { everyMs?: number initialDelayMs?: number timeoutMs?: number maxConsecutiveErrors?: number backoff?: { factor: number maxIntervalMs: number } }