UNPKG

orca-clmm-agent

Version:

Orca Whirlpool clmm library for automated position management

136 lines 6.23 kB
import { setDefaultFunder } from "@orca-so/whirlpools"; import { TransactionDetails, WhirlpoolInfo, type OrcaPosition } from "./types"; import { Address, Signature, TransactionSigner } from "@solana/kit"; import { DivergenceLossResult, GetLiquidityInTicksParams, OpenPositionParams, OrcaToken, PositionYieldLimits, PositionYieldRange } from "./orca.types"; export declare const TOKEN_MAX_EXCEEDED_ERROR: bigint; export declare const TOKEN_MIN_SUBCEEDED_ERROR: bigint; export declare const INVALID_START_TICK_ERROR: bigint; export declare const setOrcaDefaultFunder: typeof setDefaultFunder; /** * Calculates the minimum tick index based on the pool's tickspacing * @param tickSpacing The tickspacing of the pool * @returns The minimum tick index that is a valid multiple of tickSpacing */ export declare const calculateMinTickIndex: (tickSpacing: number) => number; /** * Calculates the maximum tick index based on the pool's tickspacing * @param tickSpacing The tickspacing of the pool * @returns The maximum tick index that is a valid multiple of tickSpacing */ export declare const calculateMaxTickIndex: (tickSpacing: number) => number; /** * Calculates the start tick index for a tick array given a tick index and tickspacing * @param tickIndex The current tick index * @param tickSpacing The tick spacing of the pool * @returns The start tick index of the tick array containing the given tick */ export declare const getTickArrayStartIndex: (tickIndex: number, tickSpacing: number) => number; /** * Converts position fees to decimal format * @param feeQuote The fee quote object containing feeOwedA and feeOwedB * @param tokenADecimals Decimals for token A * @param tokenBDecimals Decimals for token B * @returns Object with converted fee amounts */ export declare const convertPositionFees: (feeQuote: { feeOwedA: bigint; feeOwedB: bigint; }, tokenADecimals: number, tokenBDecimals: number) => { feeAmountA: number; feeAmountB: number; }; /** * Fetches all Orca Whirlpool pools from the API * @returns A promise that resolves to an array of WhirlpoolResponse objects */ export declare const fetchOrcaPools: () => Promise<WhirlpoolInfo[]>; export declare const getOrcaTokens: () => Promise<OrcaToken[]>; export declare const preloadOrcaTokens: () => Promise<OrcaToken[]>; export declare const getPreloadedOrcaTokens: (maxAgeInSeconds?: number) => Promise<OrcaToken[]>; /** * Fetches a specific Orca Whirlpool pool by address from the API * @param address The address of the Whirlpool pool * @returns A promise that resolves to a WhirlpoolResponse object */ export declare const fetchOrcaPoolByAddress: (address: string) => Promise<WhirlpoolInfo>; /** * Fetches and analyzes Orca Whirlpool positions for a given wallet address * @param walletAddress - The wallet address to fetch positions for * @param rpc - The RPC connection to use * @param pools - Optional list of whirlpools to fetch positions for * @returns A promise that resolves when all positions have been processed */ export declare const getOrcaPositions: (walletAddress: string, rpc: any, pools?: WhirlpoolInfo[], funder?: TransactionSigner) => Promise<OrcaPosition[]>; /** * Calculates the estimated yield for a given position. * @param params - The parameters for the yield calculation. * @returns The estimated yield. * @throws Will throw an error if the position is not found or if the stats are not available. */ export declare const getEstimatedYield: (params: PositionYieldRange | PositionYieldLimits) => Promise<number>; /** * Closes a position and harvests yield * @param rpc The RPC client * @param wallet The wallet signer * @param position The position to close * @returns A promise that resolves when the position is closed * @throws Will throw an error if the position is not found * @throws SolanaError if the transaction fails */ export declare const closePositionAndHarvestYield: (rpc: any, wallet: TransactionSigner, position: OrcaPosition & { [key: string]: any; }) => Promise<{ signature: Signature; details: TransactionDetails; }>; export declare const getOnChainPool: (whirlpool: WhirlpoolInfo, rpc: any) => Promise<{ price: number; discriminator: import("@solana/kit").ReadonlyUint8Array; whirlpoolsConfig: Address; whirlpoolBump: import("@solana/kit").ReadonlyUint8Array; tickSpacing: number; feeTierIndexSeed: import("@solana/kit").ReadonlyUint8Array; feeRate: number; protocolFeeRate: number; liquidity: bigint; sqrtPrice: bigint; tickCurrentIndex: number; protocolFeeOwedA: bigint; protocolFeeOwedB: bigint; tokenMintA: Address; tokenVaultA: Address; feeGrowthGlobalA: bigint; tokenMintB: Address; tokenVaultB: Address; feeGrowthGlobalB: bigint; rewardLastUpdatedTimestamp: bigint; rewardInfos: Array<import("@orca-so/whirlpools-client").WhirlpoolRewardInfo>; }>; export declare const openPosition: ({ rpc, whirlpoolAddress, params, price, lowerMultiple, upperMultiple, slippageToleranceBps, wallet, swapDustToAddress, walletByteArray, maxGasUSD, }: OpenPositionParams) => Promise<{ positionMint: Address; signature: Signature; details: TransactionDetails; swapSignature: Signature | undefined; swapLoss: number; }>; /** * Calculate divergence (impermanent) loss and details in a CLMM range. * Basically just the loss in value difference form just HODLing the tokens vs LPing them. * @param p Current price (tokenB per tokenA) * @param p_i Initial price at position entry * @param p_a Lower price bound of the range * @param p_b Upper price bound of the range * @param depositA Initial deposit amount of token A * @param depositB Initial deposit amount of token B * @returns Object with impermanent loss and related values */ export declare const divergenceLoss: (p: number, p_i: number, p_a: number, p_b: number, depositA: number, depositB: number) => DivergenceLossResult; export declare const getLiquidityInTicks: ({ poolAddress, rpc }: GetLiquidityInTicksParams) => Promise<{ data: { tickIndex: number; price: number; liquidity: number; }[]; currentPrice: number; }>; //# sourceMappingURL=orca.d.ts.map