@meteora-ag/cp-amm-sdk 1.0.1-rc.33 → 1.0.1-rc.35

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.mjs CHANGED
@@ -21,7 +21,7 @@ var __async = (__this, __arguments, generator) => {
21
21
  };
22
22
 
23
23
  // src/CpAmm.ts
24
- import { Program, BN as BN9 } from "@coral-xyz/anchor";
24
+ import { Program, BN as BN10 } from "@coral-xyz/anchor";
25
25
  import { NATIVE_MINT as NATIVE_MINT2, TOKEN_2022_PROGRAM_ID as TOKEN_2022_PROGRAM_ID2 } from "@solana/spl-token";
26
26
  import invariant from "invariant";
27
27
 
@@ -7140,8 +7140,49 @@ function calculateTransferFeeExcludedAmount(transferFeeIncludedAmount, mint, cur
7140
7140
  };
7141
7141
  }
7142
7142
 
7143
- // src/CpAmm.ts
7143
+ // src/helpers/vestings.ts
7144
+ import { BN as BN9 } from "@coral-xyz/anchor";
7144
7145
  import { min } from "bn.js";
7146
+ function isVestingComplete(vestingData, currentPoint) {
7147
+ const cliffPoint = vestingData.cliffPoint;
7148
+ const periodFrequency = vestingData.periodFrequency;
7149
+ const numberOfPeriods = vestingData.numberOfPeriod;
7150
+ const endPoint = cliffPoint.add(periodFrequency.muln(numberOfPeriods));
7151
+ return currentPoint.gte(endPoint);
7152
+ }
7153
+ function getTotalLockedLiquidity(vestingData) {
7154
+ return vestingData.cliffUnlockLiquidity.add(
7155
+ vestingData.liquidityPerPeriod.mul(new BN9(vestingData.numberOfPeriod))
7156
+ );
7157
+ }
7158
+ function getAvailableVestingLiquidity(vestingData, currentPoint) {
7159
+ const {
7160
+ cliffPoint,
7161
+ periodFrequency,
7162
+ cliffUnlockLiquidity,
7163
+ liquidityPerPeriod,
7164
+ numberOfPeriod,
7165
+ totalReleasedLiquidity
7166
+ } = vestingData;
7167
+ if (currentPoint < cliffPoint) {
7168
+ return new BN9(0);
7169
+ }
7170
+ if (periodFrequency.isZero()) {
7171
+ return cliffUnlockLiquidity.sub(totalReleasedLiquidity);
7172
+ }
7173
+ let passedPeriod = new BN9(currentPoint).sub(cliffPoint).div(periodFrequency);
7174
+ passedPeriod = min(passedPeriod, new BN9(numberOfPeriod));
7175
+ const unlockedLiquidity = cliffUnlockLiquidity.add(
7176
+ passedPeriod.mul(liquidityPerPeriod)
7177
+ );
7178
+ const availableReleasingLiquidity = unlockedLiquidity.sub(
7179
+ totalReleasedLiquidity
7180
+ );
7181
+ return availableReleasingLiquidity;
7182
+ }
7183
+
7184
+ // src/CpAmm.ts
7185
+ import { min as min2 } from "bn.js";
7145
7186
  var CpAmm = class {
7146
7187
  constructor(connection) {
7147
7188
  this._program = new Program(cp_amm_default, {
@@ -7371,6 +7412,103 @@ var CpAmm = class {
7371
7412
  }).instruction();
7372
7413
  });
7373
7414
  }
