@meteora-ag/cp-amm-sdk 1.0.1-rc.25 → 1.0.1-rc.27
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 +223 -2
- package/dist/index.d.ts +223 -2
- package/dist/index.js +765 -313
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +766 -314
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -5294,14 +5294,80 @@ type LiquidityDeltaParams = {
|
|
|
5294
5294
|
currentEpoch: number;
|
|
5295
5295
|
};
|
|
5296
5296
|
};
|
|
5297
|
-
type RemoveLiquidityParams =
|
|
5297
|
+
type RemoveLiquidityParams = {
|
|
5298
|
+
owner: PublicKey;
|
|
5299
|
+
position: PublicKey;
|
|
5300
|
+
pool: PublicKey;
|
|
5301
|
+
positionNftMint: PublicKey;
|
|
5302
|
+
liquidityDeltaQ64: BN;
|
|
5303
|
+
tokenAAmountThreshold: BN;
|
|
5304
|
+
tokenBAmountThreshold: BN;
|
|
5305
|
+
tokenAMint: PublicKey;
|
|
5306
|
+
tokenBMint: PublicKey;
|
|
5307
|
+
tokenAVault: PublicKey;
|
|
5308
|
+
tokenBVault: PublicKey;
|
|
5309
|
+
tokenAProgram: PublicKey;
|
|
5310
|
+
tokenBProgram: PublicKey;
|
|
5311
|
+
};
|
|
5298
5312
|
type RemoveAllLiquidityParams = Omit<RemoveLiquidityParams, "liquidityDeltaQ64">;
|
|
5313
|
+
type BuildAddLiquidityParams = {
|
|
5314
|
+
owner: PublicKey;
|
|
5315
|
+
position: PublicKey;
|
|
5316
|
+
pool: PublicKey;
|
|
5317
|
+
positionNftAccount: PublicKey;
|
|
5318
|
+
liquidityDelta: BN;
|
|
5319
|
+
tokenAAccount: PublicKey;
|
|
5320
|
+
tokenBAccount: PublicKey;
|
|
5321
|
+
tokenAAmountThreshold: BN;
|
|
5322
|
+
tokenBAmountThreshold: BN;
|
|
5323
|
+
tokenAMint: PublicKey;
|
|
5324
|
+
tokenBMint: PublicKey;
|
|
5325
|
+
tokenAVault: PublicKey;
|
|
5326
|
+
tokenBVault: PublicKey;
|
|
5327
|
+
tokenAProgram: PublicKey;
|
|
5328
|
+
tokenBProgram: PublicKey;
|
|
5329
|
+
};
|
|
5330
|
+
type BuildRemoveAllLiquidityInstructionParams = {
|
|
5331
|
+
poolAuthority: PublicKey;
|
|
5332
|
+
owner: PublicKey;
|
|
5333
|
+
position: PublicKey;
|
|
5334
|
+
pool: PublicKey;
|
|
5335
|
+
positionNftAccount: PublicKey;
|
|
5336
|
+
tokenAAccount: PublicKey;
|
|
5337
|
+
tokenBAccount: PublicKey;
|
|
5338
|
+
tokenAAmountThreshold: BN;
|
|
5339
|
+
tokenBAmountThreshold: BN;
|
|
5340
|
+
tokenAMint: PublicKey;
|
|
5341
|
+
tokenBMint: PublicKey;
|
|
5342
|
+
tokenAVault: PublicKey;
|
|
5343
|
+
tokenBVault: PublicKey;
|
|
5344
|
+
tokenAProgram: PublicKey;
|
|
5345
|
+
tokenBProgram: PublicKey;
|
|
5346
|
+
};
|
|
5299
5347
|
type ClosePositionParams = {
|
|
5300
5348
|
owner: PublicKey;
|
|
5301
5349
|
pool: PublicKey;
|
|
5302
5350
|
position: PublicKey;
|
|
5303
5351
|
positionNftMint: PublicKey;
|
|
5304
5352
|
};
|
|
5353
|
+
type RemoveAllLiquidityAndClosePositionParams = {
|
|
5354
|
+
owner: PublicKey;
|
|
5355
|
+
position: PublicKey;
|
|
5356
|
+
poolState: PoolState;
|
|
5357
|
+
positionState: PositionState;
|
|
5358
|
+
tokenAAmountThreshold: BN;
|
|
5359
|
+
tokenBAmountThreshold: BN;
|
|
5360
|
+
};
|
|
5361
|
+
type MergePositionParams = {
|
|
5362
|
+
owner: PublicKey;
|
|
5363
|
+
positionA: PublicKey;
|
|
5364
|
+
positionB: PublicKey;
|
|
5365
|
+
poolState: PoolState;
|
|
5366
|
+
positionAState: PositionState;
|
|
5367
|
+
positionBState: PositionState;
|
|
5368
|
+
tokenAAmountThreshold: BN;
|
|
5369
|
+
tokenBAmountThreshold: BN;
|
|
5370
|
+
};
|
|
5305
5371
|
type GetQuoteParams = {
|
|
5306
5372
|
inAmount: BN;
|
|
5307
5373
|
inputTokenMint: PublicKey;
|
|
@@ -5351,6 +5417,21 @@ type LockPositionParams = {
|
|
|
5351
5417
|
liquidityPerPeriod: BN;
|
|
5352
5418
|
numberOfPeriod: number;
|
|
5353
5419
|
};
|
|
5420
|
+
type ClaimPositionFeeInstructionParams = {
|
|
5421
|
+
owner: PublicKey;
|
|
5422
|
+
poolAuthority: PublicKey;
|
|
5423
|
+
pool: PublicKey;
|
|
5424
|
+
position: PublicKey;
|
|
5425
|
+
positionNftAccount: PublicKey;
|
|
5426
|
+
tokenAAccount: PublicKey;
|
|
5427
|
+
tokenBAccount: PublicKey;
|
|
5428
|
+
tokenAVault: PublicKey;
|
|
5429
|
+
tokenBVault: PublicKey;
|
|
5430
|
+
tokenAMint: PublicKey;
|
|
5431
|
+
tokenBMint: PublicKey;
|
|
5432
|
+
tokenAProgram: PublicKey;
|
|
5433
|
+
tokenBProgram: PublicKey;
|
|
5434
|
+
};
|
|
5354
5435
|
type ClaimPositionFeeParams = {
|
|
5355
5436
|
owner: PublicKey;
|
|
5356
5437
|
position: PublicKey;
|
|
@@ -5363,6 +5444,14 @@ type ClaimPositionFeeParams = {
|
|
|
5363
5444
|
tokenAProgram: PublicKey;
|
|
5364
5445
|
tokenBProgram: PublicKey;
|
|
5365
5446
|
};
|
|
5447
|
+
type ClosePositionInstructionParams = {
|
|
5448
|
+
owner: PublicKey;
|
|
5449
|
+
poolAuthority: PublicKey;
|
|
5450
|
+
pool: PublicKey;
|
|
5451
|
+
position: PublicKey;
|
|
5452
|
+
positionNftMint: PublicKey;
|
|
5453
|
+
positionNftAccount: PublicKey;
|
|
5454
|
+
};
|
|
5366
5455
|
type InitializeRewardParams = {
|
|
5367
5456
|
rewardIndex: number;
|
|
5368
5457
|
rewardDuration: BN;
|
|
@@ -5419,6 +5508,46 @@ type PermanentLockParams = {
|
|
|
5419
5508
|
pool: PublicKey;
|
|
5420
5509
|
unlockedLiquidity: BN;
|
|
5421
5510
|
};
|
|
5511
|
+
type GetDepositQuoteParams = {
|
|
5512
|
+
inAmount: BN;
|
|
5513
|
+
isTokenA: boolean;
|
|
5514
|
+
minSqrtPrice: BN;
|
|
5515
|
+
maxSqrtPrice: BN;
|
|
5516
|
+
sqrtPrice: BN;
|
|
5517
|
+
inputTokenInfo?: {
|
|
5518
|
+
mint: Mint;
|
|
5519
|
+
currentEpoch: number;
|
|
5520
|
+
};
|
|
5521
|
+
outputTokenInfo?: {
|
|
5522
|
+
mint: Mint;
|
|
5523
|
+
currentEpoch: number;
|
|
5524
|
+
};
|
|
5525
|
+
};
|
|
5526
|
+
type GetWithdrawQuoteParams = {
|
|
5527
|
+
liquidityDelta: BN;
|
|
5528
|
+
minSqrtPrice: BN;
|
|
5529
|
+
maxSqrtPrice: BN;
|
|
5530
|
+
sqrtPrice: BN;
|
|
5531
|
+
tokenATokenInfo?: {
|
|
5532
|
+
mint: Mint;
|
|
5533
|
+
currentEpoch: number;
|
|
5534
|
+
};
|
|
5535
|
+
tokenBTokenInfo?: {
|
|
5536
|
+
mint: Mint;
|
|
5537
|
+
currentEpoch: number;
|
|
5538
|
+
};
|
|
5539
|
+
};
|
|
5540
|
+
type DepositQuote = {
|
|
5541
|
+
actualInputAmount: BN;
|
|
5542
|
+
consumedInputAmount: BN;
|
|
5543
|
+
outputAmount: BN;
|
|
5544
|
+
liquidityDelta: BN;
|
|
5545
|
+
};
|
|
5546
|
+
type WithdrawQuote = {
|
|
5547
|
+
liquidityDelta: BN;
|
|
5548
|
+
outAmountA: BN;
|
|
5549
|
+
outAmountB: BN;
|
|
5550
|
+
};
|
|
5422
5551
|
|
|
5423
5552
|
/**
|
|
5424
5553
|
* CpAmm SDK class to interact with the Dynamic CP-AMM
|
|
@@ -5438,6 +5567,18 @@ declare class CpAmm {
|
|
|
5438
5567
|
* @returns init sqrt price and liquidity in Q64 format.
|
|
5439
5568
|
*/
|
|
5440
5569
|
private preparePoolCreationParams;
|
|
5570
|
+
/**
|
|
5571
|
+
* Prepares token accounts for a transaction by retrieving or creating associated token accounts.
|
|
5572
|
+
* @private
|
|
5573
|
+
* @param {PublicKey} owner - The owner of the token accounts
|
|
5574
|
+
* @param {PublicKey} tokenAMint - Mint address of token A
|
|
5575
|
+
* @param {PublicKey} tokenBMint - Mint address of token B
|
|
5576
|
+
* @param {PublicKey} tokenAProgram - Program ID for token A (Token or Token2022)
|
|
5577
|
+
* @param {PublicKey} tokenBProgram - Program ID for token B (Token or Token2022)
|
|
5578
|
+
* @returns {Promise<{tokenAAta: PublicKey, tokenBAta: PublicKey, instructions: TransactionInstruction[]}>}
|
|
5579
|
+
* The token account addresses and any instructions needed to create them
|
|
5580
|
+
*/
|
|
5581
|
+
private prepareTokenAccounts;
|
|
5441
5582
|
/**
|
|
5442
5583
|
* Derives token badge account metadata
|
|
5443
5584
|
* @param tokenAMint - Public key of token A mint
|
|
@@ -5445,6 +5586,34 @@ declare class CpAmm {
|
|
|
5445
5586
|
* @returns Array of account metadata for token badges
|
|
5446
5587
|
*/
|
|
5447
5588
|
private getTokenBadgeAccounts;
|
|
5589
|
+
/**
|
|
5590
|
+
* Builds an instruction to add liquidity to a position.
|
|
5591
|
+
* @private
|
|
5592
|
+
* @param {BuildAddLiquidityParams} params - Parameters for adding liquidity
|
|
5593
|
+
* @returns {Promise<TransactionInstruction>} Instruction to add liquidity
|
|
5594
|
+
*/
|
|
5595
|
+
private buildAddLiquidityInstruction;
|
|
5596
|
+
/**
|
|
5597
|
+
* Builds an instruction to remove all liquidity from a position.
|
|
5598
|
+
* @private
|
|
5599
|
+
* @param {BuildRemoveAllLiquidityInstructionParams} params - Parameters for removing all liquidity
|
|
5600
|
+
* @returns {Promise<TransactionInstruction>} Instruction to remove all liquidity
|
|
5601
|
+
*/
|
|
5602
|
+
private buildRemoveAllLiquidityInstruction;
|
|
5603
|
+
/**
|
|
5604
|
+
* Builds an instruction to claim fees accumulated by a position.
|
|
5605
|
+
* @private
|
|
5606
|
+
* @param {ClaimPositionFeeInstructionParams} params - Parameters for claiming position fees
|
|
5607
|
+
* @returns {Promise<TransactionInstruction>} Instruction to claim position fees
|
|
5608
|
+
*/
|
|
5609
|
+
private buildClaimPositionFeeInstruction;
|
|
5610
|
+
/**
|
|
5611
|
+
* Builds an instruction to close a position.
|
|
5612
|
+
* @private
|
|
5613
|
+
* @param {ClosePositionInstructionParams} params - Parameters for closing a position
|
|
5614
|
+
* @returns {Promise<TransactionInstruction>} Instruction to close the position
|
|
5615
|
+
*/
|
|
5616
|
+
private buildClosePositionInstruction;
|
|
5448
5617
|
/**
|
|
5449
5618
|
* Fetches the Config state of the program.
|
|
5450
5619
|
* @param config - Public key of the config account.
|
|
@@ -5519,6 +5688,8 @@ declare class CpAmm {
|
|
|
5519
5688
|
publicKey: PublicKey;
|
|
5520
5689
|
account: VestingState;
|
|
5521
5690
|
}>>;
|
|
5691
|
+
isLockedPosition(position: PositionState): boolean;
|
|
5692
|
+
isPoolExist(pool: PublicKey): Promise<boolean>;
|
|
5522
5693
|
/**
|
|
5523
5694
|
* Calculates swap quote based on input amount and pool state.
|
|
5524
5695
|
* @param params - Swap parameters including input amount, pool state, slippage, etc.
|
|
@@ -5532,6 +5703,31 @@ declare class CpAmm {
|
|
|
5532
5703
|
totalFee: BN;
|
|
5533
5704
|
priceImpact: number;
|
|
5534
5705
|
}>;
|
|
5706
|
+
/**
|
|
5707
|
+
* Calculates the deposit quote for liquidity pool.
|
|
5708
|
+
*
|
|
5709
|
+
* @param {GetDepositQuoteParams} params - The parameters for calculating the deposit quote.
|
|
5710
|
+
*
|
|
5711
|
+
* @returns {Promise<Object>} Deposit quote results
|
|
5712
|
+
* @returns {BN} returns.actualInputAmount - The actual amount used as input (after deducting transfer fees).
|
|
5713
|
+
* @returns {BN} returns.outputAmount - The calculated corresponding amount of the other token.
|
|
5714
|
+
* @returns {BN} returns.liquidityDelta - The amount of liquidity that will be added to the pool.
|
|
5715
|
+
*/
|
|
5716
|
+
getDepositQuote(params: GetDepositQuoteParams): Promise<DepositQuote>;
|
|
5717
|
+
/**
|
|
5718
|
+
* Calculates the withdrawal quote for removing liquidity from a concentrated liquidity pool.
|
|
5719
|
+
*
|
|
5720
|
+
* @param {GetWithdrawQuoteParams} params - The parameters for calculating the withdraw quote
|
|
5721
|
+
*
|
|
5722
|
+
* @param {Object|null} params.tokenATokenInfo - must provide if token a is token2022
|
|
5723
|
+
* @param {Object|null} params.tokenBTokenInfo - must provide if token b is token2022
|
|
5724
|
+
*
|
|
5725
|
+
* @returns {Promise<Object>} Withdrawal quote results
|
|
5726
|
+
* @returns {BN} returns.liquidityDelta - The amount of liquidity that will be removed from the pool
|
|
5727
|
+
* @returns {BN} returns.outAmountA - The calculated amount of token A to be received (after deducting transfer fees)
|
|
5728
|
+
* @returns {BN} returns.outAmountB - The calculated amount of token B to be received (after deducting transfer fees)
|
|
5729
|
+
*/
|
|
5730
|
+
getWithdrawQuote(params: GetWithdrawQuoteParams): Promise<WithdrawQuote>;
|
|
5535
5731
|
/**
|
|
5536
5732
|
* Computes the liquidity delta based on the provided token amounts and pool state.
|
|
5537
5733
|
*
|
|
@@ -5610,6 +5806,31 @@ declare class CpAmm {
|
|
|
5610
5806
|
*/
|
|
5611
5807
|
claimPositionFee(params: ClaimPositionFeeParams): TxBuilder;
|
|
5612
5808
|
closePosition(params: ClosePositionParams): TxBuilder;
|
|
5809
|
+
/**
|
|
5810
|
+
* Builds a transaction to remove all liquidity from a position and close it.
|
|
5811
|
+
* This combines several operations in a single transaction:
|
|
5812
|
+
* 1. Claims any accumulated fees
|
|
5813
|
+
* 2. Removes all liquidity
|
|
5814
|
+
* 3. Closes the position
|
|
5815
|
+
*
|
|
5816
|
+
* @param {RemoveAllLiquidityAndClosePositionParams} params - Combined parameters
|
|
5817
|
+
* @returns {TxBuilder} Transaction builder with all required instructions
|
|
5818
|
+
* @throws {Error} If the position is locked or cannot be closed
|
|
5819
|
+
*/
|
|
5820
|
+
removeAllLiquidityAndClosePosition(params: RemoveAllLiquidityAndClosePositionParams): TxBuilder;
|
|
5821
|
+
/**
|
|
5822
|
+
* Builds a transaction to merge liquidity from one position into another.
|
|
5823
|
+
* This process:
|
|
5824
|
+
* 1. Claims fees from the source position
|
|
5825
|
+
* 2. Removes all liquidity from the source position
|
|
5826
|
+
* 3. Adds that liquidity to the target position
|
|
5827
|
+
* 4. Closes the source position
|
|
5828
|
+
*
|
|
5829
|
+
* @param {MergePositionParams} params - Parameters for merging positions
|
|
5830
|
+
* @returns {TxBuilder} Transaction builder with all required instructions
|
|
5831
|
+
* @throws {Error} If either position is locked or incompatible
|
|
5832
|
+
*/
|
|
5833
|
+
mergePosition(params: MergePositionParams): TxBuilder;
|
|
5613
5834
|
/**
|
|
5614
5835
|
* Builds a transaction to update reward duration.
|
|
5615
5836
|
* @param {UpdateRewardDurationParams} params - Parameters including pool and new duration.
|
|
@@ -12163,4 +12384,4 @@ var CpAmmIDL = {
|
|
|
12163
12384
|
types: types
|
|
12164
12385
|
};
|
|
12165
12386
|
|
|
12166
|
-
export { ActivationPoint, ActivationType, type AddLiquidityParams, type AmmProgram, BASIS_POINT_MAX, type BaseFee, CP_AMM_PROGRAM_ID, type ClaimPartnerFeeParams, type ClaimPositionFeeParams, type ClaimRewardParams, type ClosePositionParams, CollectFeeMode, type ConfigState, CpAmm, type CpAmm$1 as CpAmmTypes, type CreatePoolParams, type CreatePositionParams, type DynamicFee, FEE_DENOMINATOR, type FeeMode, FeeSchedulerMode, type FundRewardParams, type GetQuoteParams, 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, ONE, PRECISION, type PermanentLockParams, type PoolFeesParams, type PoolState, type PositionState, type PreparePoolCreationParams, type PreparedPoolCreation, type RefreshVestingParams, 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, calculateInitSqrtPrice, calculateTransferFeeExcludedAmount, calculateTransferFeeIncludedAmount, decimalToQ64, CpAmmIDL as default, deriveClaimFeeOperatorAddress, deriveConfigAddress, deriveCustomizablePoolAddress, deriveEventAuthority, derivePoolAddress, derivePoolAuthority, derivePositionAddress, derivePositionNftAccount, deriveRewardVaultAddress, deriveTokenBadge, deriveTokenBadgeAddress, deriveTokenVaultAddress, divCeil, getAllNftByUser, getAmountAFromLiquidityDelta, getAmountBFromLiquidityDelta, getBaseFeeNumerator, getCurrentPrice, getDeltaAmountA, getDeltaAmountB, getDynamicFeeNumerator, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getFeeNumerator, getFirstKey, getLiquidityDeltaFromAmountA, getLiquidityDeltaFromAmountB, getMaxAmountWithSlippage, getMinAmountWithSlippage, getNextSqrtPrice, getNftOwner, getOrCreateATAInstruction, getPriceImpact, getSecondKey, getSimulationComputeUnits, getSwapAmount, getTokenDecimals, getTokenProgram, getUnClaimReward, mulDiv, mulShr, positionByPoolFilter, pow, q64ToDecimal, shlDiv, unwrapSOLInstruction, vestingByPositionFilter, wrapSOLInstruction };
|
|
12387
|
+
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 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, deriveEventAuthority, derivePoolAddress, derivePoolAuthority, derivePositionAddress, derivePositionNftAccount, deriveRewardVaultAddress, deriveTokenBadge, deriveTokenBadgeAddress, deriveTokenVaultAddress, divCeil, getAllNftByUser, getAmountAFromLiquidityDelta, getAmountBFromLiquidityDelta, getBaseFeeNumerator, getCurrentPrice, getDeltaAmountA, getDeltaAmountB, getDynamicFeeNumerator, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getFeeNumerator, getFirstKey, getLiquidityDeltaFromAmountA, getLiquidityDeltaFromAmountB, getMaxAmountWithSlippage, getMinAmountWithSlippage, getNextSqrtPrice, getNftOwner, getOrCreateATAInstruction, getPriceImpact, getSecondKey, getSimulationComputeUnits, getSwapAmount, getTokenDecimals, getTokenProgram, getUnClaimReward, mulDiv, mulShr, positionByPoolFilter, pow, q64ToDecimal, shlDiv, unwrapSOLInstruction, vestingByPositionFilter, wrapSOLInstruction };
|
package/dist/index.d.ts
CHANGED
|
@@ -5294,14 +5294,80 @@ type LiquidityDeltaParams = {
|
|
|
5294
5294
|
currentEpoch: number;
|
|
5295
5295
|
};
|
|
5296
5296
|
};
|
|
5297
|
-
type RemoveLiquidityParams =
|
|
5297
|
+
type RemoveLiquidityParams = {
|
|
5298
|
+
owner: PublicKey;
|
|
5299
|
+
position: PublicKey;
|
|
5300
|
+
pool: PublicKey;
|
|
5301
|
+
positionNftMint: PublicKey;
|
|
5302
|
+
liquidityDeltaQ64: BN;
|
|
5303
|
+
tokenAAmountThreshold: BN;
|
|
5304
|
+
tokenBAmountThreshold: BN;
|
|
5305
|
+
tokenAMint: PublicKey;
|
|
5306
|
+
tokenBMint: PublicKey;
|
|
5307
|
+
tokenAVault: PublicKey;
|
|
5308
|
+
tokenBVault: PublicKey;
|
|
5309
|
+
tokenAProgram: PublicKey;
|
|
5310
|
+
tokenBProgram: PublicKey;
|
|
5311
|
+
};
|
|
5298
5312
|
type RemoveAllLiquidityParams = Omit<RemoveLiquidityParams, "liquidityDeltaQ64">;
|
|
5313
|
+
type BuildAddLiquidityParams = {
|
|
5314
|
+
owner: PublicKey;
|
|
5315
|
+
position: PublicKey;
|
|
5316
|
+
pool: PublicKey;
|
|
5317
|
+
positionNftAccount: PublicKey;
|
|
5318
|
+
liquidityDelta: BN;
|
|
5319
|
+
tokenAAccount: PublicKey;
|
|
5320
|
+
tokenBAccount: PublicKey;
|
|
5321
|
+
tokenAAmountThreshold: BN;
|
|
5322
|
+
tokenBAmountThreshold: BN;
|
|
5323
|
+
tokenAMint: PublicKey;
|
|
5324
|
+
tokenBMint: PublicKey;
|
|
5325
|
+
tokenAVault: PublicKey;
|
|
5326
|
+
tokenBVault: PublicKey;
|
|
5327
|
+
tokenAProgram: PublicKey;
|
|
5328
|
+
tokenBProgram: PublicKey;
|
|
5329
|
+
};
|
|
5330
|
+
type BuildRemoveAllLiquidityInstructionParams = {
|
|
5331
|
+
poolAuthority: PublicKey;
|
|
5332
|
+
owner: PublicKey;
|
|
5333
|
+
position: PublicKey;
|
|
5334
|
+
pool: PublicKey;
|
|
5335
|
+
positionNftAccount: PublicKey;
|
|
5336
|
+
tokenAAccount: PublicKey;
|
|
5337
|
+
tokenBAccount: PublicKey;
|
|
5338
|
+
tokenAAmountThreshold: BN;
|
|
5339
|
+
tokenBAmountThreshold: BN;
|
|
5340
|
+
tokenAMint: PublicKey;
|
|
5341
|
+
tokenBMint: PublicKey;
|
|
5342
|
+
tokenAVault: PublicKey;
|
|
5343
|
+
tokenBVault: PublicKey;
|
|
5344
|
+
tokenAProgram: PublicKey;
|
|
5345
|
+
tokenBProgram: PublicKey;
|
|
5346
|
+
};
|
|
5299
5347
|
type ClosePositionParams = {
|
|
5300
5348
|
owner: PublicKey;
|
|
5301
5349
|
pool: PublicKey;
|
|
5302
5350
|
position: PublicKey;
|
|
5303
5351
|
positionNftMint: PublicKey;
|
|
5304
5352
|
};
|
|
5353
|
+
type RemoveAllLiquidityAndClosePositionParams = {
|
|
5354
|
+
owner: PublicKey;
|
|
5355
|
+
position: PublicKey;
|
|
5356
|
+
poolState: PoolState;
|
|
5357
|
+
positionState: PositionState;
|
|
5358
|
+
tokenAAmountThreshold: BN;
|
|
5359
|
+
tokenBAmountThreshold: BN;
|
|
5360
|
+
};
|
|
5361
|
+
type MergePositionParams = {
|
|
5362
|
+
owner: PublicKey;
|
|
5363
|
+
positionA: PublicKey;
|
|
5364
|
+
positionB: PublicKey;
|
|
5365
|
+
poolState: PoolState;
|
|
5366
|
+
positionAState: PositionState;
|
|
5367
|
+
positionBState: PositionState;
|
|
5368
|
+
tokenAAmountThreshold: BN;
|
|
5369
|
+
tokenBAmountThreshold: BN;
|
|
5370
|
+
};
|
|
5305
5371
|
type GetQuoteParams = {
|
|
5306
5372
|
inAmount: BN;
|
|
5307
5373
|
inputTokenMint: PublicKey;
|
|
@@ -5351,6 +5417,21 @@ type LockPositionParams = {
|
|
|
5351
5417
|
liquidityPerPeriod: BN;
|
|
5352
5418
|
numberOfPeriod: number;
|
|
5353
5419
|
};
|
|
5420
|
+
type ClaimPositionFeeInstructionParams = {
|
|
5421
|
+
owner: PublicKey;
|
|
5422
|
+
poolAuthority: PublicKey;
|
|
5423
|
+
pool: PublicKey;
|
|
5424
|
+
position: PublicKey;
|
|
5425
|
+
positionNftAccount: PublicKey;
|
|
5426
|
+
tokenAAccount: PublicKey;
|
|
5427
|
+
tokenBAccount: PublicKey;
|
|
5428
|
+
tokenAVault: PublicKey;
|
|
5429
|
+
tokenBVault: PublicKey;
|
|
5430
|
+
tokenAMint: PublicKey;
|
|
5431
|
+
tokenBMint: PublicKey;
|
|
5432
|
+
tokenAProgram: PublicKey;
|
|
5433
|
+
tokenBProgram: PublicKey;
|
|
5434
|
+
};
|
|
5354
5435
|
type ClaimPositionFeeParams = {
|
|
5355
5436
|
owner: PublicKey;
|
|
5356
5437
|
position: PublicKey;
|
|
@@ -5363,6 +5444,14 @@ type ClaimPositionFeeParams = {
|
|
|
5363
5444
|
tokenAProgram: PublicKey;
|
|
5364
5445
|
tokenBProgram: PublicKey;
|
|
5365
5446
|
};
|
|
5447
|
+
type ClosePositionInstructionParams = {
|
|
5448
|
+
owner: PublicKey;
|
|
5449
|
+
poolAuthority: PublicKey;
|
|
5450
|
+
pool: PublicKey;
|
|
5451
|
+
position: PublicKey;
|
|
5452
|
+
positionNftMint: PublicKey;
|
|
5453
|
+
positionNftAccount: PublicKey;
|
|
5454
|
+
};
|
|
5366
5455
|
type InitializeRewardParams = {
|
|
5367
5456
|
rewardIndex: number;
|
|
5368
5457
|
rewardDuration: BN;
|
|
@@ -5419,6 +5508,46 @@ type PermanentLockParams = {
|
|
|
5419
5508
|
pool: PublicKey;
|
|
5420
5509
|
unlockedLiquidity: BN;
|
|
5421
5510
|
};
|
|
5511
|
+
type GetDepositQuoteParams = {
|
|
5512
|
+
inAmount: BN;
|
|
5513
|
+
isTokenA: boolean;
|
|
5514
|
+
minSqrtPrice: BN;
|
|
5515
|
+
maxSqrtPrice: BN;
|
|
5516
|
+
sqrtPrice: BN;
|
|
5517
|
+
inputTokenInfo?: {
|
|
5518
|
+
mint: Mint;
|
|
5519
|
+
currentEpoch: number;
|
|
5520
|
+
};
|
|
5521
|
+
outputTokenInfo?: {
|
|
5522
|
+
mint: Mint;
|
|
5523
|
+
currentEpoch: number;
|
|
5524
|
+
};
|
|
5525
|
+
};
|
|
5526
|
+
type GetWithdrawQuoteParams = {
|
|
5527
|
+
liquidityDelta: BN;
|
|
5528
|
+
minSqrtPrice: BN;
|
|
5529
|
+
maxSqrtPrice: BN;
|
|
5530
|
+
sqrtPrice: BN;
|
|
5531
|
+
tokenATokenInfo?: {
|
|
5532
|
+
mint: Mint;
|
|
5533
|
+
currentEpoch: number;
|
|
5534
|
+
};
|
|
5535
|
+
tokenBTokenInfo?: {
|
|
5536
|
+
mint: Mint;
|
|
5537
|
+
currentEpoch: number;
|
|
5538
|
+
};
|
|
5539
|
+
};
|
|
5540
|
+
type DepositQuote = {
|
|
5541
|
+
actualInputAmount: BN;
|
|
5542
|
+
consumedInputAmount: BN;
|
|
5543
|
+
outputAmount: BN;
|
|
5544
|
+
liquidityDelta: BN;
|
|
5545
|
+
};
|
|
5546
|
+
type WithdrawQuote = {
|
|
5547
|
+
liquidityDelta: BN;
|
|
5548
|
+
outAmountA: BN;
|
|
5549
|
+
outAmountB: BN;
|
|
5550
|
+
};
|
|
5422
5551
|
|
|
5423
5552
|
/**
|
|
5424
5553
|
* CpAmm SDK class to interact with the Dynamic CP-AMM
|
|
@@ -5438,6 +5567,18 @@ declare class CpAmm {
|
|
|
5438
5567
|
* @returns init sqrt price and liquidity in Q64 format.
|
|
5439
5568
|
*/
|
|
5440
5569
|
private preparePoolCreationParams;
|
|
5570
|
+
/**
|
|
5571
|
+
* Prepares token accounts for a transaction by retrieving or creating associated token accounts.
|
|
5572
|
+
* @private
|
|
5573
|
+
* @param {PublicKey} owner - The owner of the token accounts
|
|
5574
|
+
* @param {PublicKey} tokenAMint - Mint address of token A
|
|
5575
|
+
* @param {PublicKey} tokenBMint - Mint address of token B
|
|
5576
|
+
* @param {PublicKey} tokenAProgram - Program ID for token A (Token or Token2022)
|
|
5577
|
+
* @param {PublicKey} tokenBProgram - Program ID for token B (Token or Token2022)
|
|
5578
|
+
* @returns {Promise<{tokenAAta: PublicKey, tokenBAta: PublicKey, instructions: TransactionInstruction[]}>}
|
|
5579
|
+
* The token account addresses and any instructions needed to create them
|
|
5580
|
+
*/
|
|
5581
|
+
private prepareTokenAccounts;
|
|
5441
5582
|
/**
|
|
5442
5583
|
* Derives token badge account metadata
|
|
5443
5584
|
* @param tokenAMint - Public key of token A mint
|
|
@@ -5445,6 +5586,34 @@ declare class CpAmm {
|
|
|
5445
5586
|
* @returns Array of account metadata for token badges
|
|
5446
5587
|
*/
|
|
5447
5588
|
private getTokenBadgeAccounts;
|
|
5589
|
+
/**
|
|
5590
|
+
* Builds an instruction to add liquidity to a position.
|
|
5591
|
+
* @private
|
|
5592
|
+
* @param {BuildAddLiquidityParams} params - Parameters for adding liquidity
|
|
5593
|
+
* @returns {Promise<TransactionInstruction>} Instruction to add liquidity
|
|
5594
|
+
*/
|
|
5595
|
+
private buildAddLiquidityInstruction;
|
|
5596
|
+
/**
|
|
5597
|
+
* Builds an instruction to remove all liquidity from a position.
|
|
5598
|
+
* @private
|
|
5599
|
+
* @param {BuildRemoveAllLiquidityInstructionParams} params - Parameters for removing all liquidity
|
|
5600
|
+
* @returns {Promise<TransactionInstruction>} Instruction to remove all liquidity
|
|
5601
|
+
*/
|
|
5602
|
+
private buildRemoveAllLiquidityInstruction;
|
|
5603
|
+
/**
|
|
5604
|
+
* Builds an instruction to claim fees accumulated by a position.
|
|
5605
|
+
* @private
|
|
5606
|
+
* @param {ClaimPositionFeeInstructionParams} params - Parameters for claiming position fees
|
|
5607
|
+
* @returns {Promise<TransactionInstruction>} Instruction to claim position fees
|
|
5608
|
+
*/
|
|
5609
|
+
private buildClaimPositionFeeInstruction;
|
|
5610
|
+
/**
|
|
5611
|
+
* Builds an instruction to close a position.
|
|
5612
|
+
* @private
|
|
5613
|
+
* @param {ClosePositionInstructionParams} params - Parameters for closing a position
|
|
5614
|
+
* @returns {Promise<TransactionInstruction>} Instruction to close the position
|
|
5615
|
+
*/
|
|
5616
|
+
private buildClosePositionInstruction;
|
|
5448
5617
|
/**
|
|
5449
5618
|
* Fetches the Config state of the program.
|
|
5450
5619
|
* @param config - Public key of the config account.
|
|
@@ -5519,6 +5688,8 @@ declare class CpAmm {
|
|
|
5519
5688
|
publicKey: PublicKey;
|
|
5520
5689
|
account: VestingState;
|
|
5521
5690
|
}>>;
|
|
5691
|
+
isLockedPosition(position: PositionState): boolean;
|
|
5692
|
+
isPoolExist(pool: PublicKey): Promise<boolean>;
|
|
5522
5693
|
/**
|
|
5523
5694
|
* Calculates swap quote based on input amount and pool state.
|
|
5524
5695
|
* @param params - Swap parameters including input amount, pool state, slippage, etc.
|
|
@@ -5532,6 +5703,31 @@ declare class CpAmm {
|
|
|
5532
5703
|
totalFee: BN;
|
|
5533
5704
|
priceImpact: number;
|
|
5534
5705
|
}>;
|
|
5706
|
+
/**
|
|
5707
|
+
* Calculates the deposit quote for liquidity pool.
|
|
5708
|
+
*
|
|
5709
|
+
* @param {GetDepositQuoteParams} params - The parameters for calculating the deposit quote.
|
|
5710
|
+
*
|
|
5711
|
+
* @returns {Promise<Object>} Deposit quote results
|
|
5712
|
+
* @returns {BN} returns.actualInputAmount - The actual amount used as input (after deducting transfer fees).
|
|
5713
|
+
* @returns {BN} returns.outputAmount - The calculated corresponding amount of the other token.
|
|
5714
|
+
* @returns {BN} returns.liquidityDelta - The amount of liquidity that will be added to the pool.
|
|
5715
|
+
*/
|
|
5716
|
+
getDepositQuote(params: GetDepositQuoteParams): Promise<DepositQuote>;
|
|
5717
|
+
/**
|
|
5718
|
+
* Calculates the withdrawal quote for removing liquidity from a concentrated liquidity pool.
|
|
5719
|
+
*
|
|
5720
|
+
* @param {GetWithdrawQuoteParams} params - The parameters for calculating the withdraw quote
|
|
5721
|
+
*
|
|
5722
|
+
* @param {Object|null} params.tokenATokenInfo - must provide if token a is token2022
|
|
5723
|
+
* @param {Object|null} params.tokenBTokenInfo - must provide if token b is token2022
|
|
5724
|
+
*
|
|
5725
|
+
* @returns {Promise<Object>} Withdrawal quote results
|
|
5726
|
+
* @returns {BN} returns.liquidityDelta - The amount of liquidity that will be removed from the pool
|
|
5727
|
+
* @returns {BN} returns.outAmountA - The calculated amount of token A to be received (after deducting transfer fees)
|
|
5728
|
+
* @returns {BN} returns.outAmountB - The calculated amount of token B to be received (after deducting transfer fees)
|
|
5729
|
+
*/
|
|
5730
|
+
getWithdrawQuote(params: GetWithdrawQuoteParams): Promise<WithdrawQuote>;
|
|
5535
5731
|
/**
|
|
5536
5732
|
* Computes the liquidity delta based on the provided token amounts and pool state.
|
|
5537
5733
|
*
|
|
@@ -5610,6 +5806,31 @@ declare class CpAmm {
|
|
|
5610
5806
|
*/
|
|
5611
5807
|
claimPositionFee(params: ClaimPositionFeeParams): TxBuilder;
|
|
5612
5808
|
closePosition(params: ClosePositionParams): TxBuilder;
|
|
5809
|
+
/**
|
|
5810
|
+
* Builds a transaction to remove all liquidity from a position and close it.
|
|
5811
|
+
* This combines several operations in a single transaction:
|
|
5812
|
+
* 1. Claims any accumulated fees
|
|
5813
|
+
* 2. Removes all liquidity
|
|
5814
|
+
* 3. Closes the position
|
|
5815
|
+
*
|
|
5816
|
+
* @param {RemoveAllLiquidityAndClosePositionParams} params - Combined parameters
|
|
5817
|
+
* @returns {TxBuilder} Transaction builder with all required instructions
|
|
5818
|
+
* @throws {Error} If the position is locked or cannot be closed
|
|
5819
|
+
*/
|
|
5820
|
+
removeAllLiquidityAndClosePosition(params: RemoveAllLiquidityAndClosePositionParams): TxBuilder;
|
|
5821
|
+
/**
|
|
5822
|
+
* Builds a transaction to merge liquidity from one position into another.
|
|
5823
|
+
* This process:
|
|
5824
|
+
* 1. Claims fees from the source position
|
|
5825
|
+
* 2. Removes all liquidity from the source position
|
|
5826
|
+
* 3. Adds that liquidity to the target position
|
|
5827
|
+
* 4. Closes the source position
|
|
5828
|
+
*
|
|
5829
|
+
* @param {MergePositionParams} params - Parameters for merging positions
|
|
5830
|
+
* @returns {TxBuilder} Transaction builder with all required instructions
|
|
5831
|
+
* @throws {Error} If either position is locked or incompatible
|
|
5832
|
+
*/
|
|
5833
|
+
mergePosition(params: MergePositionParams): TxBuilder;
|
|
5613
5834
|
/**
|
|
5614
5835
|
* Builds a transaction to update reward duration.
|
|
5615
5836
|
* @param {UpdateRewardDurationParams} params - Parameters including pool and new duration.
|
|
@@ -12163,4 +12384,4 @@ var CpAmmIDL = {
|
|
|
12163
12384
|
types: types
|
|
12164
12385
|
};
|
|
12165
12386
|
|
|
12166
|
-
export { ActivationPoint, ActivationType, type AddLiquidityParams, type AmmProgram, BASIS_POINT_MAX, type BaseFee, CP_AMM_PROGRAM_ID, type ClaimPartnerFeeParams, type ClaimPositionFeeParams, type ClaimRewardParams, type ClosePositionParams, CollectFeeMode, type ConfigState, CpAmm, type CpAmm$1 as CpAmmTypes, type CreatePoolParams, type CreatePositionParams, type DynamicFee, FEE_DENOMINATOR, type FeeMode, FeeSchedulerMode, type FundRewardParams, type GetQuoteParams, 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, ONE, PRECISION, type PermanentLockParams, type PoolFeesParams, type PoolState, type PositionState, type PreparePoolCreationParams, type PreparedPoolCreation, type RefreshVestingParams, 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, calculateInitSqrtPrice, calculateTransferFeeExcludedAmount, calculateTransferFeeIncludedAmount, decimalToQ64, CpAmmIDL as default, deriveClaimFeeOperatorAddress, deriveConfigAddress, deriveCustomizablePoolAddress, deriveEventAuthority, derivePoolAddress, derivePoolAuthority, derivePositionAddress, derivePositionNftAccount, deriveRewardVaultAddress, deriveTokenBadge, deriveTokenBadgeAddress, deriveTokenVaultAddress, divCeil, getAllNftByUser, getAmountAFromLiquidityDelta, getAmountBFromLiquidityDelta, getBaseFeeNumerator, getCurrentPrice, getDeltaAmountA, getDeltaAmountB, getDynamicFeeNumerator, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getFeeNumerator, getFirstKey, getLiquidityDeltaFromAmountA, getLiquidityDeltaFromAmountB, getMaxAmountWithSlippage, getMinAmountWithSlippage, getNextSqrtPrice, getNftOwner, getOrCreateATAInstruction, getPriceImpact, getSecondKey, getSimulationComputeUnits, getSwapAmount, getTokenDecimals, getTokenProgram, getUnClaimReward, mulDiv, mulShr, positionByPoolFilter, pow, q64ToDecimal, shlDiv, unwrapSOLInstruction, vestingByPositionFilter, wrapSOLInstruction };
|
|
12387
|
+
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 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, deriveEventAuthority, derivePoolAddress, derivePoolAuthority, derivePositionAddress, derivePositionNftAccount, deriveRewardVaultAddress, deriveTokenBadge, deriveTokenBadgeAddress, deriveTokenVaultAddress, divCeil, getAllNftByUser, getAmountAFromLiquidityDelta, getAmountBFromLiquidityDelta, getBaseFeeNumerator, getCurrentPrice, getDeltaAmountA, getDeltaAmountB, getDynamicFeeNumerator, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getFeeNumerator, getFirstKey, getLiquidityDeltaFromAmountA, getLiquidityDeltaFromAmountB, getMaxAmountWithSlippage, getMinAmountWithSlippage, getNextSqrtPrice, getNftOwner, getOrCreateATAInstruction, getPriceImpact, getSecondKey, getSimulationComputeUnits, getSwapAmount, getTokenDecimals, getTokenProgram, getUnClaimReward, mulDiv, mulShr, positionByPoolFilter, pow, q64ToDecimal, shlDiv, unwrapSOLInstruction, vestingByPositionFilter, wrapSOLInstruction };
|