import * as _chainflip_utils_chainflip from '@chainflip/utils/chainflip'; import { ChainflipNetwork, AssetAndChain, UncheckedAssetAndChain, ChainflipChain, ChainflipAsset, AssetOfChain, AssetSymbol, AnyChainflipChain, ChainAssetMap, ChainMap } from '@chainflip/utils/chainflip'; export { AssetSymbol as Asset, ChainflipNetwork, UncheckedAssetAndChain, getInternalAsset as getChainflipId } from '@chainflip/utils/chainflip'; import { HexString } from '@chainflip/utils/types'; import { z } from 'zod'; type AccountCreationDepositChannelParams = z.input>; declare const getAccountCreationDepositChannelSchema: (network: ChainflipNetwork) => z.ZodEffects; signer: z.ZodEffects; sigType: z.ZodLiteral<"Eip712">; }, "strip", z.ZodTypeAny, { signature: `0x${string}`; signer: `0x${string}`; sigType: "Eip712"; }, { signature: string; signer: string; sigType: "Eip712"; }>, { signature: `0x${string}`; signer: `0x${string}`; sig_type: "Eip712"; }, { signature: string; signer: string; sigType: "Eip712"; }>; }, "strip", z.ZodTypeAny, { Ethereum: { signature: `0x${string}`; signer: `0x${string}`; sig_type: "Eip712"; }; }, { Ethereum: { signature: string; signer: string; sigType: "Eip712"; }; }>; transactionMetadata: z.ZodEffects, { nonce: number; expiry_block: number; }, { nonce: number; expiryBlock: number; }>; asset: z.ZodEffects, _chainflip_utils_chainflip.AssetAndChain, { asset: string; chain: string; }>; refundAddress: z.ZodString; boostFeeBps: z.ZodDefault>; }, "strip", z.ZodTypeAny, { asset: _chainflip_utils_chainflip.AssetAndChain; signatureData: { Ethereum: { signature: `0x${string}`; signer: `0x${string}`; sig_type: "Eip712"; }; }; transactionMetadata: { nonce: number; expiry_block: number; }; refundAddress: string; boostFeeBps: number; }, { asset: { asset: string; chain: string; }; signatureData: { Ethereum: { signature: string; signer: string; sigType: "Eip712"; }; }; transactionMetadata: { nonce: number; expiryBlock: number; }; refundAddress: string; boostFeeBps?: number | undefined; }>, { asset: _chainflip_utils_chainflip.AssetAndChain; signatureData: { Ethereum: { signature: `0x${string}`; signer: `0x${string}`; sig_type: "Eip712"; }; }; transactionMetadata: { nonce: number; expiry_block: number; }; refundAddress: string; boostFeeBps: number; }, { asset: { asset: string; chain: string; }; signatureData: { Ethereum: { signature: string; signer: string; sigType: "Eip712"; }; }; transactionMetadata: { nonce: number; expiryBlock: number; }; refundAddress: string; boostFeeBps?: number | undefined; }>; declare const ccmParamsSchema: z.ZodEffects]>, `0x${string}`, string>; message: z.ZodEffects, `0x${string}`, string>; ccmAdditionalData: z.ZodOptional, `0x${string}`, string>>; }, "strip", z.ZodTypeAny, { message: `0x${string}`; gasBudget: `0x${string}`; ccmAdditionalData?: `0x${string}` | undefined; }, { message: string; gasBudget: string; ccmAdditionalData?: string | undefined; }>, { gasBudget: `0x${string}`; message: `0x${string}`; ccmAdditionalData: `0x${string}`; }, { message: string; gasBudget: string; ccmAdditionalData?: string | undefined; }>; type CcmParams = z.input; declare const affiliateBroker: z.ZodEffects; commissionBps: z.ZodNumber; }, "strip", z.ZodTypeAny, { account: string; commissionBps: number; }, { account: string; commissionBps: number; }>, { account: string; bps: number; }, { account: string; commissionBps: number; }>; type AffiliateBroker = z.input; declare const dcaParams: z.ZodObject<{ numberOfChunks: z.ZodNumber; chunkIntervalBlocks: z.ZodNumber; }, "strip", z.ZodTypeAny, { numberOfChunks: number; chunkIntervalBlocks: number; }, { numberOfChunks: number; chunkIntervalBlocks: number; }>; type DcaParams = z.input; declare const fillOrKillParams: z.ZodObject<{ retryDurationBlocks: z.ZodNumber; refundAddress: z.ZodString; minPriceX128: z.ZodString; maxOraclePriceSlippage: z.ZodEffects>, number | null, number | null | undefined>; refundCcmMetadata: z.ZodDefault]>, `0x${string}`, string>; message: z.ZodEffects, `0x${string}`, string>; ccmAdditionalData: z.ZodOptional, `0x${string}`, string>>; }, "strip", z.ZodTypeAny, { message: `0x${string}`; gasBudget: `0x${string}`; ccmAdditionalData?: `0x${string}` | undefined; }, { message: string; gasBudget: string; ccmAdditionalData?: string | undefined; }>, { gasBudget: `0x${string}`; message: `0x${string}`; ccmAdditionalData: `0x${string}`; }, { message: string; gasBudget: string; ccmAdditionalData?: string | undefined; }>>>>>; }, "strip", z.ZodTypeAny, { refundAddress: string; retryDurationBlocks: number; minPriceX128: string; maxOraclePriceSlippage: number | null; refundCcmMetadata: { gasBudget: `0x${string}`; message: `0x${string}`; ccmAdditionalData: `0x${string}`; } | null; }, { refundAddress: string; retryDurationBlocks: number; minPriceX128: string; maxOraclePriceSlippage?: number | null | undefined; refundCcmMetadata?: { message: string; gasBudget: string; ccmAdditionalData?: string | undefined; } | null | undefined; }>; type FillOrKillParamsX128 = z.input; type FillOrKillParamsWithMinPrice = Omit & { minPrice: string; }; interface Fee extends UncheckedAssetAndChain { type: T; amount: string; } type SwapFee = Fee<'NETWORK' | 'INGRESS' | 'EGRESS' | 'BROKER' | 'BOOST' | 'REFUND'>; type PoolFee = Fee<'LIQUIDITY'>; type PaidFee = SwapFee | PoolFee; type PoolInfo = { baseAsset: AssetAndChain; quoteAsset: AssetAndChain; fee: Omit; }; type BoostedQuoteDetails = { estimatedBoostFeeBps: number; maxBoostFeeBps: number; }; interface BaseQuoteDetails { srcAsset: AssetAndChain; destAsset: AssetAndChain; isVaultSwap: boolean; isOnChain: boolean; ccmParams?: { gasBudget: string; messageLengthBytes: number; }; depositAmount: string; intermediateAmount?: string; egressAmount: string; includedFees: SwapFee[]; poolInfo: PoolInfo[]; lowLiquidityWarning: boolean | undefined; estimatedDurationSeconds: number; estimatedDurationsSeconds: { deposit: number; swap: number; egress: number; }; estimatedPrice: string; recommendedSlippageTolerancePercent: number; recommendedRetryDurationMinutes: number; recommendedLivePriceSlippageTolerancePercent: number | undefined; } type WithBoostQuote = Omit & BoostedQuoteDetails; interface RegularQuote extends BaseQuoteDetails { type: 'REGULAR'; boostQuote?: WithBoostQuote; } interface DCAQuote extends BaseQuoteDetails { type: 'DCA'; dcaParams: DcaParams; boostQuote?: WithBoostQuote; } type Quote = RegularQuote | DCAQuote; type DCABoostQuote = NonNullable; type RegularBoostQuote = NonNullable; type BoostQuote = RegularBoostQuote | DCABoostQuote; type FillOrKillParams = { livePriceSlippageTolerancePercent?: string | number; refundAddress: string; refundCcmMetadata?: CcmParams | null; } & ({ minPrice: string; retryDurationBlocks: number; } | { minPrice: string; retryDurationMinutes: number; } | { slippageTolerancePercent: string | number; retryDurationBlocks: number; } | { slippageTolerancePercent: string | number; retryDurationMinutes: number; }); interface ChainData { chain: ChainflipChain; name: string; evmChainId: number | undefined; isMainnet: boolean; requiredBlockConfirmations: number | undefined; maxRetryDurationBlocks: number | undefined; } type AssetData = { [C in ChainflipChain]: { chainflipId: ChainflipAsset; asset: AssetOfChain; chain: C; contractAddress: string | undefined; decimals: number; name: string; symbol: AssetSymbol; isMainnet: boolean; minimumSwapAmount: string; maximumSwapAmount: string | null; minimumEgressAmount: string; }; }[ChainflipChain]; interface ChainsAndAssets { srcChain: ChainflipChain; srcAsset: AssetSymbol; destChain: ChainflipChain; destAsset: AssetSymbol; } interface QuoteRequest extends ChainsAndAssets { amount: string; brokerCommissionBps?: number; affiliateBrokers?: AffiliateBroker[]; isVaultSwap?: boolean; isOnChain?: boolean; ccmParams?: { gasBudget: string; messageLengthBytes: number; }; /** * Chainflip broker SS58 address attributed to this quote. * Overrides the SDK-level `brokerAccount` option for this request. */ brokerAccount?: `cF${string}`; } interface QuoteResponseV2 extends QuoteRequest { quotes: Quote[]; } type FillOrKillParamsWithSlippage = Omit & { slippageTolerancePercent: string | number; }; interface SwapStatusRequest { id: string; } type BoostPoolDepth = { feeTierBps: number; availableAmount: bigint; asset: AssetSymbol; chain: ChainflipChain; poolType: 'LEGACY_BOOST' | 'SUPPLY'; }; type ChunkFailureReason = 'PriceImpactLimit' | 'MinPriceViolation' | 'OraclePriceSlippageExceeded' | 'OraclePriceStale' | 'PredecessorSwapFailure' | 'SafeModeActive'; interface Failure { failedAt: number; failedBlockIndex: string; mode: string; reason: { code: string; message: string; }; } interface Boost { maxBoostFeeBps: number; effectiveBoostFeeBps: number | undefined; boostedAt: number | undefined; boostedBlockIndex: string | undefined; skippedAt: number | undefined; skippedBlockIndex: string | undefined; } interface Broker { account: string; commissionBps: string; } interface DepositChannelFields { id: string; createdAt: number; depositAddress: string; srcChainExpiryBlock: string; estimatedExpiryTime: number; expectedDepositAmount: string | undefined; isExpired: boolean; openedThroughBackend: boolean; dcaParams: DcaParams | undefined; } interface DepositFields { amount: string; txRef: string | undefined; txConfirmations: number | undefined; witnessedAt: number | undefined; witnessedBlockIndex: string | undefined; failure: Failure | undefined; failedAt: number | undefined; failedBlockIndex: string | undefined; } type RescheduledInfo = { latestSwapRescheduledAt: number | undefined; latestSwapRescheduledBlockIndex: string | undefined; latestSwapRescheduledReason: ChunkFailureReason | undefined; }; type ChunkInfo = { inputAmount: string; intermediateAmount: string | undefined; outputAmount: string | undefined; scheduledAt: number; scheduledBlockIndex: string; executedAt: number | undefined; executedBlockIndex: string | undefined; retryCount: number; abortedAt: number | undefined; abortedBlockIndex: string | undefined; abortedReason: ChunkFailureReason | undefined; } & RescheduledInfo; type PickRequired = { [K in keyof T as undefined extends T[K] ? never : K]: T[K]; } & {}; interface SwapFields { originalInputAmount: string; remainingInputAmount: string; swappedInputAmount: string; swappedIntermediateAmount: string; swappedOutputAmount: string; livePriceExecutionDeltaPercentage: number | undefined; regular: ChunkInfo | undefined; dca: { lastExecutedChunk: ChunkInfo | null; currentChunk: (PickRequired & RescheduledInfo) | null; executedChunks: number; remainingChunks: number; } | undefined; /** * Represents details of an on-chain transaction associated with the swap. * - `accountId`: The account identifier of the LP for the on-chain swap. * - `outputAmount`: The amount of output tokens received from the swap. * This is `undefined` if the swap has not been executed or it was fully * refunded. * - `refundAmount`: The amount of input tokens refunded due to a fully or * partially refunded swap. This is `undefined` if no refund occurred. */ onChain: { /** The account identifier of the LP for the on-chain swap */ accountId: string; /** * The amount of output tokens received from the swap. This is * `undefined` if the swap has not been executed or it was fully * refunded. */ outputAmount: string | undefined; /** * The amount of input tokens refunded due to a fully or partially * refunded swap. This is `undefined` if no refund occurred. */ refundAmount: string | undefined; } | undefined; } interface EgressFields { amount: string; scheduledAt: number | undefined; scheduledBlockIndex: string | undefined; txRef: string | undefined; witnessedAt: number | undefined; witnessedBlockIndex: string | undefined; failure: Failure | undefined; failedAt: number | undefined; failedBlockIndex: string | undefined; transactionPayload: { contract: `0x${string}`; value: string; chainId: string; data: `0x${string}`; } | undefined; } interface SwapStatusResponseCommonFields { srcChain: AnyChainflipChain; srcAsset: AssetSymbol; destChain: AnyChainflipChain; destAsset: AssetSymbol; swapId: string; destAddress: string; depositChannel: DepositChannelFields | undefined; ccmParams: CcmParams | undefined; fillOrKillParams: FillOrKillParamsWithMinPrice | undefined; dcaParams: DcaParams | undefined; boost: Boost | undefined; estimatedDurationSeconds: number | null | undefined; estimatedDurationsSeconds: { deposit: number; swap: number; egress: number; }; srcChainRequiredBlockConfirmations: number | null; brokers: Broker[]; fees: PaidFee[]; lastStatechainUpdateAt: number | undefined; } interface Waiting extends SwapStatusResponseCommonFields { depositChannel: DepositChannelFields; } interface Receiving extends SwapStatusResponseCommonFields { deposit: DepositFields; } interface Swapping extends Receiving { swap: SwapFields; } interface Sending extends Receiving { swap: SwapFields; swapEgress: EgressFields | undefined; refundEgress: EgressFields | undefined; fallbackEgress: EgressFields | undefined; } type SwapStatusResponseV2 = ({ state: 'WAITING'; } & Waiting) | ({ state: 'RECEIVING'; } & Receiving) | ({ state: 'SWAPPING'; } & Swapping) | ({ state: 'SENDING'; } & Sending) | ({ state: 'SENT'; } & Sending) | ({ state: 'COMPLETED'; } & Sending) | ({ state: 'FAILED'; } & Sending); interface DepositAddressRequestV2 { quote: Quote | BoostQuote; srcAddress?: string; destAddress: string; fillOrKillParams: FillOrKillParams; affiliateBrokers?: { account: `cF${string}` | `0x${string}`; commissionBps: number; }[]; ccmParams?: CcmParams; brokerCommissionBps?: number; } interface DepositAddressResponseV2 extends Omit { destAddress: string; ccmParams?: CcmParams; maxBoostFeeBps?: number; srcAddress?: string; dcaParams?: DcaParams; fillOrKillParams: FillOrKillParams; depositChannelId: string; depositAddress: string; brokerCommissionBps: number; affiliateBrokers: AffiliateBroker[]; depositChannelExpiryBlock: bigint; estimatedDepositChannelExpiryTime: number | undefined; channelOpeningFee: bigint; } interface VaultSwapRequest { quote: Quote | BoostQuote; srcAddress?: string; destAddress: string; fillOrKillParams: FillOrKillParams; affiliateBrokers?: { account: `cF${string}` | `0x${string}`; commissionBps: number; }[]; ccmParams?: CcmParams; brokerAccount?: `cF${string}`; brokerCommissionBps?: number; extraParams?: { seed?: `0x${string}`; }; } type VaultSwapResponse = { chain: 'Bitcoin'; nulldataPayload: string; depositAddress: string; } | { chain: 'Ethereum' | 'Arbitrum'; calldata: string; value: bigint; to: string; sourceTokenAddress?: string | undefined; } | { chain: 'Tron'; calldata: string; value: bigint; to: string; note: string; sourceTokenAddress?: string; } | { chain: 'Solana'; programId: string; accounts: { pubkey: string; isSigner: boolean; isWritable: boolean; }[]; data: string; }; interface EncodeCfParametersRequest { quote: Quote | BoostQuote; srcAddress?: string; destAddress: string; fillOrKillParams: FillOrKillParams; affiliateBrokers?: { account: `cF${string}` | `0x${string}`; commissionBps: number; }[]; ccmParams?: CcmParams; brokerAccount?: `cF${string}`; brokerCommissionBps?: number; } type RequestOptions = { signal?: AbortSignal; }; type SwapSDKOptions = { network?: ChainflipNetwork; backendUrl?: string; broker?: { url: string; }; rpcUrl?: string; enabledFeatures?: { dcaV2?: boolean; }; /** * Chainflip broker SS58 address attributed to quote requests. * Sent on every /v2/quote request unless overridden per-call. */ brokerAccount?: `cF${string}`; }; type AssetState = 'all' | 'deposit' | 'destination' | 'depositChannel' | 'vaultSwap'; declare class SwapSDK { private readonly options; private readonly rpcConfig; private readonly apiClient; private cache; private dcaV2Enabled; constructor(options?: SwapSDKOptions); getChains(sourceChain?: ChainflipChain, type?: AssetState): Promise; private getStateChainEnvironment; private getSupportedAssets; private getBtcSupplyPoolDepth; private getBoostPoolsDepth; getAssets(chain?: ChainflipChain, type?: AssetState): Promise; protected shouldTakeCommission(): boolean; private getCommissionBps; getQuoteV2(quoteRequest: QuoteRequest, options?: RequestOptions): Promise; getStatusV2(swapStatusRequest: SwapStatusRequest, options?: RequestOptions): Promise; private validateSwapAmount; getSwapLimits(): Promise<{ minimumSwapAmounts: ChainAssetMap; maximumSwapAmounts: ChainAssetMap; }>; getRequiredBlockConfirmations(): Promise>; getChannelOpeningFees(): Promise>; getBoostLiquidity(params?: { /** @deprecated DEPRECATED(2.2): Only value supported moving forward is 5 bps */ feeTierBps?: number; } | ({ /** @deprecated DEPRECATED(2.2): Only value supported moving forward is 5 bps */ feeTierBps?: number; } & UncheckedAssetAndChain)): Promise; requestDepositAddressV2({ quote, srcAddress, destAddress, fillOrKillParams: inputFoKParams, affiliateBrokers: affiliates, ccmParams, brokerCommissionBps: brokerCommissionBpsParam, }: DepositAddressRequestV2): Promise; encodeVaultSwapData({ quote, srcAddress, destAddress, fillOrKillParams: inputFoKParams, affiliateBrokers: affiliates, ccmParams, brokerAccount, brokerCommissionBps: brokerCommissionBpsParam, extraParams, }: VaultSwapRequest): Promise; encodeCfParameters({ quote, srcAddress, destAddress, fillOrKillParams, affiliateBrokers: affiliates, ccmParams, brokerAccount, brokerCommissionBps, }: EncodeCfParametersRequest): Promise; checkBoostEnabled(): Promise; requestAccountCreationDepositAddress(asset: ChainflipAsset, refundAddress: string, signatureData: AccountCreationDepositChannelParams['signatureData'], transactionMetadata: AccountCreationDepositChannelParams['transactionMetadata'], boostFeeBps?: number): Promise<{ depositAddress: string; brokerCommissionBps: number; id: string; maxBoostFeeBps: number; issuedBlock: number; srcChainExpiryBlock: string; channelOpeningFee: string; estimatedExpiryTime?: number | undefined; }>; } /** * This file provides backwards compatibility for exports from before we started * moving common stuff to the toolkit */ declare const ChainflipNetworks: { mainnet: "mainnet"; backspin: "backspin"; sisyphos: "sisyphos"; perseverance: "perseverance"; }; declare const InternalAssets: { Usdc: "Usdc"; Usdt: "Usdt"; Wbtc: "Wbtc"; Flip: "Flip"; Eth: "Eth"; Btc: "Btc"; ArbUsdc: "ArbUsdc"; ArbUsdt: "ArbUsdt"; ArbEth: "ArbEth"; Sol: "Sol"; SolUsdc: "SolUsdc"; SolUsdt: "SolUsdt"; Trx: "Trx"; TrxUsdt: "TrxUsdt"; HubDot: "HubDot"; HubUsdt: "HubUsdt"; HubUsdc: "HubUsdc"; }; declare const Chains: { Ethereum: "Ethereum"; Arbitrum: "Arbitrum"; Tron: "Tron"; Bitcoin: "Bitcoin"; Solana: "Solana"; Assethub: "Assethub"; }; declare const Assets: { BTC: "BTC"; DOT: "DOT"; ETH: "ETH"; FLIP: "FLIP"; SOL: "SOL"; USDC: "USDC"; USDT: "USDT"; WBTC: "WBTC"; TRX: "TRX"; }; type Chain = ChainflipChain; type InternalAsset = ChainflipAsset; export { type AssetData, Assets, type BoostPoolDepth, type BoostQuote, type Chain, type ChainData, type InternalAsset as ChainflipId, InternalAssets as ChainflipIds, ChainflipNetworks, Chains, type ChainsAndAssets, type DCABoostQuote, type DCAQuote, type DepositAddressRequestV2, type DepositAddressResponseV2, type EncodeCfParametersRequest, type FillOrKillParamsWithSlippage, type Quote, type QuoteRequest, type QuoteResponseV2, type RegularQuote, SwapSDK, type SwapSDKOptions, type SwapStatusRequest, type SwapStatusResponseV2, type VaultSwapRequest, type VaultSwapResponse };