7415
+ /**
7416
+ * Builds an instruction to refresh vesting for a position
7417
+ * @param params Parameters required for the refresh vesting instruction
7418
+ * @returns Transaction instruction or null if no vestings to refresh
7419
+ */
7420
+ buildRefreshVestingInstruction(params) {
7421
+ return __async(this, null, function* () {
7422
+ const { owner, position, positionNftAccount, pool, vestingAccounts } = params;
7423
+ if (vestingAccounts.length == 0) {
7424
+ return null;
7425
+ }
7426
+ return yield this._program.methods.refreshVesting().accountsPartial({
7427
+ position,
7428
+ positionNftAccount,
7429
+ pool,
7430
+ owner
7431
+ }).remainingAccounts(
7432
+ vestingAccounts.map((pubkey) => {
7433
+ return {
7434
+ isSigner: false,
7435
+ isWritable: true,
7436
+ pubkey
7437
+ };
7438
+ })
7439
+ ).instruction();
7440
+ });
7441
+ }
7442
+ /**
7443
+ * Helper function that builds instructions to claim fees, remove liquidity, and close a position
7444
+ * @param {BuildLiquidatePositionInstructionParams} params - Parameters for liquidating a position
7445
+ * @returns {Promise<TransactionInstruction[]>} Array of instructions
7446
+ * @private
7447
+ */
7448
+ buildLiquidatePositionInstruction(params) {
7449
+ return __async(this, null, function* () {
7450
+ const {
7451
+ owner,
7452
+ position,
7453
+ positionNftAccount,
7454
+ positionState,
7455
+ poolState,
7456
+ tokenAAccount,
7457
+ tokenBAccount,
7458
+ tokenAAmountThreshold,
7459
+ tokenBAmountThreshold
7460
+ } = params;
7461
+ const { nftMint: positionNftMint, pool } = positionState;
7462
+ const { tokenAMint, tokenBMint, tokenAVault, tokenBVault } = poolState;
7463
+ const tokenAProgram = getTokenProgram(poolState.tokenAFlag);
7464
+ const tokenBProgram = getTokenProgram(poolState.tokenBFlag);
7465
+ const instructions = [];
7466
+ const claimPositionFeeInstruction = yield this.buildClaimPositionFeeInstruction({
7467
+ owner,
7468
+ poolAuthority: this.poolAuthority,
7469
+ pool,
7470
+ position,
7471
+ positionNftAccount,
7472
+ tokenAAccount,
7473
+ tokenBAccount,
7474
+ tokenAVault,
7475
+ tokenBVault,
7476
+ tokenAMint,
7477
+ tokenBMint,
7478
+ tokenAProgram,
7479
+ tokenBProgram
7480
+ });
7481
+ instructions.push(claimPositionFeeInstruction);
7482
+ const removeAllLiquidityInstruction = yield this.buildRemoveAllLiquidityInstruction({
7483
+ poolAuthority: this.poolAuthority,
7484
+ owner,
7485
+ pool,
7486
+ position,
7487
+ positionNftAccount,
7488
+ tokenAAccount,
7489
+ tokenBAccount,
7490
+ tokenAAmountThreshold,
7491
+ tokenBAmountThreshold,
7492
+ tokenAMint,
7493
+ tokenBMint,
7494
+ tokenAVault,
7495
+ tokenBVault,
7496
+ tokenAProgram,
7497
+ tokenBProgram
7498
+ });
7499
+ instructions.push(removeAllLiquidityInstruction);
7500
+ const closePositionInstruction = yield this.buildClosePositionInstruction({
7501
+ owner,
7502
+ poolAuthority: this.poolAuthority,
7503
+ pool,
7504
+ position,
7505
+ positionNftMint,
7506
+ positionNftAccount
7507
+ });
7508
+ instructions.push(closePositionInstruction);
7509
+ return instructions;
7510
+ });
7511
+ }
7374
7512
  /**
7375
7513
  * Fetches the Config state of the program.
7376
7514
  * @param config - Public key of the config account.
@@ -7518,6 +7656,44 @@ var CpAmm = class {
7518
7656
  );
7519
7657
  return totalLockedLiquidity.gtn(0);
7520
7658
  }
7659
+ isPermanentLockedPosition(positionState) {
7660
+ return positionState.permanentLockedLiquidity.gtn(0);
7661
+ }
7662
+ /**
7663
+ * Checks if a position can be unlocked based on its locking state and vesting schedules.
7664
+ *
7665
+ * This method evaluates whether a position is eligible for operations that require
7666
+ * unlocked liquidity, such as removing all liquidity or closing the position. It checks both
7667
+ * permanent locks and time-based vesting schedules.
7668
+ *
7669
+ * @private
7670
+ * @param {PositionState} positionState - The current state of the position
7671
+ * @param {Array<{account: PublicKey; vestingState: VestingState}>} vestings - Array of vesting accounts and their states
7672
+ * @param {BN} currentPoint - Current timestamp or slot number (depending on activation type of pool)
7673
+ *
7674
+ * @returns {Object} Result object containing unlock status and reason
7675
+ * @returns {boolean} result.canUnlock - Whether the position can be unlocked
7676
+ * @returns {string|undefined} result.reason - Reason why position cannot be unlocked (if applicable)
7677
+ */
7678
+ canUnlockPosition(positionState, vestings, currentPoint) {
7679
+ if (vestings.length > 0) {
7680
+ if (this.isPermanentLockedPosition(positionState)) {
7681
+ return {
7682
+ canUnlock: false,
7683
+ reason: "Position is permanently locked"
7684
+ };
7685
+ }
7686
+ for (const vesting of vestings) {
7687
+ if (!isVestingComplete(vesting.vestingState, currentPoint)) {
7688
+ return {
7689
+ canUnlock: false,
7690
+ reason: "Position has incomplete vesting schedule"
7691
+ };
7692
+ }
7693
+ }
7694
+ }
7695
+ return { canUnlock: true };
7696
+ }
7521
7697
  isPoolExist(pool) {
7522
7698
  return __async(this, null, function* () {
7523
7699
  const poolState = yield this._program.account.pool.fetchNullable(pool);
@@ -7590,22 +7766,25 @@ var CpAmm = class {
7590
7766
  aToB,
7591
7767
  collectFeeMode
7592
7768
  );
7593
- let actualAmoutOut = amountOut;
7769
+ let actualAmountOut = amountOut;
7594
7770
  if (outputTokenInfo) {
7595
- actualAmoutOut = calculateTransferFeeExcludedAmount(
7771
+ actualAmountOut = calculateTransferFeeExcludedAmount(
7596
7772
  amountOut,
7597
7773
  outputTokenInfo.mint,
7598
7774
  outputTokenInfo.currentEpoch
7599
7775
  ).amount;
7600
7776
  }
7601
- const minSwapOutAmount = getMinAmountWithSlippage(actualAmoutOut, slippage);
7777
+ const minSwapOutAmount = getMinAmountWithSlippage(
7778
+ actualAmountOut,
7779
+ slippage
7780
+ );
7602
7781
  return {
7603
7782
  swapInAmount: inAmount,
7604
7783
  consumedInAmount: actualAmountIn,
7605
- swapOutAmount: actualAmoutOut,
7784
+ swapOutAmount: actualAmountOut,
7606
7785
  minSwapOutAmount,
7607
7786
  totalFee,
7608
- priceImpact: getPriceImpact(minSwapOutAmount, actualAmoutOut)
7787
+ priceImpact: getPriceImpact(minSwapOutAmount, actualAmountOut)
7609
7788
  };
7610
7789
  });
7611
7790
  }
@@ -7662,7 +7841,7 @@ var CpAmm = class {
7662
7841
  0 /* Up */
7663
7842
  )
7664
7843
  };
