@meteora-ag/cp-amm-sdk 1.0.1-rc.26 → 1.0.1-rc.28
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 +66 -1
- package/dist/index.d.ts +66 -1
- package/dist/index.js +176 -43
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +176 -43
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -5508,6 +5508,46 @@ type PermanentLockParams = {
|
|
|
5508
5508
|
pool: PublicKey;
|
|
5509
5509
|
unlockedLiquidity: BN;
|
|
5510
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
|
+
};
|
|
5511
5551
|
|
|
5512
5552
|
/**
|
|
5513
5553
|
* CpAmm SDK class to interact with the Dynamic CP-AMM
|
|
@@ -5663,6 +5703,31 @@ declare class CpAmm {
|
|
|
5663
5703
|
totalFee: BN;
|
|
5664
5704
|
priceImpact: number;
|
|
5665
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>;
|
|
5666
5731
|
/**
|
|
5667
5732
|
* Computes the liquidity delta based on the provided token amounts and pool state.
|
|
5668
5733
|
*
|
|
@@ -12319,4 +12384,4 @@ var CpAmmIDL = {
|
|
|
12319
12384
|
types: types
|
|
12320
12385
|
};
|
|
12321
12386
|
|
|
12322
|
-
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 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, 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, 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
|
@@ -5508,6 +5508,46 @@ type PermanentLockParams = {
|
|
|
5508
5508
|
pool: PublicKey;
|
|
5509
5509
|
unlockedLiquidity: BN;
|
|
5510
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
|
+
};
|
|
5511
5551
|
|
|
5512
5552
|
/**
|
|
5513
5553
|
* CpAmm SDK class to interact with the Dynamic CP-AMM
|
|
@@ -5663,6 +5703,31 @@ declare class CpAmm {
|
|
|
5663
5703
|
totalFee: BN;
|
|
5664
5704
|
priceImpact: number;
|
|
5665
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>;
|
|
5666
5731
|
/**
|
|
5667
5732
|
* Computes the liquidity delta based on the provided token amounts and pool state.
|
|
5668
5733
|
*
|
|
@@ -12319,4 +12384,4 @@ var CpAmmIDL = {
|
|
|
12319
12384
|
types: types
|
|
12320
12385
|
};
|
|
12321
12386
|
|
|
12322
|
-
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 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, 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, 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.js
CHANGED
|
@@ -6372,6 +6372,38 @@ var MAX_SQRT_PRICE = new (0, _anchor.BN)("79226673521066979257578248091");
|
|
|
6372
6372
|
var MIN_CU_BUFFER = 5e4;
|
|
6373
6373
|
var MAX_CU_BUFFER = 2e5;
|
|
6374
6374
|
|
|
6375
|
+
// src/types.ts
|
|
6376
|
+
var Rounding = /* @__PURE__ */ ((Rounding2) => {
|
|
6377
|
+
Rounding2[Rounding2["Up"] = 0] = "Up";
|
|
6378
|
+
Rounding2[Rounding2["Down"] = 1] = "Down";
|
|
6379
|
+
return Rounding2;
|
|
6380
|
+
})(Rounding || {});
|
|
6381
|
+
var ActivationPoint = /* @__PURE__ */ ((ActivationPoint2) => {
|
|
6382
|
+
ActivationPoint2[ActivationPoint2["Timestamp"] = 0] = "Timestamp";
|
|
6383
|
+
ActivationPoint2[ActivationPoint2["Slot"] = 1] = "Slot";
|
|
6384
|
+
return ActivationPoint2;
|
|
6385
|
+
})(ActivationPoint || {});
|
|
6386
|
+
var FeeSchedulerMode = /* @__PURE__ */ ((FeeSchedulerMode2) => {
|
|
6387
|
+
FeeSchedulerMode2[FeeSchedulerMode2["Linear"] = 0] = "Linear";
|
|
6388
|
+
FeeSchedulerMode2[FeeSchedulerMode2["Exponential"] = 1] = "Exponential";
|
|
6389
|
+
return FeeSchedulerMode2;
|
|
6390
|
+
})(FeeSchedulerMode || {});
|
|
6391
|
+
var CollectFeeMode = /* @__PURE__ */ ((CollectFeeMode3) => {
|
|
6392
|
+
CollectFeeMode3[CollectFeeMode3["BothToken"] = 0] = "BothToken";
|
|
6393
|
+
CollectFeeMode3[CollectFeeMode3["OnlyB"] = 1] = "OnlyB";
|
|
6394
|
+
return CollectFeeMode3;
|
|
6395
|
+
})(CollectFeeMode || {});
|
|
6396
|
+
var TradeDirection = /* @__PURE__ */ ((TradeDirection2) => {
|
|
6397
|
+
TradeDirection2[TradeDirection2["AtoB"] = 0] = "AtoB";
|
|
6398
|
+
TradeDirection2[TradeDirection2["BtoA"] = 1] = "BtoA";
|
|
6399
|
+
return TradeDirection2;
|
|
6400
|
+
})(TradeDirection || {});
|
|
6401
|
+
var ActivationType = /* @__PURE__ */ ((ActivationType2) => {
|
|
6402
|
+
ActivationType2[ActivationType2["Slot"] = 0] = "Slot";
|
|
6403
|
+
ActivationType2[ActivationType2["Timestamp"] = 1] = "Timestamp";
|
|
6404
|
+
return ActivationType2;
|
|
6405
|
+
})(ActivationType || {});
|
|
6406
|
+
|
|
6375
6407
|
// src/pda.ts
|
|
6376
6408
|
|
|
6377
6409
|
function getFirstKey(key1, key2) {
|
|
@@ -6590,38 +6622,6 @@ function getAllNftByUser(_0, _1) {
|
|
|
6590
6622
|
// src/helpers/fee.ts
|
|
6591
6623
|
|
|
6592
6624
|
|
|
6593
|
-
// src/types.ts
|
|
6594
|
-
var Rounding = /* @__PURE__ */ ((Rounding2) => {
|
|
6595
|
-
Rounding2[Rounding2["Up"] = 0] = "Up";
|
|
6596
|
-
Rounding2[Rounding2["Down"] = 1] = "Down";
|
|
6597
|
-
return Rounding2;
|
|
6598
|
-
})(Rounding || {});
|
|
6599
|
-
var ActivationPoint = /* @__PURE__ */ ((ActivationPoint2) => {
|
|
6600
|
-
ActivationPoint2[ActivationPoint2["Timestamp"] = 0] = "Timestamp";
|
|
6601
|
-
ActivationPoint2[ActivationPoint2["Slot"] = 1] = "Slot";
|
|
6602
|
-
return ActivationPoint2;
|
|
6603
|
-
})(ActivationPoint || {});
|
|
6604
|
-
var FeeSchedulerMode = /* @__PURE__ */ ((FeeSchedulerMode2) => {
|
|
6605
|
-
FeeSchedulerMode2[FeeSchedulerMode2["Linear"] = 0] = "Linear";
|
|
6606
|
-
FeeSchedulerMode2[FeeSchedulerMode2["Exponential"] = 1] = "Exponential";
|
|
6607
|
-
return FeeSchedulerMode2;
|
|
6608
|
-
})(FeeSchedulerMode || {});
|
|
6609
|
-
var CollectFeeMode = /* @__PURE__ */ ((CollectFeeMode3) => {
|
|
6610
|
-
CollectFeeMode3[CollectFeeMode3["BothToken"] = 0] = "BothToken";
|
|
6611
|
-
CollectFeeMode3[CollectFeeMode3["OnlyB"] = 1] = "OnlyB";
|
|
6612
|
-
return CollectFeeMode3;
|
|
6613
|
-
})(CollectFeeMode || {});
|
|
6614
|
-
var TradeDirection = /* @__PURE__ */ ((TradeDirection2) => {
|
|
6615
|
-
TradeDirection2[TradeDirection2["AtoB"] = 0] = "AtoB";
|
|
6616
|
-
TradeDirection2[TradeDirection2["BtoA"] = 1] = "BtoA";
|
|
6617
|
-
return TradeDirection2;
|
|
6618
|
-
})(TradeDirection || {});
|
|
6619
|
-
var ActivationType = /* @__PURE__ */ ((ActivationType2) => {
|
|
6620
|
-
ActivationType2[ActivationType2["Slot"] = 0] = "Slot";
|
|
6621
|
-
ActivationType2[ActivationType2["Timestamp"] = 1] = "Timestamp";
|
|
6622
|
-
return ActivationType2;
|
|
6623
|
-
})(ActivationType || {});
|
|
6624
|
-
|
|
6625
6625
|
// src/math/feeMath.ts
|
|
6626
6626
|
|
|
6627
6627
|
var MAX_EXPONENTIAL = new (0, _anchor.BN)(524288);
|
|
@@ -7652,6 +7652,123 @@ var CpAmm = class {
|
|
|
7652
7652
|
};
|
|
7653
7653
|
});
|
|
7654
7654
|
}
|
|
7655
|
+
/**
|
|
7656
|
+
* Calculates the deposit quote for liquidity pool.
|
|
7657
|
+
*
|
|
7658
|
+
* @param {GetDepositQuoteParams} params - The parameters for calculating the deposit quote.
|
|
7659
|
+
*
|
|
7660
|
+
* @returns {Promise<Object>} Deposit quote results
|
|
7661
|
+
* @returns {BN} returns.actualInputAmount - The actual amount used as input (after deducting transfer fees).
|
|
7662
|
+
* @returns {BN} returns.outputAmount - The calculated corresponding amount of the other token.
|
|
7663
|
+
* @returns {BN} returns.liquidityDelta - The amount of liquidity that will be added to the pool.
|
|
7664
|
+
*/
|
|
7665
|
+
getDepositQuote(params) {
|
|
7666
|
+
return __async(this, null, function* () {
|
|
7667
|
+
const {
|
|
7668
|
+
inAmount,
|
|
7669
|
+
isTokenA,
|
|
7670
|
+
inputTokenInfo,
|
|
7671
|
+
outputTokenInfo,
|
|
7672
|
+
minSqrtPrice,
|
|
7673
|
+
maxSqrtPrice,
|
|
7674
|
+
sqrtPrice
|
|
7675
|
+
} = params;
|
|
7676
|
+
const actualAmountIn = inputTokenInfo ? inAmount.sub(
|
|
7677
|
+
calculateTransferFeeIncludedAmount(
|
|
7678
|
+
inAmount,
|
|
7679
|
+
inputTokenInfo.mint,
|
|
7680
|
+
inputTokenInfo.currentEpoch
|
|
7681
|
+
).transferFee
|
|
7682
|
+
) : inAmount;
|
|
7683
|
+
const { liquidityDelta, rawAmount } = isTokenA ? {
|
|
7684
|
+
liquidityDelta: getLiquidityDeltaFromAmountA(
|
|
7685
|
+
actualAmountIn,
|
|
7686
|
+
sqrtPrice,
|
|
7687
|
+
maxSqrtPrice
|
|
7688
|
+
),
|
|
7689
|
+
rawAmount: (delta) => getAmountBFromLiquidityDelta(
|
|
7690
|
+
delta,
|
|
7691
|
+
sqrtPrice,
|
|
7692
|
+
minSqrtPrice,
|
|
7693
|
+
0 /* Up */
|
|
7694
|
+
)
|
|
7695
|
+
} : {
|
|
7696
|
+
liquidityDelta: getLiquidityDeltaFromAmountB(
|
|
7697
|
+
actualAmountIn,
|
|
7698
|
+
minSqrtPrice,
|
|
7699
|
+
sqrtPrice
|
|
7700
|
+
),
|
|
7701
|
+
rawAmount: (delta) => getAmountAFromLiquidityDelta(
|
|
7702
|
+
delta,
|
|
7703
|
+
sqrtPrice,
|
|
7704
|
+
maxSqrtPrice,
|
|
7705
|
+
0 /* Up */
|
|
7706
|
+
)
|
|
7707
|
+
};
|
|
7708
|
+
const rawOutputAmount = new (0, _anchor.BN)(rawAmount(liquidityDelta));
|
|
7709
|
+
const outputAmount = outputTokenInfo ? calculateTransferFeeIncludedAmount(
|
|
7710
|
+
rawOutputAmount,
|
|
7711
|
+
outputTokenInfo.mint,
|
|
7712
|
+
outputTokenInfo.currentEpoch
|
|
7713
|
+
).amount : rawOutputAmount;
|
|
7714
|
+
return {
|
|
7715
|
+
actualInputAmount: actualAmountIn,
|
|
7716
|
+
consumedInputAmount: inAmount,
|
|
7717
|
+
liquidityDelta,
|
|
7718
|
+
outputAmount
|
|
7719
|
+
};
|
|
7720
|
+
});
|
|
7721
|
+
}
|
|
7722
|
+
/**
|
|
7723
|
+
* Calculates the withdrawal quote for removing liquidity from a concentrated liquidity pool.
|
|
7724
|
+
*
|
|
7725
|
+
* @param {GetWithdrawQuoteParams} params - The parameters for calculating the withdraw quote
|
|
7726
|
+
*
|
|
7727
|
+
* @param {Object|null} params.tokenATokenInfo - must provide if token a is token2022
|
|
7728
|
+
* @param {Object|null} params.tokenBTokenInfo - must provide if token b is token2022
|
|
7729
|
+
*
|
|
7730
|
+
* @returns {Promise<Object>} Withdrawal quote results
|
|
7731
|
+
* @returns {BN} returns.liquidityDelta - The amount of liquidity that will be removed from the pool
|
|
7732
|
+
* @returns {BN} returns.outAmountA - The calculated amount of token A to be received (after deducting transfer fees)
|
|
7733
|
+
* @returns {BN} returns.outAmountB - The calculated amount of token B to be received (after deducting transfer fees)
|
|
7734
|
+
*/
|
|
7735
|
+
getWithdrawQuote(params) {
|
|
7736
|
+
return __async(this, null, function* () {
|
|
7737
|
+
const {
|
|
7738
|
+
liquidityDelta,
|
|
7739
|
+
sqrtPrice,
|
|
7740
|
+
maxSqrtPrice,
|
|
7741
|
+
minSqrtPrice,
|
|
7742
|
+
tokenATokenInfo,
|
|
7743
|
+
tokenBTokenInfo
|
|
7744
|
+
} = params;
|
|
7745
|
+
const amountA = getAmountAFromLiquidityDelta(
|
|
7746
|
+
liquidityDelta,
|
|
7747
|
+
sqrtPrice,
|
|
7748
|
+
maxSqrtPrice,
|
|
7749
|
+
1 /* Down */
|
|
7750
|
+
);
|
|
7751
|
+
const amountB = getAmountBFromLiquidityDelta(
|
|
7752
|
+
liquidityDelta,
|
|
7753
|
+
sqrtPrice,
|
|
7754
|
+
minSqrtPrice,
|
|
7755
|
+
1 /* Down */
|
|
7756
|
+
);
|
|
7757
|
+
return {
|
|
7758
|
+
liquidityDelta,
|
|
7759
|
+
outAmountA: tokenATokenInfo ? calculateTransferFeeExcludedAmount(
|
|
7760
|
+
new (0, _anchor.BN)(amountA),
|
|
7761
|
+
tokenATokenInfo.mint,
|
|
7762
|
+
tokenATokenInfo.currentEpoch
|
|
7763
|
+
).amount : new (0, _anchor.BN)(amountA),
|
|
7764
|
+
outAmountB: tokenBTokenInfo ? calculateTransferFeeExcludedAmount(
|
|
7765
|
+
new (0, _anchor.BN)(amountB),
|
|
7766
|
+
tokenBTokenInfo.mint,
|
|
7767
|
+
tokenBTokenInfo.currentEpoch
|
|
7768
|
+
).amount : new (0, _anchor.BN)(amountB)
|
|
7769
|
+
};
|
|
7770
|
+
});
|
|
7771
|
+
}
|
|
7655
7772
|
/**
|
|
7656
7773
|
* Computes the liquidity delta based on the provided token amounts and pool state.
|
|
7657
7774
|
*
|
|
@@ -8049,9 +8166,11 @@ var CpAmm = class {
|
|
|
8049
8166
|
tokenBAmountThreshold
|
|
8050
8167
|
});
|
|
8051
8168
|
const transaction = new (0, _web3js.Transaction)();
|
|
8052
|
-
transaction.add(
|
|
8053
|
-
|
|
8054
|
-
|
|
8169
|
+
transaction.add(
|
|
8170
|
+
...preInstructions.length > 0 ? preInstructions : [],
|
|
8171
|
+
addLiquidityInstruction,
|
|
8172
|
+
...postInstructions.length > 0 ? postInstructions : []
|
|
8173
|
+
);
|
|
8055
8174
|
return transaction;
|
|
8056
8175
|
});
|
|
8057
8176
|
}
|
|
@@ -8183,9 +8302,11 @@ var CpAmm = class {
|
|
|
8183
8302
|
tokenBProgram
|
|
8184
8303
|
});
|
|
8185
8304
|
const transaction = new (0, _web3js.Transaction)();
|
|
8186
|
-
transaction.add(
|
|
8187
|
-
|
|
8188
|
-
|
|
8305
|
+
transaction.add(
|
|
8306
|
+
...preInstructions.length > 0 ? preInstructions : [],
|
|
8307
|
+
removeAllLiquidityInstruction,
|
|
8308
|
+
...postInstructions.length > 0 ? postInstructions : []
|
|
8309
|
+
);
|
|
8189
8310
|
return transaction;
|
|
8190
8311
|
});
|
|
8191
8312
|
}
|
|
@@ -8408,9 +8529,11 @@ var CpAmm = class {
|
|
|
8408
8529
|
tokenBProgram
|
|
8409
8530
|
});
|
|
8410
8531
|
const transaction = new (0, _web3js.Transaction)();
|
|
8411
|
-
transaction.add(
|
|
8412
|
-
|
|
8413
|
-
|
|
8532
|
+
transaction.add(
|
|
8533
|
+
...preInstructions.length > 0 ? preInstructions : [],
|
|
8534
|
+
claimPositionFeeInstruction,
|
|
8535
|
+
...postInstructions.length > 0 ? postInstructions : []
|
|
8536
|
+
);
|
|
8414
8537
|
return transaction;
|
|
8415
8538
|
});
|
|
8416
8539
|
}
|
|
@@ -8486,7 +8609,9 @@ var CpAmm = class {
|
|
|
8486
8609
|
closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
|
|
8487
8610
|
}
|
|
8488
8611
|
const transaction = new (0, _web3js.Transaction)();
|
|
8489
|
-
|
|
8612
|
+
if (preInstructions.length > 0) {
|
|
8613
|
+
transaction.add(...preInstructions);
|
|
8614
|
+
}
|
|
8490
8615
|
const claimPositionFeeInstruction = yield this.buildClaimPositionFeeInstruction({
|
|
8491
8616
|
owner,
|
|
8492
8617
|
poolAuthority,
|
|
@@ -8530,6 +8655,9 @@ var CpAmm = class {
|
|
|
8530
8655
|
positionNftAccount
|
|
8531
8656
|
});
|
|
8532
8657
|
transaction.add(closePositionInstruction);
|
|
8658
|
+
if (postInstructions.length > 0) {
|
|
8659
|
+
transaction.add(...postInstructions);
|
|
8660
|
+
}
|
|
8533
8661
|
return transaction;
|
|
8534
8662
|
});
|
|
8535
8663
|
}
|
|
@@ -8594,7 +8722,9 @@ var CpAmm = class {
|
|
|
8594
8722
|
closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
|
|
8595
8723
|
}
|
|
8596
8724
|
const transaction = new (0, _web3js.Transaction)();
|
|
8597
|
-
|
|
8725
|
+
if (preInstructions.length > 0) {
|
|
8726
|
+
transaction.add(...preInstructions);
|
|
8727
|
+
}
|
|
8598
8728
|
const claimPositionFeeInstruction = yield this.buildClaimPositionFeeInstruction({
|
|
8599
8729
|
owner,
|
|
8600
8730
|
poolAuthority,
|
|
@@ -8656,6 +8786,9 @@ var CpAmm = class {
|
|
|
8656
8786
|
positionNftAccount: positionBNftAccount
|
|
8657
8787
|
});
|
|
8658
8788
|
transaction.add(closePositionInstruction);
|
|
8789
|
+
if (postInstructions.length > 0) {
|
|
8790
|
+
transaction.add(...postInstructions);
|
|
8791
|
+
}
|
|
8659
8792
|
return transaction;
|
|
8660
8793
|
});
|
|
8661
8794
|
}
|