import { CloverDexType, RouterType } from '../consts'; import { IRouterContext } from './RouterContext'; import { Account, Address, Blockhash, FullySignedTransaction, Instruction, Rpc, Signature, SolanaRpcApi, Transaction } from '@solana/kit'; import BN from 'bn.js'; import { AddressLookupTable } from '@solana-program/address-lookup-table'; export interface Router { readonly routerType: RouterType; readonly connection: Rpc; route: (params: RouteParams, ctx: IRouterContext) => Promise; quote: (params: QuoteParams) => Promise; } type RouteOutputBase = { instructions?: Ixs; /** @deprecated Use `instructions` instead */ ixsRouter?: Instruction[]; amountsExactIn: AmountExactIn; amountsExactOut: AmountExactOut; swapType: SwapType; responseTimeGetQuoteMs: number; responseTimeSwapIxsMs: number; routerType: RouterType; priceImpactBps?: number; simulatedPriceImpactBps?: number; guaranteedPriceImpactBps?: number; priceDifferenceFromPriceSourceBps?: number; simulatedPriceDifferenceFromPriceSourceBps?: number; guaranteedPriceDifferenceFromPriceSourceBps?: number; expiryTime: number; perReferenceId?: string; birdeyeTokenInPriceInSol?: number; birdeyeTokenOutPriceInSol?: number; spotPriceTokenInAmount?: BN; spotPriceTokenOutAmount?: BN; inputMintProgramOwner?: Address; outputMintProgramOwner?: Address; inputTokenDecimals?: number; outputTokenDecimals?: number; jupRequestId?: string; cloverDexType?: CloverDexType; skipLimoLogsForRoute?: boolean; simulationResult?: RouteSimulationResult; requestedMaxAccounts?: number; }; type WithTransaction = { transaction: Transaction; lookupTableAccounts: Account[]; }; type WithoutTransaction = { transaction?: never; lookupTableAccounts?: Account[]; }; type RouteOutputUnion = WithTransaction | WithoutTransaction; export type RouterOutput = RouteOutputBase & RouteOutputUnion; export type RouteOutput = RouteOutputBase & RouteOutputUnion; export type RouterInstructionsBase = { createInAtaIxs: Instruction[]; createOutAtaIxs: Instruction[]; wrapSolIxs: Instruction[]; swapIxs: Instruction[]; unwrapSolIxs: Instruction[]; }; export type LimoRouteInstructions = { limoLogsStartIxs: Instruction[]; limoLedgerStartIxs: Instruction[]; limoLogsEndIxs: Instruction[]; limoLedgerEndIxs: Instruction[]; }; export type RouterInstructions = RouterInstructionsBase & Partial; export type RouteInstructions = RouterInstructionsBase & LimoRouteInstructions; export type AmountExactIn = { amountIn: BN; amountOutGuaranteed: BN; amountOut: BN; amountOutSimulated?: BN; }; export type AmountExactOut = { amountOut: BN; amountInGuaranteed: BN; amountIn: BN; amountInSimulated?: BN; }; export type SwapType = 'exactIn' | 'exactOut'; export type RouteSimulationResult = { /** * Indicates if the simulation was successful */ success: boolean; /** * Cause of the failure if `success` is false */ errorReason?: SimulationErrorReason; /** * Logs generated during the simulation */ logs?: string[]; /** * Timestamp of the simulation */ simulationTimestamp?: number; }; export declare enum SimulationErrorReason { Unknown = "UNKNOWN", SlippageExceeded = "SLIPPAGE_EXCEEDED", TooManyAccountLocks = "TOO_MANY_ACCOUNT_LOCKS", TransactionTooLarge = "TRANSACTION_TOO_LARGE" } export type RouteParams = { tokenIn: Address; tokenOut: Address; amount: BN; swapType: SwapType; executor: Address; maxSlippageBps: number; referrerPda?: Address; includeSetupIxs?: boolean; wrapAndUnwrapSol?: boolean; routerTypes?: RouterType[]; includeLimoLogs?: boolean; includeRfq?: boolean; /** * Base per-router timeout in milliseconds. * Clover routes may use up to 4x this budget internally while composing inner routes. */ timeoutMs?: number; atLeastOneNoMoreThanTimeoutMS?: number; withSimulation?: boolean; /** * Optional flag to filter out failed simulations from the results * Only applicable if `withSimulation` is true */ filterFailedSimulations?: boolean; destinationTokenAccount?: Address; preferredMaxAccounts?: number | number[]; requestPriceImpact?: boolean; perMinimumQuoteLifetimeSeconds?: number; assertSwapBalances?: boolean; overrideAssertMaxInputAmountChange?: BN; overrideAssertMinOutputAmountChange?: BN; simulateWithMockInputAmount?: boolean; simulateWithTopHolder?: boolean; }; export type RouteOrQuoteParams = { tokenIn: Address; tokenOut: Address; amount: BN; swapType: SwapType; executor?: Address; maxSlippageBps: number; referrerPda?: Address; includeSetupIxs?: boolean; wrapAndUnwrapSol?: boolean; routerTypes?: RouterType[]; includeLimoLogs?: boolean; includeRfq?: boolean; /** * Base per-router timeout in milliseconds. * Clover routes may use up to 4x this budget internally while composing inner routes. */ timeoutMs?: number; atLeastOneNoMoreThanTimeoutMS?: number; withSimulation?: boolean; filterFailedSimulations?: boolean; destinationTokenAccount?: Address; preferredMaxAccounts?: number | number[]; requestPriceImpact?: boolean; perMinimumQuoteLifetimeSeconds?: number; assertSwapBalances?: boolean; overrideAssertMaxInputAmountChange?: BN; overrideAssertMinOutputAmountChange?: BN; simulateWithMockInputAmount?: boolean; simulateWithTopHolder?: boolean; }; export declare function extractPreferredMaxAccounts(value: number | number[] | undefined): number | undefined; export declare function asPreferredMaxAccountsArray(value: number | number[] | undefined): number[] | undefined; export declare const SOL_MINT_INFO: MintInfo; export type MintInfo = { tokenProgramId: Address; decimals: number; }; export type QuoteParams = { tokenIn: Address; tokenOut: Address; amount: BN; swapType: SwapType; maxSlippageBps: number; routerTypes?: RouterType[]; includeRfq?: boolean; /** * Base per-router timeout in milliseconds. * Clover routes may use up to 4x this budget internally while composing inner routes. */ timeoutMs?: number; atLeastOneNoMoreThanTimeoutMS?: number; preferredMaxAccounts?: number | number[]; executor?: Address; requestPriceImpact?: boolean; }; export type QuoteParamsSerialized = { tokenIn: string; tokenOut: string; amount: string; swapType: string; maxSlippageBps: number; routerTypes?: string[]; includeRfq?: string; /** * Base per-router timeout in milliseconds. * Clover routes may use up to 4x this budget internally while composing inner routes. */ timeoutMs?: number; atLeastOneNoMoreThanTimeoutMS?: number; preferredMaxAccounts?: number | number[]; requestPriceImpact?: boolean; executor?: string; }; export declare function getQuoteParamsKeys(): (keyof QuoteParams)[]; export declare function getRouteParamsKeys(): (keyof RouteParams)[]; export declare function getRouteOutputSerializedKeys(): (keyof RouteOutputSerialized)[]; export type RouteParamsSerialized = { tokenIn: string; tokenOut: string; amount: string; swapType: string; executor: string; maxSlippageBps: number; referrerPda?: string; includeSetupIxs?: string; wrapAndUnwrapSol?: string; routerTypes?: string[]; includeLimoLogs?: string; includeRfq?: string; /** * Base per-router timeout in milliseconds. * Clover routes may use up to 4x this budget internally while composing inner routes. */ timeoutMs?: number; atLeastOneNoMoreThanTimeoutMS?: number; withSimulation?: string; /** * Optional flag to filter out failed simulations from the results * Only applicable if `withSimulation` is true */ filterFailedSimulations?: string; destinationTokenAccount?: string; preferredMaxAccounts?: number | number[]; requestPriceImpact?: string; perMinimumQuoteLifetimeSeconds?: number; assertSwapBalances?: string; overrideAssertMaxInputAmountChange?: string; overrideAssertMinOutputAmountChange?: string; simulateWithMockInputAmount?: string; simulateWithTopHolder?: string; }; type RouteOutputSerializedBase = { instructions?: RouteInstructionsSerialized; /** * @deprecated Use `instructions` instead */ ixsRouterBs58?: InstructionSerialized[]; amountsExactIn: AmountExactInSerialized; amountsExactOut: AmountExactOutSerialized; swapType: string; responseTimeGetQuoteMs: number; responseTimeSwapIxsMs: number; priceImpactBps?: number; simulatedPriceImpactBps?: number; guaranteedPriceImpactBps?: number; priceDifferenceFromPriceSourceBps?: number; simulatedPriceDifferenceFromPriceSourceBps?: number; guaranteedPriceDifferenceFromPriceSourceBps?: number; routerType: string; expiryTime: number; perReferenceId?: string; birdeyeTokenInPriceInSol?: number; birdeyeTokenOutPriceInSol?: number; spotPriceTokenInAmount?: string; spotPriceTokenOutAmount?: string; inputMintProgramOwner?: string; outputMintProgramOwner?: string; inputTokenDecimals?: number; outputTokenDecimals?: number; jupRequestId?: string; withSimulation?: string; cloverDexType?: CloverDexType; skipLimoLogsForRoute?: string; /** * Optional simulation result object that contains the success status, error message, and logs */ simulationResult?: RouteSimulationResultSerialized; requestedMaxAccounts?: number; }; type WithTransactionSerialized = { transactionBs58: string; lookupTableAccountsBs58: AddressLookupTableAccountSerialized[]; }; type WithoutTransactionSerialized = { transactionBs58?: never; lookupTableAccountsBs58?: AddressLookupTableAccountSerialized[]; }; export type RouteOutputSerialized = RouteOutputSerializedBase & (WithTransactionSerialized | WithoutTransactionSerialized); export type AmountExactInSerialized = { amountIn: string; amountOutGuaranteed: string; amountOut: string; amountOutSimulated?: string; }; export type AmountExactOutSerialized = { amountOut: string; amountInGuaranteed: string; amountIn: string; amountInSimulated?: string; }; export type ExecutePerRouteParams = { userSignature: string; perReferenceId: string; userWallet?: string; quoteExpiryMs?: number; }; export type RouteInstructionsSerialized = { createInAtaIxs: InstructionSerialized[]; createOutAtaIxs: InstructionSerialized[]; wrapSolIxs: InstructionSerialized[]; limoLogsStartIxs: InstructionSerialized[]; limoLedgerStartIxs: InstructionSerialized[]; swapIxs: InstructionSerialized[]; limoLedgerEndIxs: InstructionSerialized[]; limoLogsEndIxs: InstructionSerialized[]; unwrapSolIxs: InstructionSerialized[]; }; export type InstructionSerialized = { programId: string; data: string; keys: Array<{ pubkey: string; isSigner: boolean; isWritable: boolean; }>; }; export type AddressLookupTableStateSerialized = { deactivationSlot: string; lastExtendedSlot: number; lastExtendedSlotStartIndex: number; authority?: string; addresses: string[]; }; export type AddressLookupTableAccountSerialized = { key: string; state: AddressLookupTableStateSerialized; }; export type RouteSimulationResultSerialized = { /** * Indicates if the simulation was successful */ success: boolean; /** * Cause of the failure if `success` is false */ errorReason?: string; /** * Logs generated during the simulation */ logs?: string[]; /** * Timestamp of the simulation in milliseconds since epoch */ simulationTimestamp?: number; }; export type BlockhashWithExpiry = { blockhash: Blockhash; lastValidBlockHeight: bigint; }; export type ExecuteRouteParams = { userToExecute: Address; router: RouteOutput; signTransaction: (tx: Transaction) => Promise; signPartialTransaction: (tx: Transaction) => Promise; executeTransaction: (tx: FullySignedTransaction) => Promise; confirmTransaction: (sig: Signature) => Promise; recentBlockhash: BlockhashWithExpiry; computeBudgetInstructions?: Instruction[]; }; export interface BirdEyePriceMultipleParams { list_address: string; } export interface BirdeyePriceData { value: number; updateUnixTime: number; updateHumanTime: string; priceInNative: number; priceChange24h: number; liquidity: number; } export interface BirdeyeMultiPriceResponse { success: boolean; data: { [tokenAddress: string]: BirdeyePriceData; }; } export interface GetJupiterPriceParams { ids: string; vsToken?: string; showExtraInfo?: boolean; } export interface GetJupiterPriceResponse { [key: string]: GetJupiterPriceTokenInfo; } export interface GetJupiterPriceTokenInfo { usdPrice: number; blockId?: number; decimals?: number; priceChange24h?: number; mint?: string; } export interface RoutesResponse { routes: RouteOutput[]; traceId: string; error?: Error; } export interface BestRouteResponse { bestRoute: RouteOutput | undefined; traceId: string; } export interface AsyncData { inputMintProgramOwner?: Address; outputMintProgramOwner?: Address; inputTokenDecimals?: number; outputTokenDecimals?: number; birdeyeTokenInPriceInSol?: number; birdeyeTokenOutPriceInSol?: number; } export interface TopHolderBirdeye { amount: string; decimals: number; mint: string; owner: string; token_account: string; ui_amount: number; } export interface TopHolderResponse { data: { items: TopHolderBirdeye[]; }; success: boolean; } export interface TokenAccountMetadata { address: Address; programAddress: Address; mint: Address; } export {}; //# sourceMappingURL=types.d.ts.map