@meteora-ag/cp-amm-sdk 1.0.0-rc.7 → 1.0.0-rc.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -5625,6 +5625,11 @@ declare class CpAmm {
5625
5625
  _program: AmmProgram;
5626
5626
  private poolAuthority;
5627
5627
  constructor(connection: Connection);
5628
+ /**
5629
+ * Returns the Anchor program instance.
5630
+ * @returns The AmmProgram instance.
5631
+ */
5632
+ getProgram(): AmmProgram;
5628
5633
  /**
5629
5634
  * Prepares token accounts for a transaction by retrieving or creating associated token accounts.
5630
5635
  * @private
@@ -6084,41 +6089,6 @@ declare function getSwapAmount(inAmount: BN, sqrtPrice: BN, liquidity: BN, trade
6084
6089
  amountOut: BN;
6085
6090
  totalFee: BN;
6086
6091
  };
6087
- /**
6088
- * Converts basis points (bps) to a fee numerator
6089
- * 1 bps = 0.01% = 0.0001 in decimal
6090
- *
6091
- * @param bps - The value in basis points [1-10_000]
6092
- * @returns The equivalent fee numerator
6093
- */
6094
- declare function bpsToFeeNumerator(bps: number): number;
6095
- /**
6096
- * Converts a fee numerator back to basis points (bps)
6097
- *
6098
- * @param feeNumerator - The fee numerator to convert
6099
- * @returns The equivalent value in basis points [1-10_000]
6100
- */
6101
- declare function feeNumeratorToBps(feeNumerator: number): number;
6102
- /**
6103
- * Calculates the reduction factor for a Linear fee schedule
6104
- * Formula: fee = cliff_fee_numerator - passed_period * reduction_factor
6105
- *
6106
- * @param cliffFeeBps - The initial fee value at the cliff in basis points
6107
- * @param targetFeeBps - The desired final fee value after all periods in basis points
6108
- * @param totalPeriods - The total number of periods over which the reduction occurs
6109
- * @returns The estimate of reduction factor
6110
- */
6111
- declare function estimateLinearReductionFactor(cliffFeeBps: number, targetFeeBps: number, totalPeriods: number): number;
6112
- /**
6113
- * Calculates the reduction factor for an Exponential fee schedule
6114
- * Formula: fee_numerator = cliff_fee_numerator * (1 - reduction_factor/BASIS_POINT_MAX)^passed_period
6115
- * reduction_factor = BASIS_POINT_MAX * (1 - (fee_numerator/cliff_fee_numerator)^(1/totalPeriods))
6116
- * @param cliffFeeBps - The initial fee value at the cliff in basis points
6117
- * @param targetFeeBps - The desired final fee value after all periods in basis points
6118
- * @param totalPeriods - The total number of periods over which the reduction occurs
6119
- * @returns The estimate of reduction factor
6120
- */
6121
- declare function estimateExponentialReductionFactor(cliffFeeBps: number, targetFeeBps: number, totalPeriods: number): number;
6122
6092
 
6123
6093
  declare function getNextSqrtPrice(amount: BN, sqrtPrice: BN, liquidity: BN, aToB: boolean): BN;
6124
6094
  declare function getLiquidityDeltaFromAmountA(amountA: BN, lowerSqrtPrice: BN, // current sqrt price
@@ -12567,4 +12537,4 @@ var CpAmmIDL = {
12567
12537
  types: types
12568
12538
  };
12569
12539
 
12570
- export { ActivationPoint, ActivationType, type AddLiquidityParams, type AmmProgram, BASIS_POINT_MAX, type BaseFee, type BuildAddLiquidityParams, type BuildLiquidatePositionInstructionParams, type BuildRemoveAllLiquidityInstructionParams, CP_AMM_PROGRAM_ID, type ClaimPartnerFeeParams, type ClaimPositionFeeInstructionParams, type ClaimPositionFeeParams, type ClaimRewardParams, type ClosePositionInstructionParams, type ClosePositionParams, CollectFeeMode, type ConfigState, CpAmm, type CpAmm$1 as CpAmmTypes, type CreatePoolParams, type CreatePositionAndAddLiquidity, type CreatePositionParams, type DepositQuote, type DynamicFee, type DynamicFeeParams, FEE_DENOMINATOR, type FeeMode, FeeSchedulerMode, type FundRewardParams, type GetDepositQuoteParams, type GetQuoteParams, type GetWithdrawQuoteParams, type InitializeCustomizeablePoolParams, type InitializeRewardParams, LIQUIDITY_SCALE, type LiquidityDeltaParams, type LockPositionParams, MAX_CU_BUFFER, MAX_FEE_NUMERATOR, MAX_SQRT_PRICE, MIN_CU_BUFFER, MIN_SQRT_PRICE, type MergePositionParams, ONE, type PermanentLockParams, type PoolFeesParams, type PoolState, type PositionState, type PreparePoolCreationParams, type PreparePoolCreationSingleSide, type PreparedPoolCreation, type RefreshVestingParams, type RemoveAllLiquidityAndClosePositionParams, type RemoveAllLiquidityParams, type RemoveLiquidityParams, type RewardInfo, Rounding, SCALE_OFFSET, type SwapParams, type SwapQuotes, type TokenBadgeState, TradeDirection, type TxBuilder, type UpdateRewardDurationParams, type UpdateRewardFunderParams, type VestingState, type WithdrawIneligibleRewardParams, type WithdrawQuote, bpsToFeeNumerator, calculateInitSqrtPrice, calculateTransferFeeExcludedAmount, calculateTransferFeeIncludedAmount, decimalToQ64, CpAmmIDL as default, deriveClaimFeeOperatorAddress, deriveConfigAddress, deriveCustomizablePoolAddress, derivePoolAddress, derivePoolAuthority, derivePositionAddress, derivePositionNftAccount, deriveRewardVaultAddress, deriveTokenBadgeAddress, deriveTokenVaultAddress, estimateExponentialReductionFactor, estimateLinearReductionFactor, feeNumeratorToBps, getAllPositionNftAccountByOwner, getAllUserPositionNftAccount, getAmountAFromLiquidityDelta, getAmountBFromLiquidityDelta, getAvailableVestingLiquidity, getBaseFeeNumerator, getDynamicFeeNumerator, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getFeeNumerator, getFirstKey, getLiquidityDeltaFromAmountA, getLiquidityDeltaFromAmountB, getMaxAmountWithSlippage, getMinAmountWithSlippage, getNextSqrtPrice, getOrCreateATAInstruction, getPriceFromSqrtPrice, getPriceImpact, getSecondKey, getSimulationComputeUnits, getSqrtPriceFromPrice, getSwapAmount, getTokenDecimals, getTokenProgram, getTotalLockedLiquidity, getUnClaimReward, isVestingComplete, mulDiv, positionByPoolFilter, pow, q64ToDecimal, unwrapSOLInstruction, vestingByPositionFilter, wrapSOLInstruction };
12540
+ export { ActivationPoint, ActivationType, type AddLiquidityParams, type AmmProgram, BASIS_POINT_MAX, type BaseFee, type BuildAddLiquidityParams, type BuildLiquidatePositionInstructionParams, type BuildRemoveAllLiquidityInstructionParams, CP_AMM_PROGRAM_ID, type ClaimPartnerFeeParams, type ClaimPositionFeeInstructionParams, type ClaimPositionFeeParams, type ClaimRewardParams, type ClosePositionInstructionParams, type ClosePositionParams, CollectFeeMode, type ConfigState, CpAmm, type CpAmm$1 as CpAmmTypes, type CreatePoolParams, type CreatePositionAndAddLiquidity, type CreatePositionParams, type DepositQuote, type DynamicFee, type DynamicFeeParams, FEE_DENOMINATOR, type FeeMode, FeeSchedulerMode, type FundRewardParams, type GetDepositQuoteParams, type GetQuoteParams, type GetWithdrawQuoteParams, type InitializeCustomizeablePoolParams, type InitializeRewardParams, LIQUIDITY_SCALE, type LiquidityDeltaParams, type LockPositionParams, MAX_CU_BUFFER, MAX_FEE_NUMERATOR, MAX_SQRT_PRICE, MIN_CU_BUFFER, MIN_SQRT_PRICE, type MergePositionParams, ONE, type PermanentLockParams, type PoolFeesParams, type PoolState, type PositionState, type PreparePoolCreationParams, type PreparePoolCreationSingleSide, type PreparedPoolCreation, type RefreshVestingParams, type RemoveAllLiquidityAndClosePositionParams, type RemoveAllLiquidityParams, type RemoveLiquidityParams, type RewardInfo, Rounding, SCALE_OFFSET, type SwapParams, type SwapQuotes, type TokenBadgeState, TradeDirection, type TxBuilder, type UpdateRewardDurationParams, type UpdateRewardFunderParams, type VestingState, type WithdrawIneligibleRewardParams, type WithdrawQuote, calculateInitSqrtPrice, calculateTransferFeeExcludedAmount, calculateTransferFeeIncludedAmount, decimalToQ64, CpAmmIDL as default, deriveClaimFeeOperatorAddress, deriveConfigAddress, deriveCustomizablePoolAddress, derivePoolAddress, derivePoolAuthority, derivePositionAddress, derivePositionNftAccount, deriveRewardVaultAddress, deriveTokenBadgeAddress, deriveTokenVaultAddress, getAllPositionNftAccountByOwner, getAllUserPositionNftAccount, getAmountAFromLiquidityDelta, getAmountBFromLiquidityDelta, getAvailableVestingLiquidity, getBaseFeeNumerator, getDynamicFeeNumerator, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getFeeNumerator, getFirstKey, getLiquidityDeltaFromAmountA, getLiquidityDeltaFromAmountB, getMaxAmountWithSlippage, getMinAmountWithSlippage, getNextSqrtPrice, getOrCreateATAInstruction, getPriceFromSqrtPrice, getPriceImpact, getSecondKey, getSimulationComputeUnits, getSqrtPriceFromPrice, getSwapAmount, getTokenDecimals, getTokenProgram, getTotalLockedLiquidity, getUnClaimReward, isVestingComplete, mulDiv, positionByPoolFilter, pow, q64ToDecimal, unwrapSOLInstruction, vestingByPositionFilter, wrapSOLInstruction };
package/dist/index.d.ts CHANGED
@@ -5625,6 +5625,11 @@ declare class CpAmm {
5625
5625
  _program: AmmProgram;
5626
5626
  private poolAuthority;
5627
5627
  constructor(connection: Connection);
5628
+ /**
5629
+ * Returns the Anchor program instance.
5630
+ * @returns The AmmProgram instance.
5631
+ */
5632
+ getProgram(): AmmProgram;
5628
5633
  /**
5629
5634
  * Prepares token accounts for a transaction by retrieving or creating associated token accounts.
5630
5635
  * @private
@@ -6084,41 +6089,6 @@ declare function getSwapAmount(inAmount: BN, sqrtPrice: BN, liquidity: BN, trade
6084
6089
  amountOut: BN;
6085
6090
  totalFee: BN;
6086
6091
  };
6087
- /**
6088
- * Converts basis points (bps) to a fee numerator
6089
- * 1 bps = 0.01% = 0.0001 in decimal
6090
- *
6091
- * @param bps - The value in basis points [1-10_000]
6092
- * @returns The equivalent fee numerator
6093
- */
6094
- declare function bpsToFeeNumerator(bps: number): number;
6095
- /**
6096
- * Converts a fee numerator back to basis points (bps)
6097
- *
6098
- * @param feeNumerator - The fee numerator to convert
6099
- * @returns The equivalent value in basis points [1-10_000]
6100
- */
6101
- declare function feeNumeratorToBps(feeNumerator: number): number;
6102
- /**
6103
- * Calculates the reduction factor for a Linear fee schedule
6104
- * Formula: fee = cliff_fee_numerator - passed_period * reduction_factor
6105
- *
6106
- * @param cliffFeeBps - The initial fee value at the cliff in basis points
6107
- * @param targetFeeBps - The desired final fee value after all periods in basis points
6108
- * @param totalPeriods - The total number of periods over which the reduction occurs
6109
- * @returns The estimate of reduction factor
6110
- */
6111
- declare function estimateLinearReductionFactor(cliffFeeBps: number, targetFeeBps: number, totalPeriods: number): number;
6112
- /**
6113
- * Calculates the reduction factor for an Exponential fee schedule
6114
- * Formula: fee_numerator = cliff_fee_numerator * (1 - reduction_factor/BASIS_POINT_MAX)^passed_period
6115
- * reduction_factor = BASIS_POINT_MAX * (1 - (fee_numerator/cliff_fee_numerator)^(1/totalPeriods))
6116
- * @param cliffFeeBps - The initial fee value at the cliff in basis points
6117
- * @param targetFeeBps - The desired final fee value after all periods in basis points
6118
- * @param totalPeriods - The total number of periods over which the reduction occurs
6119
- * @returns The estimate of reduction factor
6120
- */
6121
- declare function estimateExponentialReductionFactor(cliffFeeBps: number, targetFeeBps: number, totalPeriods: number): number;
6122
6092
 
6123
6093
  declare function getNextSqrtPrice(amount: BN, sqrtPrice: BN, liquidity: BN, aToB: boolean): BN;
6124
6094
  declare function getLiquidityDeltaFromAmountA(amountA: BN, lowerSqrtPrice: BN, // current sqrt price
@@ -12567,4 +12537,4 @@ var CpAmmIDL = {
12567
12537
  types: types
12568
12538
  };
12569
12539
 
12570
- export { ActivationPoint, ActivationType, type AddLiquidityParams, type AmmProgram, BASIS_POINT_MAX, type BaseFee, type BuildAddLiquidityParams, type BuildLiquidatePositionInstructionParams, type BuildRemoveAllLiquidityInstructionParams, CP_AMM_PROGRAM_ID, type ClaimPartnerFeeParams, type ClaimPositionFeeInstructionParams, type ClaimPositionFeeParams, type ClaimRewardParams, type ClosePositionInstructionParams, type ClosePositionParams, CollectFeeMode, type ConfigState, CpAmm, type CpAmm$1 as CpAmmTypes, type CreatePoolParams, type CreatePositionAndAddLiquidity, type CreatePositionParams, type DepositQuote, type DynamicFee, type DynamicFeeParams, FEE_DENOMINATOR, type FeeMode, FeeSchedulerMode, type FundRewardParams, type GetDepositQuoteParams, type GetQuoteParams, type GetWithdrawQuoteParams, type InitializeCustomizeablePoolParams, type InitializeRewardParams, LIQUIDITY_SCALE, type LiquidityDeltaParams, type LockPositionParams, MAX_CU_BUFFER, MAX_FEE_NUMERATOR, MAX_SQRT_PRICE, MIN_CU_BUFFER, MIN_SQRT_PRICE, type MergePositionParams, ONE, type PermanentLockParams, type PoolFeesParams, type PoolState, type PositionState, type PreparePoolCreationParams, type PreparePoolCreationSingleSide, type PreparedPoolCreation, type RefreshVestingParams, type RemoveAllLiquidityAndClosePositionParams, type RemoveAllLiquidityParams, type RemoveLiquidityParams, type RewardInfo, Rounding, SCALE_OFFSET, type SwapParams, type SwapQuotes, type TokenBadgeState, TradeDirection, type TxBuilder, type UpdateRewardDurationParams, type UpdateRewardFunderParams, type VestingState, type WithdrawIneligibleRewardParams, type WithdrawQuote, bpsToFeeNumerator, calculateInitSqrtPrice, calculateTransferFeeExcludedAmount, calculateTransferFeeIncludedAmount, decimalToQ64, CpAmmIDL as default, deriveClaimFeeOperatorAddress, deriveConfigAddress, deriveCustomizablePoolAddress, derivePoolAddress, derivePoolAuthority, derivePositionAddress, derivePositionNftAccount, deriveRewardVaultAddress, deriveTokenBadgeAddress, deriveTokenVaultAddress, estimateExponentialReductionFactor, estimateLinearReductionFactor, feeNumeratorToBps, getAllPositionNftAccountByOwner, getAllUserPositionNftAccount, getAmountAFromLiquidityDelta, getAmountBFromLiquidityDelta, getAvailableVestingLiquidity, getBaseFeeNumerator, getDynamicFeeNumerator, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getFeeNumerator, getFirstKey, getLiquidityDeltaFromAmountA, getLiquidityDeltaFromAmountB, getMaxAmountWithSlippage, getMinAmountWithSlippage, getNextSqrtPrice, getOrCreateATAInstruction, getPriceFromSqrtPrice, getPriceImpact, getSecondKey, getSimulationComputeUnits, getSqrtPriceFromPrice, getSwapAmount, getTokenDecimals, getTokenProgram, getTotalLockedLiquidity, getUnClaimReward, isVestingComplete, mulDiv, positionByPoolFilter, pow, q64ToDecimal, unwrapSOLInstruction, vestingByPositionFilter, wrapSOLInstruction };
12540
+ export { ActivationPoint, ActivationType, type AddLiquidityParams, type AmmProgram, BASIS_POINT_MAX, type BaseFee, type BuildAddLiquidityParams, type BuildLiquidatePositionInstructionParams, type BuildRemoveAllLiquidityInstructionParams, CP_AMM_PROGRAM_ID, type ClaimPartnerFeeParams, type ClaimPositionFeeInstructionParams, type ClaimPositionFeeParams, type ClaimRewardParams, type ClosePositionInstructionParams, type ClosePositionParams, CollectFeeMode, type ConfigState, CpAmm, type CpAmm$1 as CpAmmTypes, type CreatePoolParams, type CreatePositionAndAddLiquidity, type CreatePositionParams, type DepositQuote, type DynamicFee, type DynamicFeeParams, FEE_DENOMINATOR, type FeeMode, FeeSchedulerMode, type FundRewardParams, type GetDepositQuoteParams, type GetQuoteParams, type GetWithdrawQuoteParams, type InitializeCustomizeablePoolParams, type InitializeRewardParams, LIQUIDITY_SCALE, type LiquidityDeltaParams, type LockPositionParams, MAX_CU_BUFFER, MAX_FEE_NUMERATOR, MAX_SQRT_PRICE, MIN_CU_BUFFER, MIN_SQRT_PRICE, type MergePositionParams, ONE, type PermanentLockParams, type PoolFeesParams, type PoolState, type PositionState, type PreparePoolCreationParams, type PreparePoolCreationSingleSide, type PreparedPoolCreation, type RefreshVestingParams, type RemoveAllLiquidityAndClosePositionParams, type RemoveAllLiquidityParams, type RemoveLiquidityParams, type RewardInfo, Rounding, SCALE_OFFSET, type SwapParams, type SwapQuotes, type TokenBadgeState, TradeDirection, type TxBuilder, type UpdateRewardDurationParams, type UpdateRewardFunderParams, type VestingState, type WithdrawIneligibleRewardParams, type WithdrawQuote, calculateInitSqrtPrice, calculateTransferFeeExcludedAmount, calculateTransferFeeIncludedAmount, decimalToQ64, CpAmmIDL as default, deriveClaimFeeOperatorAddress, deriveConfigAddress, deriveCustomizablePoolAddress, derivePoolAddress, derivePoolAuthority, derivePositionAddress, derivePositionNftAccount, deriveRewardVaultAddress, deriveTokenBadgeAddress, deriveTokenVaultAddress, getAllPositionNftAccountByOwner, getAllUserPositionNftAccount, getAmountAFromLiquidityDelta, getAmountBFromLiquidityDelta, getAvailableVestingLiquidity, getBaseFeeNumerator, getDynamicFeeNumerator, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getFeeNumerator, getFirstKey, getLiquidityDeltaFromAmountA, getLiquidityDeltaFromAmountB, getMaxAmountWithSlippage, getMinAmountWithSlippage, getNextSqrtPrice, getOrCreateATAInstruction, getPriceFromSqrtPrice, getPriceImpact, getSecondKey, getSimulationComputeUnits, getSqrtPriceFromPrice, getSwapAmount, getTokenDecimals, getTokenProgram, getTotalLockedLiquidity, getUnClaimReward, isVestingComplete, mulDiv, positionByPoolFilter, pow, q64ToDecimal, unwrapSOLInstruction, vestingByPositionFilter, wrapSOLInstruction };
package/dist/index.js CHANGED
@@ -6886,57 +6886,6 @@ function getSwapAmount(inAmount, sqrtPrice, liquidity, tradeFeeNumerator, aToB,
6886
6886
  const amountOut = feeMode.feeOnInput ? outAmount : (totalFee = getTotalFeeOnAmount(outAmount, tradeFeeNumerator), outAmount.sub(totalFee));
6887
6887
  return { amountOut, totalFee };
6888
6888
  }
6889
- function bpsToFeeNumerator(bps) {
6890
- return bps * FEE_DENOMINATOR / BASIS_POINT_MAX;
6891
- }
6892
- function feeNumeratorToBps(feeNumerator) {
6893
- return feeNumerator * BASIS_POINT_MAX / FEE_DENOMINATOR;
6894
- }
6895
- function estimateLinearReductionFactor(cliffFeeBps, targetFeeBps, totalPeriods) {
6896
- if (totalPeriods <= 0) {
6897
- throw new Error("Total periods must be greater than zero");
6898
- }
6899
- if (cliffFeeBps > feeNumeratorToBps(MAX_FEE_NUMERATOR)) {
6900
- throw new Error(
6901
- `Cliff fee (${cliffFeeBps} bps) exceeds maximum allowed value of ${feeNumeratorToBps(
6902
- MAX_FEE_NUMERATOR
6903
- )} bps`
6904
- );
6905
- }
6906
- if (targetFeeBps > cliffFeeBps) {
6907
- throw new Error(
6908
- "Target fee must be less than or equal to cliff fee for reduction"
6909
- );
6910
- }
6911
- const cliffFeeNumerator = bpsToFeeNumerator(cliffFeeBps);
6912
- const targetFeeNumerator = bpsToFeeNumerator(targetFeeBps);
6913
- const totalReduction = cliffFeeNumerator - targetFeeNumerator;
6914
- const reductionFactor = totalReduction / totalPeriods;
6915
- return Math.floor(reductionFactor);
6916
- }
6917
- function estimateExponentialReductionFactor(cliffFeeBps, targetFeeBps, totalPeriods) {
6918
- if (totalPeriods <= 0) {
6919
- throw new Error("Total periods must be greater than zero");
6920
- }
6921
- if (cliffFeeBps > feeNumeratorToBps(MAX_FEE_NUMERATOR)) {
6922
- throw new Error(
6923
- `Cliff fee (${cliffFeeBps} bps) exceeds maximum allowed value of ${feeNumeratorToBps(
6924
- MAX_FEE_NUMERATOR
6925
- )} bps`
6926
- );
6927
- }
6928
- if (targetFeeBps > cliffFeeBps) {
6929
- throw new Error(
6930
- "Target fee bps must be less than or equal to cliff fee bps for reduction"
6931
- );
6932
- }
6933
- const cliffFeeNumerator = bpsToFeeNumerator(cliffFeeBps);
6934
- const targetFeeNumerator = bpsToFeeNumerator(targetFeeBps);
6935
- const ratio = targetFeeNumerator / cliffFeeNumerator;
6936
- const decayBase = Math.pow(ratio, 1 / totalPeriods);
6937
- const reductionFactor = BASIS_POINT_MAX * (1 - decayBase);
6938
- return Math.floor(reductionFactor);
6939
- }
6940
6889
 
6941
6890
  // src/helpers/computeUnits.ts
6942
6891
 
@@ -7236,6 +7185,13 @@ var CpAmm = class {
7236
7185
  });
7237
7186
  this.poolAuthority = derivePoolAuthority();
7238
7187
  }
7188
+ /**
7189
+ * Returns the Anchor program instance.
7190
+ * @returns The AmmProgram instance.
7191
+ */
7192
+ getProgram() {
7193
+ return this._program;
7194
+ }
7239
7195
  /**
7240
7196
  * Prepares token accounts for a transaction by retrieving or creating associated token accounts.
7241
7197
  * @private
@@ -8950,13 +8906,6 @@ var CpAmm = class {
8950
8906
  tokenAProgram,
8951
8907
  tokenBProgram
8952
8908
  );
8953
- const postInstructions = [];
8954
- if ([tokenAMint.toBase58(), tokenBMint.toBase58()].includes(
8955
- _spltoken.NATIVE_MINT.toBase58()
8956
- )) {
8957
- const closeWrappedSOLIx = yield unwrapSOLInstruction(owner);
8958
- closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
8959
- }
8960
8909
  let positionBLiquidityDelta = positionBState.unlockedLiquidity;
8961
8910
  if (positionBVestings.length > 0) {
8962
8911
  const totalAvailableVestingLiquidity = positionBVestings.reduce(
@@ -8982,6 +8931,14 @@ var CpAmm = class {
8982
8931
  refreshVestingInstruction && preInstructions.push(refreshVestingInstruction);
8983
8932
  }
8984
8933
  const transaction = new (0, _web3js.Transaction)();
8934
+ if (poolState.tokenAMint.equals(_spltoken.NATIVE_MINT)) {
8935
+ const wrapSOLIx = wrapSOLInstruction(owner, tokenAAccount, BigInt(1));
8936
+ preInstructions.push(...wrapSOLIx);
8937
+ }
8938
+ if (poolState.tokenBMint.equals(_spltoken.NATIVE_MINT)) {
8939
+ const wrapSOLIx = wrapSOLInstruction(owner, tokenBAccount, BigInt(1));
8940
+ preInstructions.push(...wrapSOLIx);
8941
+ }
8985
8942
  if (preInstructions.length > 0) {
8986
8943
  transaction.add(...preInstructions);
8987
8944
  }
@@ -9015,8 +8972,11 @@ var CpAmm = class {
9015
8972
  tokenBAmountThreshold: tokenBAmountAddLiquidityThreshold
9016
8973
  });
9017
8974
  transaction.add(addLiquidityInstruction);
9018
- if (postInstructions.length > 0) {
9019
- transaction.add(...postInstructions);
8975
+ if ([tokenAMint.toBase58(), tokenBMint.toBase58()].includes(
8976
+ _spltoken.NATIVE_MINT.toBase58()
8977
+ )) {
8978
+ const closeWrappedSOLIx = yield unwrapSOLInstruction(owner);
8979
+ closeWrappedSOLIx && transaction.add(closeWrappedSOLIx);
9020
8980
  }
9021
8981
  return transaction;
9022
8982
  });
@@ -9298,9 +9258,5 @@ var index_default = cp_amm_default;
9298
9258
 
9299
9259
 
9300
9260
 
9301
-
9302
-
9303
-
9304
-
9305
- exports.ActivationPoint = ActivationPoint; exports.ActivationType = ActivationType; exports.BASIS_POINT_MAX = BASIS_POINT_MAX; exports.CP_AMM_PROGRAM_ID = CP_AMM_PROGRAM_ID; exports.CollectFeeMode = CollectFeeMode; exports.CpAmm = CpAmm; exports.FEE_DENOMINATOR = FEE_DENOMINATOR; exports.FeeSchedulerMode = FeeSchedulerMode; exports.LIQUIDITY_SCALE = LIQUIDITY_SCALE; exports.MAX_CU_BUFFER = MAX_CU_BUFFER; exports.MAX_FEE_NUMERATOR = MAX_FEE_NUMERATOR; exports.MAX_SQRT_PRICE = MAX_SQRT_PRICE; exports.MIN_CU_BUFFER = MIN_CU_BUFFER; exports.MIN_SQRT_PRICE = MIN_SQRT_PRICE; exports.ONE = ONE; exports.Rounding = Rounding; exports.SCALE_OFFSET = SCALE_OFFSET; exports.TradeDirection = TradeDirection; exports.bpsToFeeNumerator = bpsToFeeNumerator; exports.calculateInitSqrtPrice = calculateInitSqrtPrice; exports.calculateTransferFeeExcludedAmount = calculateTransferFeeExcludedAmount; exports.calculateTransferFeeIncludedAmount = calculateTransferFeeIncludedAmount; exports.decimalToQ64 = decimalToQ64; exports.default = index_default; exports.deriveClaimFeeOperatorAddress = deriveClaimFeeOperatorAddress; exports.deriveConfigAddress = deriveConfigAddress; exports.deriveCustomizablePoolAddress = deriveCustomizablePoolAddress; exports.derivePoolAddress = derivePoolAddress; exports.derivePoolAuthority = derivePoolAuthority; exports.derivePositionAddress = derivePositionAddress; exports.derivePositionNftAccount = derivePositionNftAccount; exports.deriveRewardVaultAddress = deriveRewardVaultAddress; exports.deriveTokenBadgeAddress = deriveTokenBadgeAddress; exports.deriveTokenVaultAddress = deriveTokenVaultAddress; exports.estimateExponentialReductionFactor = estimateExponentialReductionFactor; exports.estimateLinearReductionFactor = estimateLinearReductionFactor; exports.feeNumeratorToBps = feeNumeratorToBps; exports.getAllPositionNftAccountByOwner = getAllPositionNftAccountByOwner; exports.getAllUserPositionNftAccount = getAllUserPositionNftAccount; exports.getAmountAFromLiquidityDelta = getAmountAFromLiquidityDelta; exports.getAmountBFromLiquidityDelta = getAmountBFromLiquidityDelta; exports.getAvailableVestingLiquidity = getAvailableVestingLiquidity; exports.getBaseFeeNumerator = getBaseFeeNumerator; exports.getDynamicFeeNumerator = getDynamicFeeNumerator; exports.getEstimatedComputeUnitIxWithBuffer = getEstimatedComputeUnitIxWithBuffer; exports.getEstimatedComputeUnitUsageWithBuffer = getEstimatedComputeUnitUsageWithBuffer; exports.getFeeNumerator = getFeeNumerator; exports.getFirstKey = getFirstKey; exports.getLiquidityDeltaFromAmountA = getLiquidityDeltaFromAmountA; exports.getLiquidityDeltaFromAmountB = getLiquidityDeltaFromAmountB; exports.getMaxAmountWithSlippage = getMaxAmountWithSlippage; exports.getMinAmountWithSlippage = getMinAmountWithSlippage; exports.getNextSqrtPrice = getNextSqrtPrice; exports.getOrCreateATAInstruction = getOrCreateATAInstruction; exports.getPriceFromSqrtPrice = getPriceFromSqrtPrice; exports.getPriceImpact = getPriceImpact; exports.getSecondKey = getSecondKey; exports.getSimulationComputeUnits = getSimulationComputeUnits; exports.getSqrtPriceFromPrice = getSqrtPriceFromPrice; exports.getSwapAmount = getSwapAmount; exports.getTokenDecimals = getTokenDecimals; exports.getTokenProgram = getTokenProgram; exports.getTotalLockedLiquidity = getTotalLockedLiquidity; exports.getUnClaimReward = getUnClaimReward; exports.isVestingComplete = isVestingComplete; exports.mulDiv = mulDiv; exports.positionByPoolFilter = positionByPoolFilter; exports.pow = pow; exports.q64ToDecimal = q64ToDecimal; exports.unwrapSOLInstruction = unwrapSOLInstruction; exports.vestingByPositionFilter = vestingByPositionFilter; exports.wrapSOLInstruction = wrapSOLInstruction;
9261
+ exports.ActivationPoint = ActivationPoint; exports.ActivationType = ActivationType; exports.BASIS_POINT_MAX = BASIS_POINT_MAX; exports.CP_AMM_PROGRAM_ID = CP_AMM_PROGRAM_ID; exports.CollectFeeMode = CollectFeeMode; exports.CpAmm = CpAmm; exports.FEE_DENOMINATOR = FEE_DENOMINATOR; exports.FeeSchedulerMode = FeeSchedulerMode; exports.LIQUIDITY_SCALE = LIQUIDITY_SCALE; exports.MAX_CU_BUFFER = MAX_CU_BUFFER; exports.MAX_FEE_NUMERATOR = MAX_FEE_NUMERATOR; exports.MAX_SQRT_PRICE = MAX_SQRT_PRICE; exports.MIN_CU_BUFFER = MIN_CU_BUFFER; exports.MIN_SQRT_PRICE = MIN_SQRT_PRICE; exports.ONE = ONE; exports.Rounding = Rounding; exports.SCALE_OFFSET = SCALE_OFFSET; exports.TradeDirection = TradeDirection; exports.calculateInitSqrtPrice = calculateInitSqrtPrice; exports.calculateTransferFeeExcludedAmount = calculateTransferFeeExcludedAmount; exports.calculateTransferFeeIncludedAmount = calculateTransferFeeIncludedAmount; exports.decimalToQ64 = decimalToQ64; exports.default = index_default; exports.deriveClaimFeeOperatorAddress = deriveClaimFeeOperatorAddress; exports.deriveConfigAddress = deriveConfigAddress; exports.deriveCustomizablePoolAddress = deriveCustomizablePoolAddress; exports.derivePoolAddress = derivePoolAddress; exports.derivePoolAuthority = derivePoolAuthority; exports.derivePositionAddress = derivePositionAddress; exports.derivePositionNftAccount = derivePositionNftAccount; exports.deriveRewardVaultAddress = deriveRewardVaultAddress; exports.deriveTokenBadgeAddress = deriveTokenBadgeAddress; exports.deriveTokenVaultAddress = deriveTokenVaultAddress; exports.getAllPositionNftAccountByOwner = getAllPositionNftAccountByOwner; exports.getAllUserPositionNftAccount = getAllUserPositionNftAccount; exports.getAmountAFromLiquidityDelta = getAmountAFromLiquidityDelta; exports.getAmountBFromLiquidityDelta = getAmountBFromLiquidityDelta; exports.getAvailableVestingLiquidity = getAvailableVestingLiquidity; exports.getBaseFeeNumerator = getBaseFeeNumerator; exports.getDynamicFeeNumerator = getDynamicFeeNumerator; exports.getEstimatedComputeUnitIxWithBuffer = getEstimatedComputeUnitIxWithBuffer; exports.getEstimatedComputeUnitUsageWithBuffer = getEstimatedComputeUnitUsageWithBuffer; exports.getFeeNumerator = getFeeNumerator; exports.getFirstKey = getFirstKey; exports.getLiquidityDeltaFromAmountA = getLiquidityDeltaFromAmountA; exports.getLiquidityDeltaFromAmountB = getLiquidityDeltaFromAmountB; exports.getMaxAmountWithSlippage = getMaxAmountWithSlippage; exports.getMinAmountWithSlippage = getMinAmountWithSlippage; exports.getNextSqrtPrice = getNextSqrtPrice; exports.getOrCreateATAInstruction = getOrCreateATAInstruction; exports.getPriceFromSqrtPrice = getPriceFromSqrtPrice; exports.getPriceImpact = getPriceImpact; exports.getSecondKey = getSecondKey; exports.getSimulationComputeUnits = getSimulationComputeUnits; exports.getSqrtPriceFromPrice = getSqrtPriceFromPrice; exports.getSwapAmount = getSwapAmount; exports.getTokenDecimals = getTokenDecimals; exports.getTokenProgram = getTokenProgram; exports.getTotalLockedLiquidity = getTotalLockedLiquidity; exports.getUnClaimReward = getUnClaimReward; exports.isVestingComplete = isVestingComplete; exports.mulDiv = mulDiv; exports.positionByPoolFilter = positionByPoolFilter; exports.pow = pow; exports.q64ToDecimal = q64ToDecimal; exports.unwrapSOLInstruction = unwrapSOLInstruction; exports.vestingByPositionFilter = vestingByPositionFilter; exports.wrapSOLInstruction = wrapSOLInstruction;
9306
9262
  //# sourceMappingURL=index.js.map