7665
- const rawOutputAmount = new BN9(rawAmount(liquidityDelta));
7844
+ const rawOutputAmount = new BN10(rawAmount(liquidityDelta));
7666
7845
  const outputAmount = outputTokenInfo ? calculateTransferFeeIncludedAmount(
7667
7846
  rawOutputAmount,
7668
7847
  outputTokenInfo.mint,
@@ -7772,7 +7951,7 @@ var CpAmm = class {
7772
7951
  tokenAInfo,
7773
7952
  tokenBInfo
7774
7953
  } = params;
7775
- if (tokenAAmount.eq(new BN9(0)) && tokenBAmount.eq(new BN9(0))) {
7954
+ if (tokenAAmount.eq(new BN10(0)) && tokenBAmount.eq(new BN10(0))) {
7776
7955
  throw new Error("Invalid input amount");
7777
7956
  }
7778
7957
  const actualAmountAIn = tokenAInfo ? tokenAAmount.sub(
@@ -7782,13 +7961,13 @@ var CpAmm = class {
7782
7961
  tokenAInfo.currentEpoch
7783
7962
  ).transferFee
7784
7963
  ) : tokenAAmount;
7785
- const actualAmountBIn = tokenBInfo ? tokenAAmount.sub(
7964
+ const actualAmountBIn = tokenBInfo ? tokenBAmount.sub(
7786
7965
  calculateTransferFeeIncludedAmount(
7787
7966
  tokenBAmount,
7788
7967
  tokenBInfo.mint,
7789
7968
  tokenBInfo.currentEpoch
7790
7969
  ).transferFee
7791
- ) : tokenAAmount;
7970
+ ) : tokenBAmount;
7792
7971
  const initSqrtPrice = calculateInitSqrtPrice(
7793
7972
  tokenAAmount,
7794
7973
  tokenBAmount,
@@ -7805,7 +7984,7 @@ var CpAmm = class {
7805
7984
  minSqrtPrice,
7806
7985
  initSqrtPrice
7807
7986
  );
7808
- const liquidityDelta = min(
7987
+ const liquidityDelta = min2(
7809
7988
  liquidityDeltaFromAmountA,
7810
7989
  liquidityDeltaFromAmountB
7811
7990
  );
@@ -8121,7 +8300,8 @@ var CpAmm = class {
8121
8300
  tokenAVault,
8122
8301
  tokenBVault,
8123
8302
  tokenAProgram,
8124
- tokenBProgram
8303
+ tokenBProgram,
8304
+ vestings
8125
8305
  } = params;
8126
8306
  const {
8127
8307
  tokenAAta: tokenAAccount,
@@ -8141,6 +8321,16 @@ var CpAmm = class {
8141
8321
  const closeWrappedSOLIx = yield unwrapSOLInstruction(owner);
8142
8322
  closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
8143
8323
  }
8324
+ if (vestings.length > 0) {
8325
+ const refreshVestingInstruction = yield this.buildRefreshVestingInstruction({
8326
+ owner,
8327
+ position,
8328
+ positionNftAccount,
8329
+ pool,
8330
+ vestingAccounts: vestings.map((item) => item.account)
8331
+ });
8332
+ refreshVestingInstruction && preInstructions.push(refreshVestingInstruction);
8333
+ }
8144
8334
  return yield this._program.methods.removeLiquidity({
8145
8335
  liquidityDelta,
8146
8336
  tokenAAmountThreshold,
@@ -8181,7 +8371,8 @@ var CpAmm = class {
8181
8371
  tokenAVault,
8182
8372
  tokenBVault,
8183
8373
  tokenAProgram,
8184
- tokenBProgram
8374
+ tokenBProgram,
8375
+ vestings
8185
8376
  } = params;
8186
8377
  const {
8187
8378
  tokenAAta: tokenAAccount,
@@ -8201,6 +8392,16 @@ var CpAmm = class {
8201
8392
  const closeWrappedSOLIx = yield unwrapSOLInstruction(owner);
8202
8393
  closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
8203
8394
  }
8395
+ if (vestings.length > 0) {
8396
+ const refreshVestingInstruction = yield this.buildRefreshVestingInstruction({
8397
+ owner,
8398
+ position,
8399
+ positionNftAccount,
8400
+ pool,
8401
+ vestingAccounts: vestings.map((item) => item.account)
8402
+ });
8403
+ refreshVestingInstruction && preInstructions.push(refreshVestingInstruction);
8404
+ }
8204
8405
  const removeAllLiquidityInstruction = yield this.buildRemoveAllLiquidityInstruction({
8205
8406
  poolAuthority: this.poolAuthority,
8206
8407
  owner,
@@ -8358,21 +8559,8 @@ var CpAmm = class {
8358
8559
  */
8359
8560
  refreshVesting(params) {
8360
8561
  return __async(this, null, function* () {
8361
- const { owner, position, positionNftAccount, pool, vestings } = params;
8362
- return yield this._program.methods.refreshVesting().accountsPartial({
8363
- position,
8364
- positionNftAccount,
8365
- pool,
8366
- owner
8367
- }).remainingAccounts(
8368
- vestings.map((pubkey) => {
8369
- return {
8370
- isSigner: false,
8371
- isWritable: true,
8372
- pubkey
8373
- };
8374
- })
8375
- ).transaction();
8562
+ const instruction = yield this.buildRefreshVestingInstruction(params);
8563
+ return new Transaction().add(instruction);
8376
8564
  });
8377
8565
  }
8378
8566
  /**
@@ -8470,13 +8658,19 @@ var CpAmm = class {
8470
8658
  positionState,
8471
8659
  poolState,
8472
8660
  tokenAAmountThreshold,
8473
- tokenBAmountThreshold
8661
+ tokenBAmountThreshold,
8662
+ vestings,
8663
+ currentPoint
8474
8664
  } = params;
8475
- const { nftMint: positionNftMint, pool } = positionState;
8476
- const { tokenAMint, tokenBMint, tokenAVault, tokenBVault } = poolState;
8477
- const isLockedPosition = this.isLockedPosition(positionState);
8478
- if (isLockedPosition) {
8479
- throw Error("position must be unlocked");
8665
+ const { pool } = positionState;
8666
+ const { tokenAMint, tokenBMint } = poolState;
8667
+ const { canUnlock, reason } = this.canUnlockPosition(
8668
+ positionState,
8669
+ vestings,
8670
+ currentPoint
8671
+ );
8672
+ if (!canUnlock) {
8673
+ throw new Error(`Cannot remove liquidity: ${reason}`);
8480
8674
  }
8481
8675
  const tokenAProgram = getTokenProgram(poolState.tokenAFlag);
8482
8676
  const tokenBProgram = getTokenProgram(poolState.tokenBFlag);
@@ -8498,53 +8692,32 @@ var CpAmm = class {
8498
8692
  const closeWrappedSOLIx = yield unwrapSOLInstruction(owner);
8499
8693
  closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
8500
8694
  }
8695
+ if (vestings.length > 0) {
8696
+ const refreshVestingInstruction = yield this.buildRefreshVestingInstruction({
8697
+ owner,
8698
+ position,
8699
+ positionNftAccount,
8700
+ pool,
8701
+ vestingAccounts: vestings.map((item) => item.account)
8702
+ });
8703
+ refreshVestingInstruction && preInstructions.push(refreshVestingInstruction);
8704
+ }
8501
8705
  const transaction = new Transaction();
8502
8706
  if (preInstructions.length > 0) {
8503
8707
  transaction.add(...preInstructions);
8504
8708
  }
8505
- const claimPositionFeeInstruction = yield this.buildClaimPositionFeeInstruction({
8506
- owner,
8507
- poolAuthority: this.poolAuthority,
8508
- pool,
8509
- position,
8510
- positionNftAccount,
8511
- tokenAAccount,
8512
- tokenBAccount,
8513
- tokenAVault,
8514
- tokenBVault,
8515
- tokenAMint,
8516
- tokenBMint,
8517
- tokenAProgram,
8518
- tokenBProgram
8519
- });
8520
- transaction.add(claimPositionFeeInstruction);
8521
- const removeAllLiquidityInstruction = yield this.buildRemoveAllLiquidityInstruction({
8522
- poolAuthority: this.poolAuthority,
8709
+ const liquidatePositionInstructions = yield this.buildLiquidatePositionInstruction({
8523
8710
  owner,
8524
- pool,
8525
8711
  position,
8526
8712
  positionNftAccount,
8713
+ positionState,
8714
+ poolState,
8527
8715
  tokenAAccount,
8528
8716
  tokenBAccount,
8529
8717
  tokenAAmountThreshold,
8530
- tokenBAmountThreshold,
8531
- tokenAMint,
8532
- tokenBMint,
8533
- tokenAVault,
8534
- tokenBVault,
8535
- tokenAProgram,
8536
- tokenBProgram
8537
- });
8538
- transaction.add(removeAllLiquidityInstruction);
8539
- const closePositionInstruction = yield this.buildClosePositionInstruction({
8540
- owner,
8541
- poolAuthority: this.poolAuthority,
8542
- pool,
8543
- position,
8544
- positionNftMint,
8545
- positionNftAccount
8718
+ tokenBAmountThreshold
8546
8719
  });
8547
- transaction.add(closePositionInstruction);
8720
+ transaction.add(...liquidatePositionInstructions);
8548
8721
  if (postInstructions.length > 0) {
8549
8722
  transaction.add(...postInstructions);
8550
8723
  }
@@ -8576,13 +8749,18 @@ var CpAmm = class {
8576
8749
  tokenAAmountAddLiquidityThreshold,
8577
8750
  tokenBAmountAddLiquidityThreshold,
8578
8751
  tokenAAmountRemoveLiquidityThreshold,
8579
- tokenBAmountRemoveLiquidityThreshold
8752
+ tokenBAmountRemoveLiquidityThreshold,
8753
+ positionBVestings,
8754
+ currentPoint
8580
8755
  } = params;
8581
- const isLockedPosition = this.isLockedPosition(positionBState);
8582
- if (isLockedPosition) {
8583
- throw Error("position must be unlocked");
8756
+ const { canUnlock, reason } = this.canUnlockPosition(
8757
+ positionBState,
8758
+ positionBVestings,
8759
+ currentPoint
8760
+ );
8761
+ if (!canUnlock) {
8762
+ throw new Error(`Cannot remove liquidity: ${reason}`);
8584
8763
  }
8585
- const postionBLiquidityDelta = positionBState.unlockedLiquidity;
8586
8764
  const pool = positionBState.pool;
8587
8765
  const { tokenAMint, tokenBMint, tokenAVault, tokenBVault } = poolState;
8588
8766
  const tokenAProgram = getTokenProgram(poolState.tokenAFlag);
@@ -8605,44 +8783,46 @@ var CpAmm = class {
8605
8783
  const closeWrappedSOLIx = yield unwrapSOLInstruction(owner);
8606
8784
  closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
8607
8785
  }
8786
+ let positionBLiquidityDelta = positionBState.unlockedLiquidity;
8787
+ if (positionBVestings.length > 0) {
8788
+ const totalAvailableVestingLiquidity = positionBVestings.reduce(
8789
+ (total, position) => {
8790
+ const available = getAvailableVestingLiquidity(
8791
+ position.vestingState,
8792
+ currentPoint
8793
+ );
8794
+ return total.add(available);
8795
+ },
8796
+ new BN10(0)
8797
+ );
8798
+ positionBLiquidityDelta = positionBLiquidityDelta.add(
8799
+ totalAvailableVestingLiquidity
8800
+ );
8801
+ const refreshVestingInstruction = yield this.buildRefreshVestingInstruction({
8802
+ owner,
8803
+ position: positionB,
8804
+ positionNftAccount: positionBNftAccount,
8805
+ pool,
8806
+ vestingAccounts: positionBVestings.map((item) => item.account)
8807
+ });
8808
+ refreshVestingInstruction && preInstructions.push(refreshVestingInstruction);
8809
+ }
8608
8810
  const transaction = new Transaction();
8609
8811
  if (preInstructions.length > 0) {
8610
8812
  transaction.add(...preInstructions);
8611
8813
  }
8612
- const claimPositionFeeInstruction = yield this.buildClaimPositionFeeInstruction({
8613
- owner,
8614
- poolAuthority: this.poolAuthority,
8615
- pool,
8616
- position: positionB,
8617
- positionNftAccount: positionBNftAccount,
8618
- tokenAAccount,
8619
- tokenBAccount,
8620
- tokenAVault,
8621
- tokenBVault,
8622
- tokenAMint,
8623
- tokenBMint,
8624
- tokenAProgram,
8625
- tokenBProgram
8626
- });
8627
- transaction.add(claimPositionFeeInstruction);
8628
- const removeAllLiquidityInstruction = yield this.buildRemoveAllLiquidityInstruction({
8629
- poolAuthority: this.poolAuthority,
8814
+ const liquidatePositionInstructions = yield this.buildLiquidatePositionInstruction({
8630
8815
  owner,
8631
- pool,
8632
8816
  position: positionB,
8633
8817
  positionNftAccount: positionBNftAccount,
8818
+ positionState: positionBState,
8819
+ poolState,
8634
8820
  tokenAAccount,
8635
8821
  tokenBAccount,
8636
8822
  tokenAAmountThreshold: tokenAAmountRemoveLiquidityThreshold,
8637
- tokenBAmountThreshold: tokenBAmountRemoveLiquidityThreshold,
8638
- tokenAMint,
8639
- tokenBMint,
8640
- tokenAVault,
8641
- tokenBVault,
8642
- tokenAProgram,
8643
- tokenBProgram
8823
+ tokenBAmountThreshold: tokenBAmountRemoveLiquidityThreshold
8644
8824
  });
8645
- transaction.add(removeAllLiquidityInstruction);
8825
+ transaction.add(...liquidatePositionInstructions);
8646
8826
  const addLiquidityInstruction = yield this.buildAddLiquidityInstruction({
8647
8827
  pool,
8648
8828
  position: positionA,
@@ -8656,20 +8836,11 @@ var CpAmm = class {
8656
8836
  tokenBVault,
8657
8837
  tokenAProgram,
8658
8838
  tokenBProgram,
8659
- liquidityDelta: postionBLiquidityDelta,
8839
+ liquidityDelta: positionBLiquidityDelta,
8660
8840
  tokenAAmountThreshold: tokenAAmountAddLiquidityThreshold,
8661
8841
  tokenBAmountThreshold: tokenBAmountAddLiquidityThreshold
8662
8842
  });
8663
8843
  transaction.add(addLiquidityInstruction);
8664
- const closePositionInstruction = yield this.buildClosePositionInstruction({
8665
- owner,
8666
- poolAuthority: this.poolAuthority,
8667
- pool: positionBState.pool,
8668
- position: positionB,
8669
- positionNftMint: positionBState.nftMint,
8670
- positionNftAccount: positionBNftAccount
8671
- });
8672
- transaction.add(closePositionInstruction);
8673
8844
  if (postInstructions.length > 0) {
8674
8845
  transaction.add(...postInstructions);
8675
8846
  }
@@ -8924,6 +9095,7 @@ export {
8924
9095
  getAllUserPositionNftAccount,
8925
9096
  getAmountAFromLiquidityDelta,
8926
9097
  getAmountBFromLiquidityDelta,
9098
+ getAvailableVestingLiquidity,
8927
9099
  getBaseFeeNumerator,
8928
9100
  getDynamicFeeNumerator,
8929
9101
  getEstimatedComputeUnitIxWithBuffer,
@@ -8945,7 +9117,9 @@ export {
8945
9117
  getSwapAmount,
8946
9118
  getTokenDecimals,
8947
9119
  getTokenProgram,
9120
+ getTotalLockedLiquidity,
8948
9121
  getUnClaimReward,
9122
+ isVestingComplete,
8949
9123
  mulDiv,
8950
9124
  positionByPoolFilter,
8951
9125
  pow,