{"_id":"@analosfork/damm-sdk","name":"@analosfork/damm-sdk","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@analosfork/damm-sdk","version":"1.0.0","description":"- [Core Functions](#core-functions)","license":"ISC","author":"","type":"commonjs","main":"index.js","types":"./index.d.ts","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_id":"@analosfork/damm-sdk@1.0.0","gitHead":"2c6ccabb102e421a62d506d29fd0d91b640d4205","_nodeVersion":"24.6.0","_npmVersion":"11.5.1","dist":{"integrity":"sha512-4m2cVduxzkwyKHFA9BsEF2S/By/nIVpf5D2obdYdNKATgsjxa9TEvfFaaolm3oJOtFGMlWT1uYFzh5SF5jH7dA==","shasum":"16adc6b3c210cf4618616aefc05230d98fbde8b9","tarball":"https://registry.npmjs.org/@analosfork/damm-sdk/-/damm-sdk-1.0.0.tgz","fileCount":4,"unpackedSize":652752,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIAb9JV492tS+EOhTq7fRHExqDrwgsy9UUFU3/8u1JvkBAiBcOhoVLqv3QX18dNmj5yQUQUg6GArLAUNN6/FDQffjag=="}]},"_npmUser":{"name":"analos","email":"admin@analos.io"},"directories":{},"maintainers":[{"name":"analos","email":"admin@analos.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/damm-sdk_1.0.0_1757449449915_0.009774191911330776"},"_hasShrinkwrap":false}},"time":{"created":"2025-09-09T20:24:09.804Z","1.0.0":"2025-09-09T20:24:10.154Z","modified":"2025-09-09T20:24:10.475Z"},"maintainers":[{"name":"analos","email":"admin@analos.io"}],"description":"- [Core Functions](#core-functions)","license":"ISC","readme":"# DAMM SDK: Function Documentation\n\n## Table of Contents\n\n- [Core Functions](#core-functions)\n\n  - [createPool](#createpool)\n  - [createCustomPool](#createcustompool)\n  - [createCustomPoolWithDynamicConfig](#createcustompoolwithdynamicconfig)\n  - [createPosition](#createposition)\n  - [getLiquidityDelta](#getliquiditydelta)\n  - [getQuote](#getquote)\n  - [getQuoteExactOut](#getquoteexactout)\n  - [getDepositQuote](#getdepositquote)\n  - [getWithdrawQuote](#getwithdrawquote)\n  - [swap](#swap)\n  - [addLiquidity](#addliquidity)\n  - [removeLiquidity](#removeliquidity)\n  - [removeAllLiquidity](#removeallliquidity)\n  - [removeAllLiquidityAndClosePosition](#removeallliquidityandcloseposition)\n  - [mergePosition](#mergeposition)\n  - [lockPosition](#lockposition)\n  - [permanentLockPosition](#permanentlockposition)\n  - [refreshVesting](#refreshvesting)\n  - [claimPositionFee](#claimpositionfee)\n  - [claimPositionFee2](#claimpositionfee2)\n  - [claimPartnerFee](#claimpartnerfee)\n  - [claimReward](#claimreward)\n  - [closePosition](#closeposition)\n  - [splitPosition](#splitposition)\n\n- [State Functions](#state-functions)\n\n  - [fetchConfigState](#fetchconfigstate)\n  - [fetchPoolState](#fetchpoolstate)\n  - [fetchPositionState](#fetchpositionstate)\n  - [getAllConfigs](#getallconfigs)\n  - [getAllPools](#getallpools)\n  - [getAllPositions](#getallpositions)\n  - [getAllPositionsByPool](#getallpositionsbypool)\n  - [getUserPositionByPool](#getuserpositionbypool)\n  - [getPositionsByUser](#getpositionsbyuser)\n  - [getAllVestingsByPosition](#getallvestingsbyposition)\n  - [isLockedPosition](#islockedposition)\n  - [isPoolExist](#ispoolexist)\n\n- [Helper Functions](#helper-functions)\n  - [preparePoolCreationParams](#preparepoolcreationparams)\n  - [getProgram](#getprogram)\n  - [isVestingComplete](#isvestingcomplete)\n  - [getTotalLockedLiquidity](#gettotallockedliquidity)\n  - [getAvailableVestingLiquidity](#getavailablevestingliquidity)\n  - [getMaxAmountWithSlippage](#getmaxamountwithslippage)\n  - [getMinAmountWithSlippage](#getminamountwithslippage)\n  - [getPriceImpact](#getpriceimpact)\n  - [getPriceChange](#getpricechange)\n  - [getPriceFromSqrtPrice](#getpricefromsqrtprice)\n  - [getSqrtPriceFromPrice](#getsqrtpricefromprice)\n  - [getUnClaimReward](#getunclaimreward)\n  - [getBaseFeeNumerator](#getbasefeenumerator)\n  - [getDynamicFeeNumerator](#getdynamicfeenumerator)\n  - [bpsToFeeNumerator](#bpstofeenumerator)\n  - [feeNumeratorToBps](#feenumeratortobps)\n  - [getBaseFeeParams](#getbasefeeparams)\n  - [getDynamicFeeParams](#getdynamicfeeparams)\n\n---\n\n## Core Functions\n\n### createPool\n\nCreates a new standard pool according to a predefined configuration.\n\n**Function**\n\n```typescript\nasync createPool(params: CreatePoolParams): TxBuilder\n```\n\n**Parameters**\n\n```typescript\ninterface CreatePoolParams {\n  payer: PublicKey; // The wallet paying for the transaction\n  creator: PublicKey; // The creator of the pool\n  config: PublicKey; // The configuration account for the pool\n  positionNft: PublicKey; // The mint for the initial position NFT\n  tokenAMint: PublicKey; // The mint address for token A\n  tokenBMint: PublicKey; // The mint address for token B\n  activationPoint: BN | null; // The slot or timestamp for activation\n  tokenAAmount: BN; // Initial amount of token A to deposit\n  tokenBAmount: BN; // Initial amount of token B to deposit\n  initSqrtPrice: BN; // Initial sqrt price in Q64 format\n  liquidityDelta: BN; // Initial liquidity delta in Q64 format\n  tokenAProgram: PublicKey; // Token program for token A\n  tokenBProgram: PublicKey; // Token program for token B\n  isLockLiquidity?: boolean; // true if you wanna permanent lock position after pool created.\n}\n```\n\n**Returns**\n\nA transaction builder (`TxBuilder`) that can be used to build, sign, and send the transaction.\n\n**Example**\n\n```typescript\n// First, prepare the pool creation parameters\nconst configState = await cpAmm.getConfigState(configAccount);\nconst initPrice = 10; // 1 base token = 10 quote token\nconst {actualInputAmount, consumedInputAmount, outputAmount, liquidityDelta} = cpAmm.getDepositQuote({\n  inAmount: new BN(5_000_000_000), // 5 tokenA (base token) with 9 decimals\n  isTokenA: true;\n  minSqrtPrice: configState.sqrtMinPrice,\n  maxSqrtPrice: configState.sqrtMinPrice,\n  sqrtPrice: getSqrtPriceFromPrice(initPrice, tokenADecimal, tokenBDecimal),\n  inputTokenInfo, // provide if input token is token2022\n  outputTokenInfo // provide if output token is token2022\n})\n\nconst createPoolTx = await cpAmm.createPool({\n  payer: wallet.publicKey,\n  creator: wallet.publicKey,\n  config: configAddress,\n  positionNft: positionNftMint,\n  tokenAMint,\n  tokenBMint,\n  activationPoint: null,\n  tokenAAmount: consumedInputAmount,\n  tokenBAmount: outputAmount,\n  initSqrtPrice: getSqrtPriceFromPrice(initPrice, tokenADecimal, tokenBDecimal);,\n  liquidityDelta: liquidityDelta,\n  tokenAProgram,\n  tokenBProgram\n});\n```\n\n**Notes**\n\n- Both token amounts must be greater than zero\n- If using native SOL, it will be automatically wrapped to wSOL\n- The `config` parameter should be a valid configuration account\n- Pool creation automatically creates an initial position\n- Use `preparePoolCreationParams` to calculate proper `initSqrtPrice` and `liquidityDelta`\n\n---\n\n### createCustomPool\n\nCreates a customizable pool with specific fee parameters, reward settings, and activation conditions.\n\n**Function**\n\n```typescript\nasync createCustomPool(params: InitializeCustomizeablePoolParams): Promise<{\n  tx: Transaction;\n  pool: PublicKey;\n  position: PublicKey;\n}>\n```\n\n**Parameters**\n\n```typescript\ninterface InitializeCustomizeablePoolParams {\n  payer: PublicKey; // The wallet paying for the transaction\n  creator: PublicKey; // The creator of the pool\n  positionNft: PublicKey; // The mint for the initial position NFT\n  tokenAMint: PublicKey; // The mint address for token A\n  tokenBMint: PublicKey; // The mint address for token B\n  tokenAAmount: BN; // Initial amount of token A to deposit\n  tokenBAmount: BN; // Initial amount of token B to deposit\n  sqrtMinPrice: BN; // Minimum sqrt price\n  sqrtMaxPrice: BN; // Maximum sqrt price\n  initSqrtPrice: BN; // Initial sqrt price in Q64 format\n  liquidityDelta: BN; // Initial liquidity in Q64 format\n  tokenAProgram: PublicKey; // Token program for token A\n  tokenBProgram: PublicKey; // Token program for token B\n  poolFees: PoolFees; // Fee configuration\n  hasAlphaVault: boolean; // Whether the pool has an alpha vault\n  collectFeeMode: number; // How fees are collected (0: normal, 1: alpha)\n  activationPoint: BN; // The slot or timestamp for activation\n  activationType: number; // 0: slot, 1: timestamp\n  isLockLiquidity?: boolean; // true if you wanna permanent lock position after pool created.\n}\n\ninterface PoolFees {\n  baseFee: {\n    cliffFeeNumerator: BN; // Initial fee numerator\n    numberOfPeriod: number; // Number of fee reduction periods\n    reductionFactor: BN; // How much fee reduces each period\n    periodFrequency: number; // How often fees change\n    feeSchedulerMode: number; // 0: Linear, 1: Exponential\n  };\n  dynamicFee?: {\n    // Optional dynamic fee configuration\n    binStep: number;\n    binStepU128: BN;\n    filterPeriod: number;\n    decayPeriod: number;\n    reductionFactor: number;\n    variableFeeControl: number;\n    maxVolatilityAccumulator: number;\n  };\n}\n```\n\n**Returns**\n\nAn object containing:\n\n- `tx`: The transaction to sign and send\n- `pool`: The public key of the created pool\n- `position`: The public key of the initial position\n\n**Example**\n\n```typescript\n// First, prepare the pool creation parameters\nconst { initSqrtPrice, liquidityDelta } = cpAmm.preparePoolCreationParams({\n  tokenAAmount: new BN(5_000_000_000),\n  tokenBAmount: new BN(20_000_000),\n  minSqrtPrice: MIN_SQRT_PRICE,\n  maxSqrtPrice: MAX_SQRT_PRICE\n});\n\nconst poolFees = {\n  baseFee: {\n    feeSchedulerMode: 0, // 0: Linear, 1: Exponential\n    cliffFeeNumerator: 1_000_000,\n    numberOfPeriod: 0,\n    reductionFactor: 0,\n    periodFrequency: 0\n  },\n  partnerFee: {\n    partnerAddress: partnerWallet.publicKey,\n    partnerFeeNumerator: 1000,\n  },\n  dynamicFee: {\n    binStep: 1,\n    binStepU128: new BN(\"1844674407370955\"),\n    filterPeriod: 10,\n    decayPeriod: 120,\n    reductionFactor: 5000,\n    variableFeeControl: 2000000,\n    maxVolatilityAccumulator: 100000,\n  };\n};\n\nconst { tx, pool, position } = await cpAmm.createCustomPool({\n  payer: wallet.publicKey,\n  creator: wallet.publicKey,\n  positionNft: positionNftMint,\n  tokenAMint: usdcMint,\n  tokenBMint: btcMint,\n  tokenAAmount: new BN(5_000_000_000),\n  tokenBAmount: new BN(20_000_000),\n  sqrtMinPrice: MIN_SQRT_PRICE,\n  sqrtMaxPrice: MAX_SQRT_PRICE,\n  initSqrtPrice: initSqrtPrice,\n  liquidityDelta: liquidityDelta,\n  poolFees,\n  hasAlphaVault: false,\n  collectFeeMode: 0, // 0: BothToken, 1: onlyB\n  activationPoint: new BN(Date.now()),\n  activationType: 1, // 0: slot, 1: timestamp\n  tokenAProgram,\n  tokenBProgram\n});\n```\n\n**Notes**\n\n- Use this function instead of `createPool` when you need custom fee structures\n- Use `preparePoolCreationParams` to calculate proper `initSqrtPrice` and `liquidityDelta`\n\n---\n\n### createCustomPoolWithDynamicConfig\n\nCreates a customizable pool with dynamic configuration, allowing for specific fee parameters with specified pool creator authority\n\n**Function**\n\n```typescript\nasync createCustomPoolWithDynamicConfig(params: InitializeCustomizeablePoolWithDynamicConfigParams): Promise<{\n  tx: Transaction;\n  pool: PublicKey;\n  position: PublicKey;\n}>\n```\n\n**Parameters**\n\n```typescript\ninterface InitializeCustomizeablePoolWithDynamicConfigParams {\n  payer: PublicKey; // The wallet paying for the transaction\n  creator: PublicKey; // The creator of the pool\n  positionNft: PublicKey; // The mint for the initial position NFT\n  tokenAMint: PublicKey; // The mint address for token A\n  tokenBMint: PublicKey; // The mint address for token B\n  tokenAAmount: BN; // Initial amount of token A to deposit\n  tokenBAmount: BN; // Initial amount of token B to deposit\n  sqrtMinPrice: BN; // Minimum sqrt price\n  sqrtMaxPrice: BN; // Maximum sqrt price\n  initSqrtPrice: BN; // Initial sqrt price in Q64 format\n  liquidityDelta: BN; // Initial liquidity in Q64 format\n  poolFees: PoolFeesParams; // Fee configuration\n  hasAlphaVault: boolean; // Whether the pool has an alpha vault\n  collectFeeMode: number; // How fees are collected (0: normal, 1: alpha)\n  activationPoint: BN | null; // The slot or timestamp for activation (null for immediate)\n  activationType: number; // 0: slot, 1: timestamp\n  tokenAProgram: PublicKey; // Token program for token A\n  tokenBProgram: PublicKey; // Token program for token B\n  config: PublicKey; // dynamic config account\n  poolCreatorAuthority: PublicKey; // Authority allowed to create pools with this config\n  isLockLiquidity?: boolean; // true if you wanna permanent lock position after pool created.\n}\n```\n\n**Returns**\n\nAn object containing:\n\n- `tx`: The transaction to sign and send\n- `pool`: The public key of the created pool\n- `position`: The public key of the initial position\n\n**Example**\n\n```typescript\n// First, prepare the pool creation parameters\nconst tokenAAmount = new BN(5_000_000_000);\nconst tokenBAmount = new BN(20_000_000);\nconst sqrtPrice = getSqrtPriceFromPrice(\"172\", tokenADecimal, tokenBDecimal);\nconst sqrtMinPrice = getSqrtPriceFromPrice(\"4\", tokenADecimal, tokenBDecimal);\nconst sqrtMaxPrice = getSqrtPriceFromPrice(\"400\", tokenADecimal, tokenBDecimal);\nconst { initSqrtPrice, liquidityDelta } = cpAmm.getLiquidityDelta({\n  maxAmountTokenA: tokenAAmount,\n  maxAmountTokenB: tokenBAmount,\n  sqrtMaxPrice,\n  sqrtMinPrice,\n  sqrtPrice,\n});\n\nconst baseFeeParams = getBaseFeeParams(25, 25, FeeSchedulerMode.Linear, 0, 0); // base fee: 0.25%\nconst dynamicFeeParams = getDynamicFeeParams(25); // max dynamic fee 0.25%\nconst poolFees: PoolFeesParams = {\n    baseFee: baseFeeParams,\n    padding: [],\n    dynamicFee: dynamicFeeParams,\n  };\n\nconst { tx, pool, position } = await cpAmm.createCustomPoolWithDynamicConfig({\n  payer\n  creator,\n  config: dynamicConfigAddress,\n  poolCreatorAuthority: poolCreatorAuth.publicKey,\n  positionNft: positionNftMint,\n  tokenAMint: usdcMint,\n  tokenBMint: btcMint,\n  tokenAAmount,\n  tokenBAmount,\n  sqrtMinPrice,\n  sqrtMaxPrice,\n  initSqrtPrice,\n  liquidityDelta,\n  poolFees,\n  hasAlphaVault: false,\n  collectFeeMode: 0, // 0: Both tokens, 1: Only token B\n  activationPoint: null,\n  activationType: 1, // 0: slot, 1: timestamp\n  tokenAProgram: TOKEN_PROGRAM_ID,\n  tokenBProgram: TOKEN_PROGRAM_ID,\n});\n```\n\n### createPosition\n\nCreates a new position in an existing pool.\n\n**Function**\n\n```typescript\nasync createPosition(params: CreatePositionParams): TxBuilder\n```\n\n**Parameters**\n\n```typescript\ninterface CreatePositionParams {\n  owner: PublicKey; // The owner of the position\n  payer: PublicKey; // The wallet paying for the transaction\n  pool: PublicKey; // The pool to create a position in\n  positionNft: PublicKey; // The mint for the position NFT\n}\n```\n\n**Returns**\n\nA transaction builder (`TxBuilder`) that can be used to build, sign, and send the transaction.\n\n**Example**\n\n```typescript\nconst createPositionTx = await cpAmm.createPosition({\n  owner: wallet.publicKey,\n  payer: wallet.publicKey,\n  pool: poolAddress,\n  positionNft: positionNftMint,\n});\n\nconst tx = await createPositionTx.transaction();\nconst result = await wallet.sendTransaction(tx, connection);\n```\n\n**Notes**\n\n- The `positionNft` should be a new mint that doesn't already have a position\n- Creating a position doesn't automatically add liquidity\n- After creating a position, use `addLiquidity` to provide tokens\n\n---\n\n### getLiquidityDelta\n\nCalculates the liquidity delta based on the provided token amounts and price ranges.\n\n**Function**\n\n```typescript\nasync getLiquidityDelta(params: LiquidityDeltaParams): Promise<BN>\n```\n\n**Parameters**\n\n```typescript\ninterface LiquidityDeltaParams {\n  maxAmountTokenA: BN; // Maximum amount of token A to use\n  maxAmountTokenB: BN; // Maximum amount of token B to use\n  sqrtMaxPrice: BN; // Maximum sqrt price for the range\n  sqrtMinPrice: BN; // Minimum sqrt price for the range\n  sqrtPrice: BN; // Current sqrt price\n}\n```\n\n**Returns**\n\nA BN representing the liquidity delta in Q64 format.\n\n### getQuote\n\nCalculates the expected output amount for a swap, including fees and slippage protection.\n\n**Function**\n\n```typescript\nasync getQuote(params: GetQuoteParams): Promise<{\n  swapInAmount: BN;\n  consumedInAmount: BN;\n  swapOutAmount: BN;\n  minSwapOutAmount: BN;\n  totalFee: BN;\n  priceImpact: number;\n}>\n```\n\n**Parameters**\n\n```typescript\ninterface GetQuoteParams {\n  inAmount: BN; // The amount of input token to swap\n  inputTokenMint: PublicKey; // The mint of the input token\n  slippage: number; // Slippage tolerance in percentage (e.g., 0.5 for 0.5%)\n  poolState: PoolState; // The state of the pool\n  currentTime: number; // Current timestamp (for time-based fees)\n  currentSlot: number; // Current slot (for slot-based fees)\n  inputTokenInfo?: {\n    mint: Mint;\n    currentEpoch: number;\n  }; // Token info for Token2022 transfer fee calculations\n  outputTokenInfo?: {\n    mint: Mint;\n    currentEpoch: number;\n  }; // Token info for Token2022 transfer fee calculations\n}\n```\n\n**Returns**\n\nAn object containing:\n\n- `swapInAmount`: The original input amount\n- `consumedInAmount`: The actual input amount used (after transfer fees)\n- `swapOutAmount`: The expected output amount\n- `minSwapOutAmount`: The minimum output amount accounting for slippage\n- `totalFee`: The total fee to be paid\n- `priceImpact`: The price impact of the swap as a percentage\n\n**Example**\n\n```typescript\nconst poolState = await cpAmm.fetchPoolState(poolAddress);\nconst currentSlot = await connection.getSlot();\nconst blockTime = await connection.getBlockTime(currentSlot);\nconst quote = await cpAmm.getQuote({\n  inAmount: new BN(100_000_000), // 100 USDC\n  inputTokenMint: usdcMint,\n  slippage: 0.5, // 0.5% slippage\n  poolState,\n  currentTime: blockTime,\n  currentSlot,\n});\n\nconsole.log(`Expected output: ${quote.swapOutAmount.toString()}`);\nconsole.log(`Minimum output: ${quote.minSwapOutAmount.toString()}`);\nconsole.log(`Fee: ${quote.totalFee.toString()}`);\nconsole.log(`Price impact: ${quote.priceImpact.toFixed(2)}%`);\n```\n\n**Notes**\n\n- Always check the price impact before executing a swap\n- The `slippage` parameter protects users from price movements\n- Use the `minSwapOutAmount` as the `minimumAmountOut` parameter for `swap`\n- For Token2022 tokens with transfer fees, provide the token info parameters\n\n---\n\n### getQuoteExactOut\n\nCalculates the expected input amount for a swap based on an exact output amount, including fees and slippage protection.\n\n**Function**\n\n```typescript\nasync getQuoteExactOut(params: GetQuoteExactOutParams): Promise<{\n  outAmount: BN;\n  outputTokenMint: PublicKey;\n  slippage: number;\n  poolState: PoolState;\n  currentTime: number;\n  currentSlot: number;\n  inputTokenInfo?: {\n    mint: Mint;\n    currentEpoch: number;\n  };\n  outputTokenInfo?: {\n    mint: Mint;\n    currentEpoch: number;\n  };\n}>\n```\n\n**Parameters**\n\n```typescript\ninterface GetQuoteExactOutParams {\n  outAmount: BN; // The amount of output token to swap from\n  outputTokenMint: PublicKey; // The mint of the output token\n  slippage: number; // Slippage tolerance in percentage (e.g., 0.5 for 0.5%)\n  poolState: PoolState; // The state of the pool\n  currentTime: number; // Current timestamp (for time-based fees)\n  currentSlot: number; // Current slot (for slot-based fees)\n  inputTokenInfo?: {\n    mint: Mint;\n    currentEpoch: number;\n  }; // Token info for Token2022 transfer fee calculations\n  outputTokenInfo?: {\n    mint: Mint;\n    currentEpoch: number;\n  }; // Token info for Token2022 transfer fee calculations\n}\n```\n\n**Returns**\n\nAn object containing:\n\n- `outputAmount`: The expected output amount\n- `outputTokenMint`: The mint of the output token\n- `slippage`: The slippage tolerance in percentage\n- `poolState`: The state of the pool\n- `currentTime`: The current timestamp\n- `currentSlot`: The current slot\n- `inputTokenInfo`: Token info for Token2022 transfer fee calculations\n- `outputTokenInfo`: Token info for Token2022 transfer fee calculations\n\n**Example**\n\n```typescript\nconst poolState = await cpAmm.fetchPoolState(poolAddress);\nconst currentSlot = await connection.getSlot();\nconst blockTime = await connection.getBlockTime(currentSlot);\nconst quote = await cpAmm.getQuoteExactOut({\n  outAmount: new BN(100_000_000), // 100 USDC\n  outputTokenMint: usdcMint,\n  slippage: 0.5, // 0.5% slippage\n  poolState,\n  currentTime: blockTime,\n  currentSlot,\n});\n\nconsole.log(`Required input: ${quote.inputAmount.toString()}`);\nconsole.log(`Max input with slippage: ${quote.maxInputAmount.toString()}`);\nconsole.log(`Price impact: ${quote.priceImpact.toFixed(2)}%`);\nconsole.log(`Output amount: ${quote.swapResult.outputAmount.toString()}`);\n```\n\n**Notes**\n\n- Always check the price impact before executing a swap\n- The `slippage` parameter protects users from price movements\n- Use the `maxInputAmount` as the `amountIn` parameter for `swap`\n- For Token2022 tokens with transfer fees, provide the token info parameters\n\n---\n\n### getDepositQuote\n\nCalculates the deposit quote for adding liquidity to a pool based on a single token input.\n\n**Function**\n\n```typescript\nasync getDepositQuote(params: GetDepositQuoteParams): Promise<DepositQuote>\n```\n\n**Parameters**\n\n```typescript\ninterface GetDepositQuoteParams {\n  inAmount: BN; // The amount of input token\n  isTokenA: boolean; // Whether the input token is token A\n  minSqrtPrice: BN; // Minimum sqrt price\n  maxSqrtPrice: BN; // Maximum sqrt price\n  sqrtPrice: BN; // Current sqrt price\n  inputTokenInfo?: {\n    mint: Mint;\n    currentEpoch: number;\n  }; // Token info for Token2022 transfer fee calculations\n  outputTokenInfo?: {\n    mint: Mint;\n    currentEpoch: number;\n  }; // Token info for Token2022 transfer fee calculations\n}\n```\n\n**Returns**\n\nAn object containing:\n\n- `actualInputAmount`: The actual input amount (after transfer fees)\n- `consumedInputAmount`: The full input amount including transfer fees\n- `liquidityDelta`: The amount of liquidity that will be added\n- `outputAmount`: The calculated amount of the other token to be paired\n\n**Example**\n\n```typescript\nconst poolState = await cpAmm.fetchPoolState(poolAddress);\n\nconst depositQuote = await cpAmm.getDepositQuote({\n  inAmount: new BN(1_000_000_000), // 1,000 USDC\n  isTokenA: true, // USDC is token A\n  minSqrtPrice: poolState.sqrtMinPrice,\n  maxSqrtPrice: poolState.sqrtMaxPrice,\n  sqrtPrice: poolState.sqrtPrice,\n});\n\nconsole.log(`Liquidity delta: ${depositQuote.liquidityDelta.toString()}`);\nconsole.log(`Required token B: ${depositQuote.outputAmount.toString()}`);\n```\n\n**Notes**\n\n- Use this to calculate how much of token B is needed when adding token A (or vice versa)\n- Particularly useful for single-sided liquidity provision\n- The function handles Token2022 transfer fees if token info is provided\n\n---\n\n### getWithdrawQuote\n\nCalculates the withdrawal quote for removing liquidity from a pool.\n\n**Function**\n\n```typescript\nasync getWithdrawQuote(params: GetWithdrawQuoteParams): Promise<WithdrawQuote>\n```\n\n**Parameters**\n\n```typescript\ninterface GetWithdrawQuoteParams {\n  liquidityDelta: BN; // The amount of liquidity to withdraw\n  sqrtPrice: BN; // Current sqrt price\n  maxSqrtPrice: BN; // Maximum sqrt price\n  minSqrtPrice: BN; // Minimum sqrt price\n  inputTokenInfo?: {\n    mint: Mint;\n    currentEpoch: number;\n  }; // Token info for Token2022 transfer fee calculations\n  outputTokenInfo?: {\n    mint: Mint;\n    currentEpoch: number;\n  }; // Token info for Token2022 transfer fee calculations\n}\n```\n\n**Returns**\n\nAn object containing:\n\n- `liquidityDelta`: The amount of liquidity being removed\n- `outAmountA`: The calculated amount of token A to receive\n- `outAmountB`: The calculated amount of token B to receive\n\n**Example**\n\n```typescript\nconst poolState = await cpAmm.fetchPoolState(poolAddress);\nconst positionState = await cpAmm.fetchPositionState(positionAddress);\n\n// Calculate quote for removing half the liquidity\nconst liquidityToRemove = positionState.liquidity.div(new BN(2));\n\nconst withdrawQuote = await cpAmm.getWithdrawQuote({\n  liquidityDelta: liquidityToRemove,\n  sqrtPrice: poolState.sqrtPrice,\n  minSqrtPrice: poolState.sqrtMinPrice,\n  maxSqrtPrice: poolState.sqrtMaxPrice,\n});\n\nconsole.log(`Expected token A: ${withdrawQuote.outAmountA.toString()}`);\nconsole.log(`Expected token B: ${withdrawQuote.outAmountB.toString()}`);\n```\n\n**Notes**\n\n- Use this to estimate the tokens you'll receive when removing liquidity\n- The function handles Token2022 transfer fees if token info is provided\n- The calculation accounts for the current price relative to the position's price range\n\n---\n\n### swap\n\nExecutes a token swap in the pool.\n\n**Function**\n\n```typescript\nasync swap(params: SwapParams): TxBuilder\n```\n\n**Parameters**\n\n```typescript\ninterface SwapParams {\n  payer: PublicKey; // The wallet paying for the transaction\n  pool: PublicKey; // Address of the pool to swap in\n  inputTokenMint: PublicKey; // Mint of the input token\n  outputTokenMint: PublicKey; // Mint of the output token\n  amountIn: BN; // Amount of input token to swap\n  minimumAmountOut: BN; // Minimum amount of output token (slippage protection)\n  tokenAVault: PublicKey; // Pool's token A vault\n  tokenBVault: PublicKey; // Pool's token B vault\n  tokenAMint: PublicKey; // Pool's token A mint\n  tokenBMint: PublicKey; // Pool's token B mint\n  tokenAProgram: PublicKey; // Token program for token A\n  tokenBProgram: PublicKey; // Token program for token B\n  referralTokenAccount?: PublicKey; // Optional referral account for fees\n}\n```\n\n**Returns**\n\nA transaction builder (`TxBuilder`) that can be used to build, sign, and send the transaction.\n\n**Example**\n\n```typescript\nconst poolState = await cpAmm.fetchPoolState(poolAddress);\nconst currentSlot = await connection.getSlot();\nconst blockTime = await connection.getBlockTime(currentSlot);\n// Get quote first\nconst quote = await cpAmm.getQuote({\n  inAmount: new BN(100_000_000), // 100 USDC\n  inputTokenMint: poolState.tokenAMint,\n  slippage: 0.5,\n  poolState,\n  currentTime: blockTime,\n  currentSlot,\n});\n\n// Execute swap\nconst swapTx = await cpAmm.swap({\n  payer: wallet.publicKey,\n  pool: poolAddress,\n  inputTokenMint: poolState.tokenAMint,\n  outputTokenMint: poolState.tokenBMint,\n  amountIn: new BN(100_000_000),\n  minimumAmountOut: quote.minSwapOutAmount,\n  tokenAVault: poolState.tokenAVault,\n  tokenBVault: poolState.tokenBVault,\n  tokenAMint: poolState.tokenAMint,\n  tokenBMint: poolState.tokenBMint,\n  tokenAProgram: TOKEN_PROGRAM_ID,\n  tokenBProgram: TOKEN_PROGRAM_ID,\n});\n```\n\n**Notes**\n\n- Get a quote first using `getQuote` to determine the `minimumAmountOut`\n- The SDK handles wrapping/unwrapping of SOL automatically\n- Token accounts are created automatically if they don't exist\n- The transaction will fail if the output amount would be less than `minimumAmountOut`\n- Optional referral tokenAccount will receive a portion of fees if the pool is configured for referrals\n\n---\n\n### addLiquidity\n\nAdds liquidity to an existing position.\n\n**Function**\n\n```typescript\nasync addLiquidity(params: AddLiquidityParams): TxBuilder\n```\n\n**Parameters**\n\n```typescript\ninterface AddLiquidityParams {\n  owner: PublicKey; // The owner of the position\n  pool: PublicKey; // The pool address\n  position: PublicKey; // The position address\n  positionNftAccount: PublicKey; // The ata account of position nft\n  liquidityDelta: BN; // The amount of liquidity to add in Q64 format\n  maxAmountTokenA: BN; // Maximum amount of token A to use\n  maxAmountTokenB: BN; // Maximum amount of token B to use\n  tokenAAmountThreshold: BN; // Minimum acceptable token A amount (slippage protection)\n  tokenBAmountThreshold: BN; // Minimum acceptable token B amount (slippage protection)\n  tokenAMint: PublicKey; // The mint of token A\n  tokenBMint: PublicKey; // The mint of token B\n  tokenAVault: PublicKey; // The pool's token A vault\n  tokenBVault: PublicKey; // The pool's token B vault\n  tokenAProgram: PublicKey; // Token program for token A\n  tokenBProgram: PublicKey; // Token program for token B\n}\n```\n\n**Returns**\n\nA transaction builder (`TxBuilder`) that can be used to build, sign, and send the transaction.\n\n**Example**\n\n```typescript\nconst poolState = await cpAmm.fetchPoolState(poolAddress);\nconst positionState = await cpAmm.fetchPositionState(positionAddress);\n\n// Get deposit quote\nconst depositQuote = await cpAmm.getDepositQuote({\n  inAmount: new BN(1_000_000_000), // 1,000 USDC\n  isTokenA: true,\n  minSqrtPrice: poolState.sqrtMinPrice,\n  maxSqrtPrice: poolState.sqrtMaxPrice,\n  sqrtPrice: poolState.sqrtPrice,\n});\n\n// Add liquidity\nconst addLiquidityTx = await cpAmm.addLiquidity({\n  owner: wallet.publicKey,\n  pool: poolAddress,\n  position: positionAddress,\n  positionNftAccount: positionNftAccount,\n  liquidityDelta: depositQuote.liquidityDelta,\n  maxAmountTokenA: new BN(1_000_000_000),\n  maxAmountTokenB: depositQuote.outputAmount,\n  tokenAAmountThreshold: maxAmountTokenA,\n  tokenBAmountThreshold: maxAmountTokenB,\n  tokenAMint: poolState.tokenAMint,\n  tokenBMint: poolState.tokenBMint,\n  tokenAVault: poolState.tokenAVault,\n  tokenBVault: poolState.tokenBVault,\n  tokenAProgram,\n  tokenBProgram,\n});\n```\n\n**Notes**\n\n- Calculate the liquidity delta first using `getDepositQuote`\n- The SDK handles wrapping/unwrapping of SOL automatically\n- Token accounts are created automatically if they don't exist\n- Set appropriate thresholds to protect against slippage\n\n---\n\n### removeLiquidity\n\nRemoves a specific amount of liquidity from an existing position.\n\n**Function**\n\n```typescript\nasync removeLiquidity(params: RemoveLiquidityParams): TxBuilder\n```\n\n**Parameters**\n\n```typescript\ninterface RemoveLiquidityParams {\n  owner: PublicKey; // The owner of the position\n  pool: PublicKey; // The pool address\n  position: PublicKey; // The position address\n  positionNftAccount?: PublicKey; // The position NFT account\n  liquidityDelta: BN; // The amount of liquidity to remove in Q64 format\n  tokenAAmountThreshold: BN; // Minimum acceptable token A amount (slippage protection)\n  tokenBAmountThreshold: BN; // Minimum acceptable token B amount (slippage protection)\n  tokenAMint: PublicKey; // The mint of token A\n  tokenBMint: PublicKey; // The mint of token B\n  tokenAVault: PublicKey; // The pool's token A vault\n  tokenBVault: PublicKey; // The pool's token B vault\n  tokenAProgram: PublicKey; // Token program for token A\n  tokenBProgram: PublicKey; // Token program for token B\n  vestings?: Array<{ account: PublicKey }>; // Optional vesting accounts to refresh\n}\n```\n\n**Returns**\n\nA transaction builder (`TxBuilder`) that can be used to build, sign, and send the transaction.\n\n**Example**\n\n```typescript\nconst poolState = await cpAmm.fetchPoolState(poolAddress);\nconst positionState = await cpAmm.fetchPositionState(positionAddress);\n\n// Get withdraw quote for half of the liquidity\nconst liquidityToRemove = positionState.unlockedLiquidity.div(new BN(2));\nconst withdrawQuote = await cpAmm.getWithdrawQuote({\n  liquidityDelta: liquidityToRemove,\n  sqrtPrice: poolState.sqrtPrice,\n  minSqrtPrice: poolState.sqrtMinPrice,\n  maxSqrtPrice: poolState.sqrtMaxPrice,\n});\n\nconst removeLiquidityTx = await cpAmm.removeLiquidity({\n  owner: wallet.publicKey,\n  pool: poolAddress,\n  position: positionAddress,\n  positionNftAccount: positionNftAccount,\n  liquidityDelta: liquidityToRemove,\n  tokenAAmountThreshold: new BN(0),\n  tokenBAmountThreshold: new BN(0),\n  tokenAMint: poolState.tokenAMint,\n  tokenBMint: poolState.tokenBMint,\n  tokenAVault: poolState.tokenAVault,\n  tokenBVault: poolState.tokenBVault,\n  tokenAProgram,\n  tokenBProgram,\n});\n```\n\n**Notes**\n\n- You can only remove unlocked liquidity\n- The SDK handles wrapping/unwrapping of SOL automatically\n- Token accounts are created automatically if they don't exist\n- Set appropriate thresholds to protect against slippage\n- Removing all liquidity doesn't close the position\n\n---\n\n### removeAllLiquidity\n\nRemoves all available liquidity from a position.\n\n**Function**\n\n```typescript\nasync removeAllLiquidity(params: RemoveAllLiquidityParams): TxBuilder\n```\n\n**Parameters**\n\n```typescript\ninterface RemoveAllLiquidityParams {\n  owner: PublicKey; // The owner of the position\n  pool: PublicKey; // The pool address\n  position: PublicKey; // The position address\n  positionNftAccount: PublicKey; // The ata account of position nft\n  tokenAAmountThreshold: BN; // Minimum acceptable token A amount (slippage protection)\n  tokenBAmountThreshold: BN; // Minimum acceptable token B amount (slippage protection)\n  tokenAMint: PublicKey; // The mint of token A\n  tokenBMint: PublicKey; // The mint of token B\n  tokenAVault: PublicKey; // The pool's token A vault\n  tokenBVault: PublicKey; // The pool's token B vault\n  tokenAProgram: PublicKey; // Token program for token A\n  tokenBProgram: PublicKey; // Token program for token B\n  vestings?: Array<{ account: PublicKey }>; // Optional vesting accounts to refresh if position has vesting lock\n}\n```\n\n**Returns**\n\nA transaction builder (`TxBuilder`) that can be used to build, sign, and send the transaction.\n\n**Example**\n\n```typescript\nconst poolState = await cpAmm.fetchPoolState(poolAddress);\nconst positionState = await cpAmm.fetchPositionState(positionAddress);\n\nconst removeAllLiquidityTx = await cpAmm.removeAllLiquidity({\n  owner: wallet.publicKey,\n  pool: poolAddress,\n  position: positionAddress,\n  positionNftAccount: positionNftAccount,\n  tokenAAmountThreshold: new BN(0),\n  tokenBAmountThreshold: new BN(0),\n  tokenAMint: poolState.tokenAMint,\n  tokenBMint: poolState.tokenBMint,\n  tokenAVault: poolState.tokenAVault,\n  tokenBVault: poolState.tokenBVault,\n  tokenAProgram,\n  tokenBProgram,\n});\n```\n\n**Notes**\n\n- This removes all unlocked liquidity in one transaction\n- The position remains open after removing all liquidity\n- You can't remove locked liquidity (use `refreshVesting` first if needed)\n- The SDK handles wrapping/unwrapping of SOL automatically\n\n---\n\n### removeAllLiquidityAndClosePosition\n\nRemoves all liquidity from a position and closes it in a single transaction.\n\n**Function**\n\n```typescript\nasync removeAllLiquidityAndClosePosition(params: RemoveAllLiquidityAndClosePositionParams): TxBuilder\n```\n\n**Parameters**\n\n```typescript\ninterface RemoveAllLiquidityAndClosePositionParams {\n  owner: PublicKey; // The owner of the position\n  position: PublicKey; // The position address\n  positionNftAccount: PublicKey; // The position NFT account\n  positionState: PositionState; // The current position state\n  poolState: PoolState; // The current pool state\n  tokenAAmountThreshold: BN; // Minimum acceptable token A amount (slippage protection)\n  tokenBAmountThreshold: BN; // Minimum acceptable token B amount (slippage protection)\n  currentPoint: BN; // Current timestamp or slot number for vesting calculations\n  vestings?: Array<{ account: PublicKey; vestingState: VestingState }>; // Optional vesting accounts\n}\n```\n\n**Returns**\n\nA transaction builder (`TxBuilder`) that can be used to build, sign, and send the transaction.\n\n**Example**\n\n```typescript\nconst poolState = await cpAmm.fetchPoolState(poolAddress);\nconst positionState = await cpAmm.fetchPositionState(positionAddress);\n\n// Check if position is locked\nif (cpAmm.isLockedPosition(positionState)) {\n  console.error(\"Cannot close a locked position\");\n  return;\n}\n\n// Build transaction to remove all liquidity and close position\nconst tx = await cpAmm.removeAllLiquidityAndClosePosition({\n  owner: wallet.publicKey,\n  position: positionAddress,\n  positionNftAccount: positionNftAccount,\n  positionState: positionState,\n  poolState: poolState,\n  tokenAAmountThreshold: new BN(0),\n  tokenBAmountThreshold: new BN(0),\n});\n```\n\n**Notes**\n\n- This combines multiple operations in a single transaction:\n  1. Claims any accumulated fees\n  2. Removes all liquidity\n  3. Closes the position and returns the rent\n- The position must be completely unlocked\n- The function will throw an error if the position has any locked liquidity\n- This is more gas-efficient than doing these operations separately\n- If there are vesting schedules, they must be refreshed before closing the position\n\n---\n\n### mergePosition\n\nMerges liquidity from one position into another in a single transaction.\n\n**Function**\n\n```typescript\nasync mergePosition(params: MergePositionParams): TxBuilder\n```\n\n**Parameters**\n\n```typescript\ninterface MergePositionParams {\n  owner: PublicKey; // The owner of both positions\n  positionA: PublicKey; // Target position to merge into\n  positionB: PublicKey; // Source position to merge from\n  positionBState: PositionState; // State of the source position\n  poolState: PoolState; // State of the pool\n  positionANftAccount: PublicKey; // ata account of target position NFT\n  positionBNftAccount: PublicKey; // ata account of source position NFT\n  tokenAAmountAddLiquidityThreshold: BN; // Minimum token A amount for add liquidity\n  tokenBAmountAddLiquidityThreshold: BN; // Minimum token B amount for add liquidity\n  tokenAAmountRemoveLiquidityThreshold: BN; // Minimum token A amount for remove liquidity\n  tokenBAmountRemoveLiquidityThreshold: BN; // Minimum token B amount for remove liquidity\n  currentPoint: BN; // Current timestamp or slot number for vesting calculations\n  positionBVestings?: Array<{ account: PublicKey; vestingState: VestingState }>; // Optional vesting accounts for position B\n}\n```\n\n**Returns**\n\nA transaction builder (`TxBuilder`) that can be used to build, sign, and send the transaction.\n\n**Example**\n\n```typescript\nconst poolState = await cpAmm.fetchPoolState(poolAddress);\nconst positionAState = await cpAmm.fetchPositionState(positionAAddress); // Target position\nconst positionBState = await cpAmm.fetchPositionState(positionBAddress); // Source position to merge from\n\n// Check if position is locked\nif (cpAmm.isLockedPosition(positionBState)) {\n  console.error(\"Cannot merge a locked position\");\n  return;\n}\n\n// Build transaction to merge positions\nconst tx = await cpAmm.mergePosition({\n  owner: wallet.publicKey,\n  positionA: positionAAddress,\n  positionB: positionBAddress,\n  positionBState: positionBState,\n  poolState: poolState,\n  positionANftAccount: positionANftAccount,\n  positionBNftAccount: positionBNftAccount,\n  tokenAAmountAddLiquidityThreshold: new BN(U64_MAX),\n  tokenBAmountAddLiquidityThreshold: new BN(u64_MAX),\n  tokenAAmountRemoveLiquidityThreshold: new BN(0),\n  tokenBAmountRemoveLiquidityThreshold: new BN(0),\n});\n```\n\n**Notes**\n\n- This function combines multiple operations:\n  1. Claims any accumulated fees from the source position\n  2. Removes all liquidity from the source position\n  3. Adds the liquidity to the target position\n  4. Closes the source position\n- Both positions must be owned by the same wallet\n- The source position must be completely unlocked\n- This is more gas-efficient than performing these operations separately\n- Set appropriate thresholds to protect against slippage for both add and remove operations\n\n---\n\n### lockPosition\n\nBuilds a transaction to lock a position with vesting schedule.\n\n**Function**\n\n```typescript\nasync lockPosition(params: LockPositionParams): TxBuilder\n```\n\n**Parameters**\n\n```typescript\ninterface LockPositionParams {\n  owner: PublicKey; // The owner of the position\n  pool: PublicKey; // The pool address\n  payer: PublicKey; // The wallet paying for the transaction\n  vestingAccount: PublicKey; // The vesting account to create\n  position: PublicKey; // The position address\n  positionNftAccount: PublicKey; // The position NFT account\n  cliffPoint: BN | null; // The cliff point (slot or timestamp)\n  periodFrequency: BN; // How often liquidity unlocks\n  cliffUnlockLiquidity: BN; // Amount to unlock at cliff\n  liquidityPerPeriod: BN; // Amount to unlock per period\n  numberOfPeriod: number; // Number of vesting periods\n}\n```\n\n**Returns**\n\nA transaction builder (`TxBuilder`) that can be used to build, sign, and send the transaction.\n\n**Example**\n\n```typescript\nconst vestingAccount = Keypair.generate();\n\nconst lockPositionTx = await cpAmm.lockPosition({\n  owner: wallet.publicKey,\n  pool: poolAddress,\n  payer: wallet.publicKey,\n  vestingAccount: vestingAccount.publicKey,\n  position: positionAddress,\n  positionNftAccount: positionNftAccount,\n  cliffPoint: new BN(Date.now() + 7 * 24 * 60 * 60 * 1000), // 7 days cliff\n  periodFrequency: new BN(24 * 60 * 60 * 1000), // 1 day periods\n  cliffUnlockLiquidity: new BN(0), // No initial unlock\n  liquidityPerPeriod: positionState.unlockedLiquidity.div(new BN(30)), // Unlock over 30 days\n  numberOfPeriod: 30, // 30 periods\n});\n```\n\n**Notes**\n\n- Locking positions is useful for creating various incentive mechanisms\n- The vesting schedule controls how quickly liquidity unlocks over time\n- Locked liquidity cannot be withdrawn until it becomes unlocked\n- The vesting account is a new account that must be created\n- The function only locks currently unlocked liquidity\n\n---\n\n### permanentLockPosition\n\nPermanently locks a portion of liquidity in a position.\n\n**Function**\n\n```typescript\nasync permanentLockPosition(params: PermanentLockParams): TxBuilder\n```\n\n**Parameters**\n\n```typescript\ninterface PermanentLockParams {\n  owner: PublicKey; // The owner of the position\n  position: PublicKey; // The position address\n  positionNftAccount: PublicKey; // The position NFT account\n  pool: PublicKey; // The pool address\n  unlockedLiquidity: BN; // Amount of liquidity to permanently lock\n}\n```\n\n**Returns**\n\nA transaction builder (`TxBuilder`) that can be used to build, sign, and send the transaction.\n\n**Example**\n\n```typescript\nconst positionState = await cpAmm.fetchPositionState(positionAddress);\n\n// Permanently lock half of the unlocked liquidity\nconst liquidityToLock = positionState.unlockedLiquidity.div(new BN(2));\n\nconst lockTx = await cpAmm.permanentLockPosition({\n  owner: wallet.publicKey,\n  position: positionAddress,\n  positionNftAccount: positionNftAccount,\n  pool: poolAddress,\n  unlockedLiquidity: liquidityToLock,\n});\n```\n\n**Notes**\n\n- Permanently locked liquidity can never be withdrawn\n- This is useful for deep liquidity protocols or governance mechanisms\n- Once liquidity is permanently locked, this action cannot be reversed\n- The owner can still collect fees from permanently locked liquidity\n\n---\n\n### refreshVesting\n\nRefreshes vesting status of a position to unlock available liquidity.\n\n**Function**\n\n```typescript\nasync refreshVesting(params: RefreshVestingParams): TxBuilder\n```\n\n**Parameters**\n\n```typescript\ninterface RefreshVestingParams {\n  owner: PublicKey; // The owner of the position\n  position: PublicKey; // The position address\n  positionNftAccount: PublicKey; // The position NFT account\n  pool: PublicKey; // The pool address\n  vestingAccounts: PublicKey[]; // Array of vesting accounts to refresh\n}\n```\n\n**Returns**\n\nA transaction builder (`TxBuilder`) that can be used to build, sign, and send the transaction.\n\n**Example**\n\n```typescript\n// Get all vesting accounts for the position\nconst vestings = await cpAmm.getAllVestingsByPosition(positionAddress);\n\nconst refreshVestingTx = await cpAmm.refreshVesting({\n  owner: wallet.publicKey,\n  position: positionAddress,\n  positionNftAccount: positionNftAccount,\n  pool: poolAddress,\n  vestingAccounts: vestings.map((v) => v.publicKey),\n});\n```\n\n**Notes**\n\n- Call this function to update the vesting state and unlock available liquidity\n- Should be called periodically to ensure liquidity is properly unlocked\n- If all liquidity is unlocked, the vesting account remains but is no longer used\n- Must be called before removing liquidity if position has vesting accounts\n\n---\n\n### claimPositionFee\n\nClaims accumulated fees for a position.\n\n**Function**\n\n```typescript\nasync claimPositionFee(params: ClaimPositionFeeParams): TxBuilder\n```\n\n**Parameters**\n\n```typescript\ninterface ClaimPositionFeeParams {\n  owner: PublicKey; // The owner of the position\n  pool: PublicKey; // The pool address\n  position: PublicKey; // The position address\n  positionNftAccount: PublicKey; // The position NFT account\n  tokenAVault: PublicKey; // The pool's token A vault\n  tokenBVault: PublicKey; // The pool's token B vault\n  tokenAMint: PublicKey; // The mint of token A\n  tokenBMint: PublicKey; // The mint of token B\n  tokenAProgram: PublicKey; // Token program for token A\n  tokenBProgram: PublicKey; // Token program for token B\n  receiver?: Pubkey; // the wallet that will receive the fees (optional)\n  tempWSolAccount?: Pubkey; // the temporary wallet that will receive the fees (optional)\n}\n```\n\n**Returns**\n\nA transaction builder (`TxBuilder`) that can be used to build, sign, and send the transaction.\n\n**Example**\n\n```typescript\nconst poolState = await cpAmm.fetchPoolState(poolAddress);\n\nconst claimFeeTx = await cpAmm.claimPositionFee({\n  owner: wallet.publicKey,\n  pool: poolAddress,\n  position: positionAddress,\n  positionNftAccount: positionNftAccount,\n  tokenAVault: poolState.tokenAVault,\n  tokenBVault: poolState.tokenBVault,\n  tokenAMint: poolState.tokenAMint,\n  tokenBMint: poolState.tokenBMint,\n  tokenAProgram,\n  tokenBProgram,\n});\n```\n\n**Notes**\n\n- Fees are collected when trades occur in the pool\n- Only the position owner can claim fees\n- Fees are earned on both token A and token B based on the amount of liquidity provided\n- Fees accumulate over time and should be claimed periodically\n- The SDK handles wrapping/unwrapping of SOL automatically\n\n### claimPositionFee2\n\nClaims accumulated fees for a position.\n\n**Function**\n\n```typescript\nasync claimPositionFee2(params: ClaimPositionFeeParams2): TxBuilder\n```\n\n**Parameters**\n\n```typescript\ninterface ClaimPositionFeeParams {\n  owner: PublicKey; // The owner of the position\n  pool: PublicKey; // The pool address\n  position: PublicKey; // The position address\n  positionNftAccount: PublicKey; // The position NFT account\n  tokenAVault: PublicKey; // The pool's token A vault\n  tokenBVault: PublicKey; // The pool's token B vault\n  tokenAMint: PublicKey; // The mint of token A\n  tokenBMint: PublicKey; // The mint of token B\n  tokenAProgram: PublicKey; // Token program for token A\n  tokenBProgram: PublicKey; // Token program for token B\n  receiver: Pubkey; //  The wallet that will receive the fees\n  feePayer?: PublicKey; // Specific fee payer for transaction. Default fee payer is position's owner\n}\n```\n\n**Returns**\n\nA transaction builder (`TxBuilder`) that can be used to build, sign, and send the transaction.\n\n**Example**\n\n```typescript\nconst poolState = await cpAmm.fetchPoolState(poolAddress);\n\nconst claimFeeTx = await cpAmm.claimPositionFee2({\n  owner: wallet.publicKey,\n  pool: poolAddress,\n  position: positionAddress,\n  receiver: receiverAddress,\n  positionNftAccount: positionNftAccount,\n  tokenAVault: poolState.tokenAVault,\n  tokenBVault: poolState.tokenBVault,\n  tokenAMint: poolState.tokenAMint,\n  tokenBMint: poolState.tokenBMint,\n  tokenAProgram,\n  tokenBProgram,\n});\n```\n\n**Notes**\n\n- Fees are collected when trades occur in the pool\n- Only the position owner can claim fees\n- Fees will claim to receiver address\n- Fees are earned on both token A and token B based on the amount of liquidity provided\n- The SDK handles wrapping/unwrapping of SOL automatically\n\n---\n\n### claimPartnerFee\n\nClaims partner fee rewards.\n\n**Function**\n\n```typescript\nasync claimPartnerFee(params: ClaimPartnerFeeParams): TxBuilder\n```\n\n**Parameters**\n\n```typescript\ninterface ClaimPartnerFeeParams {\n  partner: PublicKey; // Partner address to receive fees\n  pool: PublicKey; // The pool address\n  maxAmountA: BN; // Maximum amount of token A to claim\n  maxAmountB: BN; // Maximum amount of token B to claim\n}\n```\n\n**Returns**\n\nA transaction builder (`TxBuilder`) that can be used to build, sign, and send the transaction.\n\n**Example**\n\n```typescript\nconst poolState = await cpAmm.fetchPoolState(poolAddress);\n\nconst claimPartnerFeeTx = await cpAmm.claimPartnerFee({\n  partner: partnerWallet.publicKey,\n  pool: poolAddress,\n  maxAmountA: new BN(1_000_000_000), // 1,000 USDC\n  maxAmountB: new BN(5_000_000_000), // 5 SOL\n});\n```\n\n**Notes**\n\n- Partner fees are a portion of trading fees directed to a specific account\n- Only the configured partner address can claim these fees\n- Partner fees must be enabled in the pool configuration\n- The SDK handles wrapping/unwrapping of SOL automatically\n- Token accounts are created automatically if they don't exist\n\n---\n\n### claimReward\n\nClaims reward tokens from a position.\n\n**Function**\n\n```typescript\nasync claimReward(params: ClaimRewardParams): TxBuilder\n```\n\n**Parameters**\n\n```typescript\ninterface ClaimRewardParams {\n  user: PublicKey; // The user claiming rewards\n  position: PublicKey; // The position address\n  positionNftAccount: PublicKey; // The position NFT account\n  rewardIndex: number; // Index of the reward to claim\n  skipReward: number; // Skip reward transfer (0: transfer reward, 1: skip reward)\n  poolState: PoolState; // The current pool state\n  positionState: PositionState; // The current position state\n}\n```\n\n**Returns**\n\nA transaction builder (`TxBuilder`) that can be used to build, sign, and send the transaction.\n\n**Example**\n\n```typescript\nconst poolState = await cpAmm.fetchPoolState(poolAddress);\nconst positionState = await cpAmm.fetchPositionState(positionAddress);\n\n// Claim reward at index 0\nconst claimRewardTx = await cpAmm.claimReward({\n  user: wallet.publicKey,\n  position: positionAddress,\n  positionNftAccount: positionNftAccount,\n  rewardIndex: 0,\n  skipReward: 0,\n  poolState: poolState,\n  positionState: positionState,\n});\n```\n\n**Notes**\n\n- Pools can have multiple reward tokens configured\n- The rewardIndex parameter specifies which reward token to claim\n- Rewards accrue based on the amount of liquidity provided and duration\n- Only the position owner can claim rewards\n- The SDK handles wrapping/unwrapping of SOL automatically\n\n---\n\n### closePosition\n\nCloses a position with no liquidity.\n\n**Function**\n\n```typescript\nasync closePosition(params: ClosePositionParams): TxBuilder\n```\n\n**Parameters**\n\n```typescript\ninterface ClosePositionParams {\n  owner: PublicKey; // The owner of the position\n  pool: PublicKey; // The pool address\n  position: PublicKey; // The position address\n  positionNftMint: PublicKey; // The position NFT mint\n  positionNftAccount: PublicKey; // The position NFT account\n}\n```\n\n**Returns**\n\nA transaction builder (`TxBuilder`) that can be used to build, sign, and send the transaction.\n\n**Example**\n\n```typescript\nconst positionState = await cpAmm.fetchPositionState(positionAddress);\n\n// Check if position has no liquidity\nif (\n  !positionState.unlockedLiquidity.isZero() ||\n  !positionState.vestedLiquidity.isZero() ||\n  !positionState.permanentLockedLiquidity.isZero()\n) {\n  console.error(\"Position still has liquidity\");\n  return;\n}\n\nconst closePositionTx = await cpAmm.closePosition({\n  owner: wallet.publicKey,\n  pool: positionState.pool,\n  position: positionAddress,\n  positionNftMint: positionState.nftMint,\n  positionNftAccount: positionNftAccount,\n});\n```\n\n**Notes**\n\n- Position must have zero liquidity before closing\n- Use `removeAllLiquidity` first if the position still has liquidity\n- Closing a position returns the rent to the owner\n- This function only closes the position account, not the NFT\n- For a full cleanup, use `removeAllLiquidityAndClosePosition` instead\n\n---\n\n### splitPosition\n\nSplits a position into two positions.\n\n**Function**\n\n```typescript\nasync splitPosition(params: SplitPositionParams): TxBuilder\n```\n\n**Parameters**\n\n```typescript\ninterface SplitPositionParams {\n  firstPositionOwner: PublicKey; // The owner of the first position\n  secondPositionOwner: PublicKey; // The owner of the second position\n  pool: PublicKey; // The pool address\n  firstPosition: PublicKey; // The first position address\n  firstPositionNftAccount: PublicKey; // The first position NFT account\n  secondPosition: PublicKey; // The second position address\n  secondPositionNftAccount: PublicKey; // The second position NFT account\n  unlockedLiquidityPercentage: number; // The percentage of unlocked liquidity to split\n  permanentLockedLiquidityPercentage: number; // The percentage of permanent locked liquidity to split\n  feeAPercentage: number; // The percentage of fee A to split\n  feeBPercentage: number; // The percentage of fee B to split\n  reward0Percentage: number; // The percentage of reward 0 to split\n  reward1Percentage: number; // The percentage of reward 1 to split\n}\n```\n\n**Returns**\n\nA transaction builder (`TxBuilder`) that can be used to build, sign, and send the transaction.\n\n**Example**\n\n```typescript\nconst firstPosition = await client.getUserPositionByPool(\n  poolAddress,\n  firstUser.publicKey\n);\n\nconst secondPositionKP = Keypair.generate();\n\nconst createSecondPositionTx = await client.createPosition({\n  owner: secondUser.publicKey,\n  payer: secondUser.publicKey,\n  pool: poolAddress,\n  positionNft: secondPositionKP.publicKey,\n});\n\nconst createSignature = await sendAndConfirmTransaction(\n  connection,\n  createSecondPositionTx,\n  [secondUser, secondPositionKP],\n  {\n    commitment: \"confirmed\",\n    skipPreflight: true,\n  }\n);\nconsole.log(\"Second position created:\", createSignature);\n\nconst secondPosition = await client.getUserPositionByPool(\n  poolAddress,\n  secondUser.publicKey\n);\n\nconst splitPositionTx = await client.splitPosition({\n  firstPositionOwner: firstUser.publicKey,\n  secondPositionOwner: secondUser.publicKey,\n  pool: poolAddress,\n  firstPosition: firstPosition[0].position,\n  firstPositionNftAccount: firstPosition[0].positionNftAccount,\n  secondPosition: secondPosition[0].position,\n  secondPositionNftAccount: secondPosition[0].positionNftAccount,\n  unlockedLiquidityPercentage: 50,\n  permanentLockedLiquidityPercentage: 0,\n  feeAPercentage: 50,\n  feeBPercentage: 50,\n  reward0Percentage: 50,\n  reward1Percentage: 50,\n});\n```\n\n**Notes**\n\n- The first position must already exist for that pool\n- The second position can be a new empty position for that same pool\n\n---\n\n## State Functions\n\n### fetchConfigState\n\nFetches the Config state of the program.\n\n**Function**\n\n```typescript\nasync fetchConfigState(config: PublicKey): Promise<ConfigState>\n```\n\n**Parameters**\n\n- `config`: Public key of the config account.\n\n**Returns**\n\nParsed ConfigState.\n\n**Example**\n\n```typescript\nconst configState = await cpAmm.fetchConfigState(configAddress);\nconsole.log(configState);\n```\n\n**Notes**\n\n- Throws an error if the config account does not exist\n\n---\n\n### fetchPoolState\n\nFetches the Pool state.\n\n**Function**\n\n```typescript\nasync fetchPoolState(pool: PublicKey): Promise<PoolState>\n```\n\n**Parameters**\n\n- `pool`: Public key of the pool.\n\n**Returns**\n\nParsed PoolState.\n\n**Example**\n\n```typescript\nconst poolState = await cpAmm.fetchPoolState(poolAddress);\nconsole.log(`Current Price: ${poolState.sqrtPrice.toString()}`);\nconsole.log(`Liquidity: ${poolState.liquidity.toString()}`);\n```\n\n**Notes**\n\n- Throws an error if the pool account does not exist\n- Contains all essential information about the pool including prices, liquidity, and fees\n\n---\n\n### fetchPositionState\n\nFetches the Position state.\n\n**Function**\n\n```typescript\nasync fetchPositionState(position: PublicKey): Promise<PositionState>\n```\n\n**Parameters**\n\n- `position`: Public key of the position.\n\n**Returns**\n\nParsed PositionState.\n\n**Example**\n\n```typescript\nconst positionState = await cpAmm.fetchPositionState(positionAddress);\nconsole.log(\n  `Unlocked Liquidity: ${positionState.unlockedLiquidity.toString()}`\n);\nconsole.log(`Vested Liquidity: ${positionState.vestedLiquidity.toString()}`);\nconsole.log(\n  `Permanent Locked Liquidity: ${positionState.permanentLockedLiquidity.toString()}`\n);\n```\n\n**Notes**\n\n- Throws an error if the position account does not exist\n- Contains information about liquidity amounts, fee collection, and rewards\n\n---\n\n### getAllConfigs\n\nRetrieves all config accounts.\n\n**Function**\n\n```typescript\nasync getAllConfigs(): Promise<Array<{ publicKey: PublicKey; account: ConfigState }>>\n```\n\n**Returns**\n\nArray of config public keys and their states.\n\n**Example**\n\n```typescript\nconst configs = await cpAmm.getAllConfigs();\nconsole.log(`Found ${configs.length} configs`);\nconfigs.forEach((config, i) => {\n  console.log(`Config ${i}: ${config.publicKey.toString()}`);\n});\n```\n\n---\n\n### getAllPools\n\nRetrieves all pool accounts.\n\n**Function**\n\n```typescript\nasync getAllPools(): Promise<Array<{ publicKey: PublicKey; account: PoolState }>>\n```\n\n**Returns**\n\nArray of pool public keys and their states.\n\n**Example**\n\n```typescript\nconst pools = await cpAmm.getAllPools();\nconsole.log(`Found ${pools.length} pools`);\npools.forEach((pool, i) => {\n  console.log(`Pool ${i}: ${pool.publicKey.toString()}`);\n  console.log(`- Token A: ${pool.account.tokenAMint.toString()}`);\n  console.log(`- Token B: ${pool.account.tokenBMint.toString()}`);\n});\n```\n\n---\n\n### getAllPositions\n\nRetrieves all position accounts.\n\n**Function**\n\n```typescript\nasync getAllPositions(): Promise<Array<{ publicKey: PublicKey; account: PositionState }>>\n```\n\n**Returns**\n\nArray of position public keys and their states.\n\n**Example**\n\n```typescript\nconst positions = await cpAmm.getAllPositions();\nconsole.log(`Found ${positions.length} positions`);\n```\n\n---\n\n### getAllPositionsByPool\n\nGets all positions for a specific pool.\n\n**Function**\n\n```typescript\nasync getAllPositionsByPool(pool: PublicKey): Promise<Array<{ publicKey: PublicKey; account: PositionState }>>\n```\n\n**Parameters**\n\n- `pool`: Public key of the pool.\n\n**Returns**\n\nList of positions for the pool.\n\n**Example**\n\n```typescript\nconst poolPositions = await cpAmm.getAllPositionsByPool(poolAddress);\nconsole.log(`Pool has ${poolPositions.length} positions`);\n```\n\n---\n\n### getUserPositionByPool\n\nGets all positions of a user for a specific pool.\n\n**Function**\n\n```typescript\nasync getUserPositionByPool(pool: PublicKey, user: PublicKey): Promise<Array<{ positionNftAccount: PublicKey; position: PublicKey; positionState: PositionState }>>\n```\n\n**Parameters**\n\n- `pool`: Public key of the pool.\n- `user`: Public key of the user.\n\n**Returns**\n\nList of user positions for the pool.\n\n**Example**\n\n```typescript\nconst userPoolPositions = await cpAmm.getUserPositionByPool(\n  poolAddress,\n  wallet.publicKey\n);\nconsole.log(`User has ${userPoolPositions.length} positions in this pool`);\n```\n\n---\n\n### getPositionsByUser\n\nGets all positions of a user across all pools.\n\n**Function**\n\n```typescript\nasync getPositionsByUser(user: PublicKey): Promise<Array<{ positionNftAccount: PublicKey; position: PublicKey; positionState: PositionState }>>\n```\n\n**Parameters**\n\n- `user`: Public key of the user.\n\n**Returns**\n\nArray of user positions already sorted by liquidity.\n\n**Example**\n\n```typescript\nconst userPositions = await cpAmm.getPositionsByUser(wallet.publicKey);\nconsole.log(`User has ${userPositions.length} total positions`);\n```\n\n**Notes**\n\n- Positions are sorted by total liquidity in descending order\n- Returns position NFT accounts, position addresses, and full position states\n\n---\n\n### getAllVestingsByPosition\n\nRetrieves all vesting accounts associated with a position.\n\n**Function**\n\n```typescript\nasync getAllVestingsByPosition(position: PublicKey): Promise<Array<{ publicKey: PublicKey; account: VestingState }>>\n```\n\n**Parameters**\n\n- `position`: Public key of the position.\n\n**Returns**\n\nArray of vesting account public keys and their states.\n\n**Example**\n\n```typescript\nconst vestings = await cpAmm.getAllVestingsByPosition(positionAddress);\nconsole.log(`Position has ${vestings.length} vesting accounts`);\n```\n\n---\n\n### isLockedPosition\n\nChecks if a position has any locked liquidity.\n\n**Function**\n\n```typescript\nisLockedPosition(position: PositionState): boolean\n```\n\n**Parameters**\n\n- `position`: The position state.\n\n**Returns**\n\nBoolean indicating whether the position has locked liquidity.\n\n**Example**\n\n```typescript\nconst positionState = await cpAmm.fetchPositionState(positionAddress);\nif (cpAmm.isLockedPosition(positionState)) {\n  console.log(\"Position has locked liquidity\");\n} else {\n  console.log(\"Position has no locked liquidity\");\n}\n```\n\n---\n\n### isPoolExist\n\nChecks if a pool exists.\n\n**Function**\n\n```typescript\nasync isPoolExist(pool: PublicKey): Promise<boolean>\n```\n\n**Parameters**\n\n- `pool`: Public key of the pool.\n\n**Returns**\n\nBoolean indicating whether the pool exists.\n\n**Example**\n\n```typescript\nconst exists = await cpAmm.isPoolExist(poolAddress);\nif (exists) {\n  console.log(\"Pool exists\");\n} else {\n  console.log(\"Pool does not exist\");\n}\n```\n\n---\n\n## Helper Functions\n\n### preparePoolCreationParams\n\nPrepares parameters required for pool creation, including initial sqrt price and liquidity.\n\n**Function**\n\n```typescript\npreparePoolCreationParams(params: PreparePoolCreationParams): PreparedPoolCreation\n```\n\n**Parameters**\n\n```typescript\ninterface PreparePoolCreationParams {\n  tokenAAmount: BN; // Initial amount of token A to deposit\n  tokenBAmount: BN; // Initial amount of token B to deposit\n  minSqrtPrice: BN; // Minimum sqrt price\n  maxSqrtPrice: BN; // Maximum sqrt price\n  tokenAInfo?: any; // Token info for Token2022 transfer fee calculations\n  tokenBInfo?: any; // Token info for Token2022 transfer fee calculations\n}\n```\n\n**Returns**\n\nAn object containing:\n\n- `initSqrtPrice`: The initial sqrt price in Q64 format\n- `liquidityDelta`: The initial liquidity in Q64 format\n\n**Example**\n\n```typescript\nconst { initSqrtPrice, liquidityDelta } = cpAmm.preparePoolCreationParams({\n  tokenAAmount: new BN(1_000_000_000), // 1,000 USDC with 6 decimals\n  tokenBAmount: new BN(5_000_000_000), // 5 SOL with 9 decimals\n  minSqrtPrice: MIN_SQRT_PRICE,\n  maxSqrtPrice: MAX_SQRT_PRICE,\n});\n\nconsole.log(`Initial sqrt price: ${initSqrtPrice.toString()}`);\nconsole.log(`Initial liquidity: ${liquidityDelta.toString()}`);\n```\n\n**Notes**\n\n- This function calculates the correct initial price and liquidity based on the token amounts\n- Both token amounts must be greater than zero\n- The function handles Token2022 transfer fees if token info is provided\n\n### isVestingComplete\n\nChecks if a vesting schedule is ready for full release.\n\n**Function**\n\n```typescript\nfunction isVestingComplete(\n  vestingData: VestingState,\n  currentPoint: BN\n): boolean;\n```\n\n**Parameters**\n\n- `vestingData`: The vesting account state data\n- `currentPoint`: Current timestamp or slot number\n\n**Returns**\n\nBoolean indicating whether the vesting schedule is complete and all liquidity can be released.\n\n**Example**\n\n```typescript\nconst vestings = await cpAmm.getAllVestingsByPosition(positionAddress);\nif (vestings.length > 0) {\n  const isComplete = isVestingComplete(vestings[0].account, new BN(Date.now()));\n  if (isComplete) {\n    console.log(\"Vesting schedule is complete, all liquidity can be released\");\n  } else {\n    console.log(\"Vesting schedule is still active\");\n  }\n}\n```\n\n**Notes**\n\n- This function checks if the current point (timestamp or slot) has passed the end of the vesting schedule\n- The end point is calculated as: cliffPoint + (periodFrequency \\* numberOfPeriods)\n- Returns true if currentPoint >= endPoint, false otherwise\n- Useful to determine if a position can be fully unlocked\n\n---\n\n### getTotalLockedLiquidity\n\nGets the total amount of liquidity in the vesting schedule.\n\n**Function**\n\n```typescript\nfunction getTotalLockedLiquidity(vestingData: VestingState): BN;\n```\n\n**Parameters**\n\n- `vestingData`: The vesting account state data\n\n**Returns**\n\nThe total locked liquidity amount as a BN.\n\n**Example**\n\n```typescript\nconst vestings = await cpAmm.getAllVestingsByPosition(positionAddress);\nif (vestings.length > 0) {\n  const totalLocked = getTotalLockedLiquidity(vestings[0].account);\n  console.log(`Total locked liquidity: ${totalLocked.toString()}`);\n}\n```\n\n**Notes**\n\n- Calculates the sum of cliff unlock liquidity and periodic unlock liquidity\n- Formula: cliffUnlockLiquidity + (liquidityPerPeriod \\* numberOfPeriod)\n- This is the total amount of liquidity that was initially locked in the vesting schedule\n- Does not account for already released liquidity\n\n---\n\n### getAvailableVestingLiquidity\n\nCalculates the available liquidity to withdraw based on vesting schedule.\n\n**Function**\n\n```typescript\nfunction getAvailableVestingLiquidity(\n  vestingData: VestingState,\n  currentPoint: BN\n): BN;\n```\n\n**Parameters**\n\n- `vestingData`: The vesting account state data\n- `currentPoint`: Current timestamp or slot number\n\n**Returns**\n\nThe amount of liquidity available to withdraw as a BN.\n\n**Example**\n\n```typescript\nconst vestings = await cpAmm.getAllVestingsByPosition(positionAddress);\nif (vestings.length > 0) {\n  const availableLiquidity = getAvailableVestingLiquidity(\n    vestings[0].account,\n    new BN(Date.now())\n  );\n  console.log(\n    `Available liquidity to withdraw: ${availableLiquidity.toString()}`\n  );\n}\n```\n\n### getMaxAmountWithSlippage\n\nCalculates the maximum amount after applying a slippage rate.\n\n**Function**\n\n```typescript\nfunction getMaxAmountWithSlippage(amount: BN, rate: number): BN;\n```\n\n**Parameters**\n\n- `amount`: The base amount as a BN\n- `rate`: The slippage rate as a percentage (e.g., 0.5 for 0.5%)\n\n**Returns**\n\nThe maximum amount after applying slippage as a BN.\n\n**Example**\n\n```typescript\nconst tokenAmount = new BN(1_000_000_000); // 1,000 tokens\nconst slippageRate = 0.5; // 0.5% slippage allowance\nconst maxAmount = getMaxAmountWithSlippage(tokenAmount, slippageRate);\nconsole.log(`Maximum amount with slippage: ${maxAmount.toString()}`);\n```\n\n**Notes**\n\n- Used when you need to calculate the upper bound of an amount with slippage tolerance\n- Formula: amount \\* (100 + rate) / 100\n- Common use case: Setting a maximum deposit amount when adding liquidity\n- Slippage rate is expressed as a percentage and supports up to 2 decimal places\n\n---\n\n### getMinAmountWithSlippage\n\nCalculates the minimum amount after applying a slippage rate.\n\n**Function**\n\n```typescript\nfunction getMinAmountWithSlippage(amount: BN, rate: number): BN;\n```\n\n**Parameters**\n\n- `amount`: The base amount as a BN\n- `rate`: The slippage rate as a percentage (e.g., 0.5 for 0.5%)\n\n**Returns**\n\nThe minimum amount after applying slippage as a BN.\n\n**Example**\n\n```typescript\nconst expectedOutput = new BN(1_000_000_000); // 1,000 tokens\nconst slippageRate = 0.5; // 0.5% slippage allowance\nconst minAmount = getMinAmountWithSlippage(expectedOutput, slippageRate);\nconsole.log(`Minimum amount with slippage: ${minAmount.toString()}`);\n```\n\n**Notes**\n\n- Used when you need to calculate the lower bound of an amount with slippage tolerance\n- Formula: amount \\* (100 - rate) / 100\n- Common use case: Setting a minimum output amount when swapping tokens\n- Slippage rate is expressed as a percentage and supports up to 2 decimal places\n\n---\n\n### getPriceImpact\n\nCalculates the price impact as a percentage.\n\n**Function**\n\n```typescript\nfunction getPriceImpact(actualAmount: BN, idealAmount: BN): number;\n```\n\n**Parameters**\n\n- `actualAmount`: The actual amount after slippage in token units\n- `idealAmount`: The theoretical amount without slippage in token units\n\n**Returns**\n\nThe price impact as a percentage (e.g., 1.5 means 1.5%).\n\n**Example**\n\n```typescript\nconst idealAmount = new BN(1_000_000_000); // 1,000 tokens (theoretical)\nconst actualAmount = new BN(990_000_000); // 990 tokens (actual)\nconst impact = getPriceImpact(actualAmount, idealAmount);\nconsole.log(`Price impact: ${impact.toFixed(2)}%`);\n```\n\n**Notes**\n\n- Used to express how much a transacti","readmeFilename":"README.md","_rev":"1-7519322528fe43cab14ba5dbf307494c"}