import { MintLayout } from '@solana/spl-token'; import { Connection, PublicKey, VersionedTransaction, TransactionInstruction } from '@solana/web3.js'; import BN from 'bn.js'; import { IPoolLayoutWithId, IPersonalPositionLayout, ITokenInfo } from '../instructions/index.js'; import { IAddLiquidityParams, IClosePositionParams, ICollectFeesParams, ICreatePoolParams, IQuoteSwapExactOutParams, IQuoteSwapExactOutReturn, ISwapExactOutParams, ICreatePositionParams, IDecreaseFullLiquidityParams, IDecreaseLiquidityParams, IInstructionReturn, ParamsWithSignerCallback, ICollectAllFeesParams, SignerCallback, IGetPositionInfoByNftMintReturn, ICalculateCreatePositionFee, IQouteSwapParams, IQouteSwapReturn, ISwapParams } from './models.js'; import { alignPriceToTickPrice, calculateApr, calculateRewardApr, calculateRangeAprs, getAmountAFromAmountB, getAmountBFromAmountA } from './utils.js'; export declare class Chain { connection: Connection; programId: PublicKey; private rentFeeCache; /** * Constructor * @param params.connection Solana chain connection object * @param params.programId CLMM program ID, default is CLMM_PROGRAM_ID */ constructor(params: { connection: Connection; programId?: PublicKey; }); /** * Get all CLMM position information for a specified account * @param userAddress User wallet address * @returns Promise Position information list */ getRawPositionInfoListByUserAddress(userAddress: PublicKey): Promise; /** * Get the corresponding position information based on the NFT mint address * @param nftMint NFT mint address * @returns Promise Position information */ getRawPositionInfoByNftMint(nftMint: PublicKey): Promise; /** * Get the corresponding pool information based on the pool address * @param poolId Pool address or PublicKey * @returns Promise Pool information */ getRawPoolInfoByPoolId(poolId: string | PublicKey): Promise; /** * Get the corresponding token information based on the token mint address * @param mintAddress Token mint address * @returns Promise<...> Token information */ getRawTokenInfoByMint(mintAddress: PublicKey): Promise<(ReturnType & { owner: PublicKey; }) | null>; /** * Get the simplified token information (including address, precision, and programId) * @param mintAddress Token mint address * @returns Promise */ getTokenInfoByMint(mintAddress: PublicKey): Promise; /** * Get the detailed position information, including price range, token amount, fee, etc. * @param nftMint NFT mint address * @returns Promise<{...}> Detailed position information */ getPositionInfoByNftMint(nftMint: PublicKey): Promise; /** * Create position instructions on the chain (does not directly send transactions) * @param params Parameters required for creating a position * @returns IInstructionReturn Contains instructions, signers, and transaction objects */ createPositionInstructions(params: ICreatePositionParams): Promise; /** * Calculate the rent fee required for creating a position * * @param params Parameters required for creating a position and options */ calculateCreatePositionFee(params: ICreatePositionParams & { useCache?: boolean; }): Promise; /** * Create a new position and send a transaction * @param params Parameters required for creating a position, including a signature callback * @returns Promise Transaction signature */ createPosition(params: ParamsWithSignerCallback): Promise; /** * Close the specified position (only when the liquidity is 0, it can be closed) * @param params.userAddress User wallet address * @param params.nftMint NFT mint address * @returns IInstructionReturn Contains instructions and transaction objects */ closePositionInstructions(params: IClosePositionParams): Promise; /** * Close the specified position and send a transaction * @param params.userAddress User wallet address * @param params.nftMint NFT mint address * @param params.signerCallback Signature callback * @returns Promise Transaction signature */ closePosition(params: { userAddress: PublicKey; nftMint: PublicKey; signerCallback: SignerCallback; }): Promise; /** * Partially remove position liquidity, generate chain instructions * @param params Contains user, position, removed liquidity amount, slippage, etc. * @returns IInstructionReturn */ decreaseLiquidityInstructions(params: IDecreaseLiquidityParams): Promise; /** * Partially remove position liquidity and send a transaction * @param params Contains signature callback, etc. * @returns Promise Transaction signature */ decreaseLiquidity(params: ParamsWithSignerCallback): Promise; /** * Remove all position liquidity (optional to automatically close position) * @param params.closePosition Whether to close position automatically * @param params Other parameters are the same as decreaseLiquidityInstructions * @returns IInstructionReturn */ decreaseFullLiquidityInstructions(params: IDecreaseFullLiquidityParams): Promise; /** * Remove all position liquidity and send a transaction * @param params Contains signature callback, etc. * @returns Promise Transaction signature */ decreaseFullLiquidity(params: ParamsWithSignerCallback): Promise; /** * Collect fees for a single position (essentially removing 0 liquidity) * @param params Contains user, position, etc. * @returns IInstructionReturn */ collectFeesInstructions(params: ICollectFeesParams): Promise; /** * Collect fees for all positions of a user, automatically batch to avoid exceeding transaction size limit * @param params.userAddress User wallet address * @param params.nftMintList NFT mint list * @returns { instructionsList, transactions } Batch instructions and transaction objects */ collectAllPositionFeesInstructions(params: ICollectAllFeesParams): Promise<{ instructionsList: TransactionInstruction[][]; transactions: VersionedTransaction[]; }>; /** * Collect fees for a single position and send a transaction * @param params Contains signature callback, etc. * @returns Promise Transaction signature */ collectFees(params: ParamsWithSignerCallback): Promise; /** * Add liquidity to an existing position, generate chain instructions * @param params Contains user, position, liquidity amount, etc. * @returns IInstructionReturn */ addLiquidityInstructions(params: IAddLiquidityParams): Promise; /** * Add liquidity to an existing position and send a transaction * @param params Contains signature callback, etc. * @returns Promise Transaction signature */ addLiquidity(params: ParamsWithSignerCallback): Promise; /** * Create pool instructions * @param params Create pool parameters * @returns IInstructionReturn */ createPoolInstructions(params: ICreatePoolParams): Promise; /** * Create a new pool and send a transaction * @param params Contains signature callback, etc. * @returns Promise Transaction signature */ createPool(params: ParamsWithSignerCallback): Promise; qouteSwap(params: IQouteSwapParams): Promise; swapInstructions(params: ISwapParams): Promise; /** * Create swap exact out instructions * @param params Contains pool info, quote return, and user address * @returns IInstructionReturn */ swapExactOutInstructions(params: { poolInfo: IPoolLayoutWithId; quoteReturn: IQuoteSwapExactOutReturn; userAddress: PublicKey; }): Promise; swap(params: ParamsWithSignerCallback): Promise; /** * Execute swap exact out transaction * @param params Contains signature callback, etc. * @returns Promise Transaction signature */ swapExactOut(params: ParamsWithSignerCallback): Promise; /** * Quote swap exact output - calculate required input amount for desired output * @param params Quote parameters including output amount and slippage * @returns Quote result with expected input amount and other swap details */ quoteSwapExactOut(params: IQuoteSwapExactOutParams): Promise; /** * Handle SOL/WSOL packaging logic, automatically generate related instructions * * @param params.userAddress User wallet address * @param params.mintA Pool tokenA mint * @param params.mintB Pool tokenB mint * @param params.amountA Optional, tokenA quantity * @param params.amountB Optional, tokenB quantity * @param params.rentExemptLamports Optional, WSOL account rent exemption lamports * @returns tokenAccountA/B, pre-instructions, post-instructions */ handleTokenAccount(params: { userAddress: PublicKey; mintA: PublicKey; mintB: PublicKey; amountA?: BN; amountB?: BN; rentExemptLamports?: number; }): Promise<{ tokenAccountA: PublicKey; tokenAccountB: PublicKey; tokenProgramIdA: PublicKey; tokenProgramIdB: PublicKey; preInstructions: TransactionInstruction[]; endInstructions: TransactionInstruction[]; }>; private estimateRentFee; calculateApr: typeof calculateApr; calculateRewardApr: typeof calculateRewardApr; calculateRangeAprs: typeof calculateRangeAprs; alignPriceToTickPrice: typeof alignPriceToTickPrice; getAmountBFromAmountA: typeof getAmountBFromAmountA; getAmountAFromAmountB: typeof getAmountAFromAmountB; } //# sourceMappingURL=chain.d.ts.map