@meteora-ag/cp-amm-sdk 1.0.1-rc.34 → 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.d.mts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +96 -75
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +96 -75
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -5346,6 +5346,17 @@ type BuildAddLiquidityParams = {
|
|
|
5346
5346
|
tokenAProgram: PublicKey;
|
|
5347
5347
|
tokenBProgram: PublicKey;
|
|
5348
5348
|
};
|
|
5349
|
+
type BuildLiquidatePositionInstructionParams = {
|
|
5350
|
+
owner: PublicKey;
|
|
5351
|
+
position: PublicKey;
|
|
5352
|
+
positionNftAccount: PublicKey;
|
|
5353
|
+
positionState: PositionState;
|
|
5354
|
+
poolState: PoolState;
|
|
5355
|
+
tokenAAccount: PublicKey;
|
|
5356
|
+
tokenBAccount: PublicKey;
|
|
5357
|
+
tokenAAmountThreshold: BN;
|
|
5358
|
+
tokenBAmountThreshold: BN;
|
|
5359
|
+
};
|
|
5349
5360
|
type BuildRemoveAllLiquidityInstructionParams = {
|
|
5350
5361
|
poolAuthority: PublicKey;
|
|
5351
5362
|
owner: PublicKey;
|
|
@@ -5651,6 +5662,13 @@ declare class CpAmm {
|
|
|
5651
5662
|
* @returns Transaction instruction or null if no vestings to refresh
|
|
5652
5663
|
*/
|
|
5653
5664
|
private buildRefreshVestingInstruction;
|
|
5665
|
+
/**
|
|
5666
|
+
* Helper function that builds instructions to claim fees, remove liquidity, and close a position
|
|
5667
|
+
* @param {BuildLiquidatePositionInstructionParams} params - Parameters for liquidating a position
|
|
5668
|
+
* @returns {Promise<TransactionInstruction[]>} Array of instructions
|
|
5669
|
+
* @private
|
|
5670
|
+
*/
|
|
5671
|
+
private buildLiquidatePositionInstruction;
|
|
5654
5672
|
/**
|
|
5655
5673
|
* Fetches the Config state of the program.
|
|
5656
5674
|
* @param config - Public key of the config account.
|
|
@@ -12475,4 +12493,4 @@ var CpAmmIDL = {
|
|
|
12475
12493
|
types: types
|
|
12476
12494
|
};
|
|
12477
12495
|
|
|
12478
|
-
export { ActivationPoint, ActivationType, type AddLiquidityParams, type AmmProgram, BASIS_POINT_MAX, type BaseFee, type BuildAddLiquidityParams, 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 CreatePositionParams, type DepositQuote, type DynamicFee, 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, PRECISION, 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, deriveTokenBadge, deriveTokenBadgeAddress, deriveTokenVaultAddress, divCeil, getAllUserPositionNftAccount, getAmountAFromLiquidityDelta, getAmountBFromLiquidityDelta, getAvailableVestingLiquidity, getBaseFeeNumerator, getDynamicFeeNumerator, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getFeeNumerator, getFirstKey, getLiquidityDeltaFromAmountA, getLiquidityDeltaFromAmountB, getMaxAmountWithSlippage, getMinAmountWithSlippage, getNextSqrtPrice, getNftOwner, getOrCreateATAInstruction, getPriceFromSqrtPrice, getPriceImpact, getSecondKey, getSimulationComputeUnits, getSqrtPriceFromPrice, getSwapAmount, getTokenDecimals, getTokenProgram, getTotalLockedLiquidity, getUnClaimReward, isVestingComplete, mulDiv, positionByPoolFilter, pow, q64ToDecimal, unwrapSOLInstruction, vestingByPositionFilter, wrapSOLInstruction };
|
|
12496
|
+
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 CreatePositionParams, type DepositQuote, type DynamicFee, 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, PRECISION, 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, deriveTokenBadge, deriveTokenBadgeAddress, deriveTokenVaultAddress, divCeil, getAllUserPositionNftAccount, getAmountAFromLiquidityDelta, getAmountBFromLiquidityDelta, getAvailableVestingLiquidity, getBaseFeeNumerator, getDynamicFeeNumerator, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getFeeNumerator, getFirstKey, getLiquidityDeltaFromAmountA, getLiquidityDeltaFromAmountB, getMaxAmountWithSlippage, getMinAmountWithSlippage, getNextSqrtPrice, getNftOwner, 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
|
@@ -5346,6 +5346,17 @@ type BuildAddLiquidityParams = {
|
|
|
5346
5346
|
tokenAProgram: PublicKey;
|
|
5347
5347
|
tokenBProgram: PublicKey;
|
|
5348
5348
|
};
|
|
5349
|
+
type BuildLiquidatePositionInstructionParams = {
|
|
5350
|
+
owner: PublicKey;
|
|
5351
|
+
position: PublicKey;
|
|
5352
|
+
positionNftAccount: PublicKey;
|
|
5353
|
+
positionState: PositionState;
|
|
5354
|
+
poolState: PoolState;
|
|
5355
|
+
tokenAAccount: PublicKey;
|
|
5356
|
+
tokenBAccount: PublicKey;
|
|
5357
|
+
tokenAAmountThreshold: BN;
|
|
5358
|
+
tokenBAmountThreshold: BN;
|
|
5359
|
+
};
|
|
5349
5360
|
type BuildRemoveAllLiquidityInstructionParams = {
|
|
5350
5361
|
poolAuthority: PublicKey;
|
|
5351
5362
|
owner: PublicKey;
|
|
@@ -5651,6 +5662,13 @@ declare class CpAmm {
|
|
|
5651
5662
|
* @returns Transaction instruction or null if no vestings to refresh
|
|
5652
5663
|
*/
|
|
5653
5664
|
private buildRefreshVestingInstruction;
|
|
5665
|
+
/**
|
|
5666
|
+
* Helper function that builds instructions to claim fees, remove liquidity, and close a position
|
|
5667
|
+
* @param {BuildLiquidatePositionInstructionParams} params - Parameters for liquidating a position
|
|
5668
|
+
* @returns {Promise<TransactionInstruction[]>} Array of instructions
|
|
5669
|
+
* @private
|
|
5670
|
+
*/
|
|
5671
|
+
private buildLiquidatePositionInstruction;
|
|
5654
5672
|
/**
|
|
5655
5673
|
* Fetches the Config state of the program.
|
|
5656
5674
|
* @param config - Public key of the config account.
|
|
@@ -12475,4 +12493,4 @@ var CpAmmIDL = {
|
|
|
12475
12493
|
types: types
|
|
12476
12494
|
};
|
|
12477
12495
|
|
|
12478
|
-
export { ActivationPoint, ActivationType, type AddLiquidityParams, type AmmProgram, BASIS_POINT_MAX, type BaseFee, type BuildAddLiquidityParams, 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 CreatePositionParams, type DepositQuote, type DynamicFee, 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, PRECISION, 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, deriveTokenBadge, deriveTokenBadgeAddress, deriveTokenVaultAddress, divCeil, getAllUserPositionNftAccount, getAmountAFromLiquidityDelta, getAmountBFromLiquidityDelta, getAvailableVestingLiquidity, getBaseFeeNumerator, getDynamicFeeNumerator, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getFeeNumerator, getFirstKey, getLiquidityDeltaFromAmountA, getLiquidityDeltaFromAmountB, getMaxAmountWithSlippage, getMinAmountWithSlippage, getNextSqrtPrice, getNftOwner, getOrCreateATAInstruction, getPriceFromSqrtPrice, getPriceImpact, getSecondKey, getSimulationComputeUnits, getSqrtPriceFromPrice, getSwapAmount, getTokenDecimals, getTokenProgram, getTotalLockedLiquidity, getUnClaimReward, isVestingComplete, mulDiv, positionByPoolFilter, pow, q64ToDecimal, unwrapSOLInstruction, vestingByPositionFilter, wrapSOLInstruction };
|
|
12496
|
+
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 CreatePositionParams, type DepositQuote, type DynamicFee, 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, PRECISION, 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, deriveTokenBadge, deriveTokenBadgeAddress, deriveTokenVaultAddress, divCeil, getAllUserPositionNftAccount, getAmountAFromLiquidityDelta, getAmountBFromLiquidityDelta, getAvailableVestingLiquidity, getBaseFeeNumerator, getDynamicFeeNumerator, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getFeeNumerator, getFirstKey, getLiquidityDeltaFromAmountA, getLiquidityDeltaFromAmountB, getMaxAmountWithSlippage, getMinAmountWithSlippage, getNextSqrtPrice, getNftOwner, getOrCreateATAInstruction, getPriceFromSqrtPrice, getPriceImpact, getSecondKey, getSimulationComputeUnits, getSqrtPriceFromPrice, getSwapAmount, getTokenDecimals, getTokenProgram, getTotalLockedLiquidity, getUnClaimReward, isVestingComplete, mulDiv, positionByPoolFilter, pow, q64ToDecimal, unwrapSOLInstruction, vestingByPositionFilter, wrapSOLInstruction };
|
package/dist/index.js
CHANGED
|
@@ -7439,6 +7439,76 @@ var CpAmm = class {
|
|
|
7439
7439
|
).instruction();
|
|
7440
7440
|
});
|
|
7441
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
|
+
}
|
|
7442
7512
|
/**
|
|
7443
7513
|
* Fetches the Config state of the program.
|
|
7444
7514
|
* @param config - Public key of the config account.
|
|
@@ -8592,8 +8662,8 @@ var CpAmm = class {
|
|
|
8592
8662
|
vestings,
|
|
8593
8663
|
currentPoint
|
|
8594
8664
|
} = params;
|
|
8595
|
-
const {
|
|
8596
|
-
const { tokenAMint, tokenBMint
|
|
8665
|
+
const { pool } = positionState;
|
|
8666
|
+
const { tokenAMint, tokenBMint } = poolState;
|
|
8597
8667
|
const { canUnlock, reason } = this.canUnlockPosition(
|
|
8598
8668
|
positionState,
|
|
8599
8669
|
vestings,
|
|
@@ -8636,49 +8706,18 @@ var CpAmm = class {
|
|
|
8636
8706
|
if (preInstructions.length > 0) {
|
|
8637
8707
|
transaction.add(...preInstructions);
|
|
8638
8708
|
}
|
|
8639
|
-
const
|
|
8640
|
-
owner,
|
|
8641
|
-
poolAuthority: this.poolAuthority,
|
|
8642
|
-
pool,
|
|
8643
|
-
position,
|
|
8644
|
-
positionNftAccount,
|
|
8645
|
-
tokenAAccount,
|
|
8646
|
-
tokenBAccount,
|
|
8647
|
-
tokenAVault,
|
|
8648
|
-
tokenBVault,
|
|
8649
|
-
tokenAMint,
|
|
8650
|
-
tokenBMint,
|
|
8651
|
-
tokenAProgram,
|
|
8652
|
-
tokenBProgram
|
|
8653
|
-
});
|
|
8654
|
-
transaction.add(claimPositionFeeInstruction);
|
|
8655
|
-
const removeAllLiquidityInstruction = yield this.buildRemoveAllLiquidityInstruction({
|
|
8656
|
-
poolAuthority: this.poolAuthority,
|
|
8709
|
+
const liquidatePositionInstructions = yield this.buildLiquidatePositionInstruction({
|
|
8657
8710
|
owner,
|
|
8658
|
-
pool,
|
|
8659
8711
|
position,
|
|
8660
8712
|
positionNftAccount,
|
|
8713
|
+
positionState,
|
|
8714
|
+
poolState,
|
|
8661
8715
|
tokenAAccount,
|
|
8662
8716
|
tokenBAccount,
|
|
8663
8717
|
tokenAAmountThreshold,
|
|
8664
|
-
tokenBAmountThreshold
|
|
8665
|
-
tokenAMint,
|
|
8666
|
-
tokenBMint,
|
|
8667
|
-
tokenAVault,
|
|
8668
|
-
tokenBVault,
|
|
8669
|
-
tokenAProgram,
|
|
8670
|
-
tokenBProgram
|
|
8671
|
-
});
|
|
8672
|
-
transaction.add(removeAllLiquidityInstruction);
|
|
8673
|
-
const closePositionInstruction = yield this.buildClosePositionInstruction({
|
|
8674
|
-
owner,
|
|
8675
|
-
poolAuthority: this.poolAuthority,
|
|
8676
|
-
pool,
|
|
8677
|
-
position,
|
|
8678
|
-
positionNftMint,
|
|
8679
|
-
positionNftAccount
|
|
8718
|
+
tokenBAmountThreshold
|
|
8680
8719
|
});
|
|
8681
|
-
transaction.add(
|
|
8720
|
+
transaction.add(...liquidatePositionInstructions);
|
|
8682
8721
|
if (postInstructions.length > 0) {
|
|
8683
8722
|
transaction.add(...postInstructions);
|
|
8684
8723
|
}
|
|
@@ -8722,7 +8761,6 @@ var CpAmm = class {
|
|
|
8722
8761
|
if (!canUnlock) {
|
|
8723
8762
|
throw new Error(`Cannot remove liquidity: ${reason}`);
|
|
8724
8763
|
}
|
|
8725
|
-
const positionBLiquidityDelta = positionBState.unlockedLiquidity;
|
|
8726
8764
|
const pool = positionBState.pool;
|
|
8727
8765
|
const { tokenAMint, tokenBMint, tokenAVault, tokenBVault } = poolState;
|
|
8728
8766
|
const tokenAProgram = getTokenProgram(poolState.tokenAFlag);
|
|
@@ -8745,7 +8783,21 @@ var CpAmm = class {
|
|
|
8745
8783
|
const closeWrappedSOLIx = yield unwrapSOLInstruction(owner);
|
|
8746
8784
|
closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
|
|
8747
8785
|
}
|
|
8786
|
+
let positionBLiquidityDelta = positionBState.unlockedLiquidity;
|
|
8748
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 (0, _anchor.BN)(0)
|
|
8797
|
+
);
|
|
8798
|
+
positionBLiquidityDelta = positionBLiquidityDelta.add(
|
|
8799
|
+
totalAvailableVestingLiquidity
|
|
8800
|
+
);
|
|
8749
8801
|
const refreshVestingInstruction = yield this.buildRefreshVestingInstruction({
|
|
8750
8802
|
owner,
|
|
8751
8803
|
position: positionB,
|
|
@@ -8759,40 +8811,18 @@ var CpAmm = class {
|
|
|
8759
8811
|
if (preInstructions.length > 0) {
|
|
8760
8812
|
transaction.add(...preInstructions);
|
|
8761
8813
|
}
|
|
8762
|
-
const
|
|
8814
|
+
const liquidatePositionInstructions = yield this.buildLiquidatePositionInstruction({
|
|
8763
8815
|
owner,
|
|
8764
|
-
poolAuthority: this.poolAuthority,
|
|
8765
|
-
pool,
|
|
8766
|
-
position: positionB,
|
|
8767
|
-
positionNftAccount: positionBNftAccount,
|
|
8768
|
-
tokenAAccount,
|
|
8769
|
-
tokenBAccount,
|
|
8770
|
-
tokenAVault,
|
|
8771
|
-
tokenBVault,
|
|
8772
|
-
tokenAMint,
|
|
8773
|
-
tokenBMint,
|
|
8774
|
-
tokenAProgram,
|
|
8775
|
-
tokenBProgram
|
|
8776
|
-
});
|
|
8777
|
-
transaction.add(claimPositionFeeInstruction);
|
|
8778
|
-
const removeAllLiquidityInstruction = yield this.buildRemoveAllLiquidityInstruction({
|
|
8779
|
-
poolAuthority: this.poolAuthority,
|
|
8780
|
-
owner,
|
|
8781
|
-
pool,
|
|
8782
8816
|
position: positionB,
|
|
8783
8817
|
positionNftAccount: positionBNftAccount,
|
|
8818
|
+
positionState: positionBState,
|
|
8819
|
+
poolState,
|
|
8784
8820
|
tokenAAccount,
|
|
8785
8821
|
tokenBAccount,
|
|
8786
8822
|
tokenAAmountThreshold: tokenAAmountRemoveLiquidityThreshold,
|
|
8787
|
-
tokenBAmountThreshold: tokenBAmountRemoveLiquidityThreshold
|
|
8788
|
-
tokenAMint,
|
|
8789
|
-
tokenBMint,
|
|
8790
|
-
tokenAVault,
|
|
8791
|
-
tokenBVault,
|
|
8792
|
-
tokenAProgram,
|
|
8793
|
-
tokenBProgram
|
|
8823
|
+
tokenBAmountThreshold: tokenBAmountRemoveLiquidityThreshold
|
|
8794
8824
|
});
|
|
8795
|
-
transaction.add(
|
|
8825
|
+
transaction.add(...liquidatePositionInstructions);
|
|
8796
8826
|
const addLiquidityInstruction = yield this.buildAddLiquidityInstruction({
|
|
8797
8827
|
pool,
|
|
8798
8828
|
position: positionA,
|
|
@@ -8811,15 +8841,6 @@ var CpAmm = class {
|
|
|
8811
8841
|
tokenBAmountThreshold: tokenBAmountAddLiquidityThreshold
|
|
8812
8842
|
});
|
|
8813
8843
|
transaction.add(addLiquidityInstruction);
|
|
8814
|
-
const closePositionInstruction = yield this.buildClosePositionInstruction({
|
|
8815
|
-
owner,
|
|
8816
|
-
poolAuthority: this.poolAuthority,
|
|
8817
|
-
pool: positionBState.pool,
|
|
8818
|
-
position: positionB,
|
|
8819
|
-
positionNftMint: positionBState.nftMint,
|
|
8820
|
-
positionNftAccount: positionBNftAccount
|
|
8821
|
-
});
|
|
8822
|
-
transaction.add(closePositionInstruction);
|
|
8823
8844
|
if (postInstructions.length > 0) {
|
|
8824
8845
|
transaction.add(...postInstructions);
|
|
8825
8846
|
}
|