import { IAsyncStorage } from './storage'; import { SupportedChain } from './types'; import { RequestSupportedAssetsForChainArgs, SupportedAssetsArgs } from './skip-api'; export type LifiSupportedAssetsArgs = SupportedAssetsArgs & { includeUTXOAssets?: boolean; }; export type RequestLifiSupportedAssetsForChainArgs = RequestSupportedAssetsForChainArgs & { includeUTXOAssets?: boolean; }; export declare enum LifiChainId { solana = "1151111081099710", bitcoin = "20000000000001" } export type LifiRouteRequest = { source_wallet_address?: string; destination_wallet_address?: string; source_asset_denom: string; source_asset_chain_id: string; dest_asset_denom: string; dest_asset_chain_id: string; amount_in: string; cumulative_affiliate_fee_bps?: string; allow_unsafe?: boolean; experimental_features?: string[]; allow_multi_tx?: boolean; smart_relay?: boolean; integrator?: string; fee_percentage?: number; slippage?: number; max_price_impact?: number; order?: 'CHEAPEST' | 'FASTEST'; }; /** * Route response of LI.FI API */ interface Token { address: string; chainId: number; symbol: string; decimals: number; name: string; coinKey?: string; logoURI?: string; priceUSD?: string; } interface FeeCost { name: string; description?: string; token: Token; amount: string; amountUSD: string; percentage: string; included: boolean; } interface GasCost { type: 'SEND' | 'APPROVE' | 'SUM'; price: string; estimate: string; limit: string; amount: string; amountUSD: string; token: Token; } interface Action { fromChainId: number; fromAmount: string; fromToken: Token; toChainId: number; toToken: Token; slippage?: number; fromAddress?: string; toAddress?: string; } export interface Estimate { tool: string; approvalAddress: string; fromAmount: string; fromAmountUSD?: string; toAmount: string; toAmountMin: string; toAmountUSD?: string; feeCosts?: FeeCost[]; gasCosts?: GasCost[]; executionDuration: number; integrator?: string; includedSteps?: LifiStepRequest[]; referrer?: string; execution?: string; transactionRequest?: string; } interface ToolDetails { key: string; name: string; logoURI?: string; } export interface IncludedStep { id: string; type: 'swap' | 'cross' | 'lifi'; tool: string; toolDetails: ToolDetails; action: Action; estimate: Estimate; includedSteps: IncludedStep[]; integrator?: string; referrer?: string; } export interface LifiRouteResponse { id: string; fromChainId: number; fromAmountUSD: string; fromAmount: string; fromToken: Token; toChainId: number; toAmountUSD: string; toAmount: string; toAmountMin: string; toToken: Token; gasCostUSD: string; steps: IncludedStep[]; does_swap: boolean; swap_price_impact_percent?: string; slippage?: string; } export type LifiTrackTransactionRequest = { tx_hash: string; }; export interface LifiTransactionDetails { txHash: string; txLink: string; amount: string; token: Token; chainId: number; gasPrice: string; gasUsed: string; gasToken: Token; gasAmount: string; gasAmountUSD: string; amountUSD: string; timestamp: number; value?: string; } export type LifiTransactionStatus = 'NOT_FOUND' | 'INVALID' | 'PENDING' | 'DONE' | 'FAILED'; export interface LifiTrackerResponse { transactionId: string; sending: LifiTransactionDetails; receiving: LifiTransactionDetails; lifiExplorerLink: string; fromAddress: string; toAddress: string; tool: string; status: LifiTransactionStatus; substatus?: string; substatusMessage?: string; metadata: { integrator: string; }; bridgeExplorerLink?: string; } export type LifiSupportedAsset = { chainId: string; originDenom: string; originChainId: string; denom: string; name: string; symbol: string; decimals: number; logoUri: string; coingeckoId: string | undefined; tokenContract?: string; trace: string; isCw20: boolean | undefined; priceUSD?: string; }; export type NativeToken = { address: string; decimals: number; symbol: string; chainId: number; coinKey?: string; name: string; }; export type LifiAssetJSON = { chainId: number; address: string; symbol: string; name: string; decimals: number; priceUSD?: string; coinKey?: string; logoURI?: string; }; export interface LifiStepRequest { id: string; type: string; tool: string; toolDetails?: { key: string; name: string; logoURI?: string; }; action: Action; estimate: Estimate; } export type TransactionRequestType = { data: string; to: string; value: bigint; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; gasLimit: string; from?: string; nonce?: number; chainId: number | string; tokenContract: string; fromAmount: string; }; export declare const LIFI_API_BASE_URL = "https://li.quest/"; export declare const LIFI_API_ADV_URL = "https://li.quest/v1/advanced/"; /** * `LifiAPI` class provides a range of methods to interact with the LI.FI API. * It includes functionalities such as retrieving supported chains and assets, * fetching routing information for token transfers, submitting transactions, * and tracking their status. This class acts as an interface for applications * to interact with the LI.FI API. * @example - https://apidocs.li.fi/reference */ export declare class LifiAPI { private static ky; private static advKy; private static supportedChainsCache; static isCacheInitialized(): boolean; static initializeCache(storage: IAsyncStorage): void; /** * Retrieves the list of supported chains from the LI.FI API. * @returns A Promise that resolves to an object containing either a list of supported chains * on success, or an error message on failure. See {@link SupportedChain[]}. * @note - some return values have values in order for maintaining type unity across agregators */ static getSupportedChains(options?: { includeEVM?: boolean; includeTestnets?: boolean; cached?: boolean; includeSVM?: boolean; includeUTXO?: boolean; }): Promise<{ success: false; error: string; } | { success: true; chains: SupportedChain[]; }>; /** * Retrieves the supported assets for a specified chain. * @param args - The arguments for the request including chainId and nativeOnly flag. See {@link RequestSupportedAssetsForChainArgs}. * @returns A promise that resolves to an object containing the supported assets for the given chain, * or an error message if unsuccessful. See {@link LifiSupportedAsset}. * * @note - Field values returned have been adjusted so we have type unity across aggregators */ static getSupportedAssets(args: LifiSupportedAssetsArgs): Promise<{ success: false; error: string; } | { success: true; assets: Record; }>; /** * Retrieves the supported assets for a specified chain. * @param args - The arguments for the request including chainId and nativeOnly flag. See {@link RequestSupportedAssetsForChainArgs}. * @returns A promise that resolves to an object containing the supported assets for the given chain, * or an error message if unsuccessful. See {@link LifiSupportedAsset}. */ static getSupportedAssetsForChain(args: RequestLifiSupportedAssetsForChainArgs): Promise<{ success: false; error: string; } | { success: true; assets: LifiSupportedAsset[]; }>; /** * Fetches quote of available routes for a given token transfer request - provided the source and destinatiopn asset details. * @param args - The arguments required to calculate the route, including source and destination asset details. See {@link LifiRouteRequest}. * @returns A promise that resolves to an object containing the route details {@link RouteResponse} or an error message. * * @note The `source_wallet_address` field is required as lifi returns a transactionRequest which can directly be processed by the wallet, instead * of us manually creating a message type. When user does not have a wallet connected this helps in fetching route quotes. */ static getRoute(args: LifiRouteRequest): Promise<{ success: false; error: string; } | { success: true; route: LifiRouteResponse; }>; /** * This method fetches step data for each transaction step/leg. `transactionRequest` represents the message for authz of txn leg. * @param args {@link LifiStepRequest} * @returns A promise that resolves to an object containing the transaction request {@link TransactionRequestType} or an error message. */ static getStepData(args: IncludedStep): Promise<{ success: false; error: string; } | { success: true; transactionRequest: TransactionRequestType; estimate: Estimate; }>; /** * * @param args {@link TrackTransactionRequest}, only transaction has is required * @returns A promise that resolves to an object containing the transaction status {@link LifiTrackerResponse} or an error message. */ static trackTransaction(args: LifiTrackTransactionRequest): Promise<{ success: true; response: LifiTrackerResponse; } | { success: false; error: string; }>; } export {};