@meteora-ag/cp-amm-sdk 1.0.1-rc.10 → 1.0.1-rc.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -6524,6 +6524,8 @@ declare function getLiquidityDeltaFromAmountA(maxAmountA: BN, lowerSqrtPrice: BN
6524
6524
  upperSqrtPrice: BN): BN;
6525
6525
  declare function getLiquidityDeltaFromAmountB(maxAmountB: BN, lowerSqrtPrice: BN, // min sqrt price
6526
6526
  upperSqrtPrice: BN): BN;
6527
+ declare function getAmountAFromLiquidityDelta(liquidity: BN, currentSqrtPrice: BN): BN;
6528
+ declare function getAmountBFromLiquidityDelta(liquidity: BN, currentSqrtPrice: BN): BN;
6527
6529
 
6528
6530
  declare const getSimulationComputeUnits: (connection: Connection, instructions: Array<TransactionInstruction>, payer: PublicKey, lookupTables: Array<AddressLookupTableAccount> | [], commitment?: Commitment) => Promise<number | null>;
6529
6531
  /**
@@ -12705,4 +12707,4 @@ var CpAmmIDL = {
12705
12707
  types: types
12706
12708
  };
12707
12709
 
12708
- export { ActivationPoint, ActivationType, type AddLiquidityParams, type AmmProgram, BASIS_POINT_MAX, type BaseFee, CP_AMM_PROGRAM_ID, type ClaimPartnerFeeParams, type ClaimPositionFeeParams, type ClaimRewardParams, CollectFeeMode, type ConfigState, CpAmm, type CpAmm$1 as CpAmmTypes, type CreatePoolParams, type CreatePositionParams, type DynamicFee, FEE_DENOMINATOR, FeeSchedulerMode, type FundRewardParams, type GetQuoteParams, type InitializeCustomizeablePoolParams, type InitializeRewardParams, type LiquidityDeltaParams, type LockPositionParams, MAX_CU_BUFFER, MAX_FEE_NUMERATOR, MAX_SQRT_PRICE, MIN_CU_BUFFER, MIN_SQRT_PRICE, type PermanentLockParams, type PoolFeesParams, type PoolState, type PositionState, type PreparePoolCreationParams, type PreparedPoolCreation, type RefreshVestingParams, type RemoveLiquidityParams, type RewardInfo, Rounding, SCALE_OFFSET, type SwapParams, type SwapQuotes, type TokenBadgeState, TradeDirection, type TxBuilder, type UpdateRewardDurationParams, type UpdateRewardFunderParams, type VestingState, type WithdrawIneligibleRewardParams, calculateSwap, CpAmmIDL as default, deriveClaimFeeOperatorAddress, deriveConfigAddress, deriveCustomizablePoolAddress, deriveEventAuthority, derivePoolAddress, derivePoolAuthority, derivePositionAddress, derivePositionNftAccount, deriveRewardVaultAddress, deriveTokenBadgeAddress, deriveTokenVaultAddress, getBaseFeeNumerator, getDeltaAmountA, getDeltaAmountB, getDynamicFeeNumerator, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getFeeNumerator, getFirstKey, getLiquidityDeltaFromAmountA, getLiquidityDeltaFromAmountB, getNextSqrtPrice, getNftOwner, getOrCreateATAInstruction, getSecondKey, getSimulationComputeUnits, getTokenDecimals, getTokenProgram, unwrapSOLInstruction, wrapSOLInstruction };
12710
+ export { ActivationPoint, ActivationType, type AddLiquidityParams, type AmmProgram, BASIS_POINT_MAX, type BaseFee, CP_AMM_PROGRAM_ID, type ClaimPartnerFeeParams, type ClaimPositionFeeParams, type ClaimRewardParams, CollectFeeMode, type ConfigState, CpAmm, type CpAmm$1 as CpAmmTypes, type CreatePoolParams, type CreatePositionParams, type DynamicFee, FEE_DENOMINATOR, FeeSchedulerMode, type FundRewardParams, type GetQuoteParams, type InitializeCustomizeablePoolParams, type InitializeRewardParams, type LiquidityDeltaParams, type LockPositionParams, MAX_CU_BUFFER, MAX_FEE_NUMERATOR, MAX_SQRT_PRICE, MIN_CU_BUFFER, MIN_SQRT_PRICE, type PermanentLockParams, type PoolFeesParams, type PoolState, type PositionState, type PreparePoolCreationParams, type PreparedPoolCreation, type RefreshVestingParams, type RemoveLiquidityParams, type RewardInfo, Rounding, SCALE_OFFSET, type SwapParams, type SwapQuotes, type TokenBadgeState, TradeDirection, type TxBuilder, type UpdateRewardDurationParams, type UpdateRewardFunderParams, type VestingState, type WithdrawIneligibleRewardParams, calculateSwap, CpAmmIDL as default, deriveClaimFeeOperatorAddress, deriveConfigAddress, deriveCustomizablePoolAddress, deriveEventAuthority, derivePoolAddress, derivePoolAuthority, derivePositionAddress, derivePositionNftAccount, deriveRewardVaultAddress, deriveTokenBadgeAddress, deriveTokenVaultAddress, getAmountAFromLiquidityDelta, getAmountBFromLiquidityDelta, getBaseFeeNumerator, getDeltaAmountA, getDeltaAmountB, getDynamicFeeNumerator, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getFeeNumerator, getFirstKey, getLiquidityDeltaFromAmountA, getLiquidityDeltaFromAmountB, getNextSqrtPrice, getNftOwner, getOrCreateATAInstruction, getSecondKey, getSimulationComputeUnits, getTokenDecimals, getTokenProgram, unwrapSOLInstruction, wrapSOLInstruction };
package/dist/index.d.ts CHANGED
@@ -6524,6 +6524,8 @@ declare function getLiquidityDeltaFromAmountA(maxAmountA: BN, lowerSqrtPrice: BN
6524
6524
  upperSqrtPrice: BN): BN;
6525
6525
  declare function getLiquidityDeltaFromAmountB(maxAmountB: BN, lowerSqrtPrice: BN, // min sqrt price
6526
6526
  upperSqrtPrice: BN): BN;
6527
+ declare function getAmountAFromLiquidityDelta(liquidity: BN, currentSqrtPrice: BN): BN;
6528
+ declare function getAmountBFromLiquidityDelta(liquidity: BN, currentSqrtPrice: BN): BN;
6527
6529
 
6528
6530
  declare const getSimulationComputeUnits: (connection: Connection, instructions: Array<TransactionInstruction>, payer: PublicKey, lookupTables: Array<AddressLookupTableAccount> | [], commitment?: Commitment) => Promise<number | null>;
6529
6531
  /**
@@ -12705,4 +12707,4 @@ var CpAmmIDL = {
12705
12707
  types: types
12706
12708
  };
12707
12709
 
12708
- export { ActivationPoint, ActivationType, type AddLiquidityParams, type AmmProgram, BASIS_POINT_MAX, type BaseFee, CP_AMM_PROGRAM_ID, type ClaimPartnerFeeParams, type ClaimPositionFeeParams, type ClaimRewardParams, CollectFeeMode, type ConfigState, CpAmm, type CpAmm$1 as CpAmmTypes, type CreatePoolParams, type CreatePositionParams, type DynamicFee, FEE_DENOMINATOR, FeeSchedulerMode, type FundRewardParams, type GetQuoteParams, type InitializeCustomizeablePoolParams, type InitializeRewardParams, type LiquidityDeltaParams, type LockPositionParams, MAX_CU_BUFFER, MAX_FEE_NUMERATOR, MAX_SQRT_PRICE, MIN_CU_BUFFER, MIN_SQRT_PRICE, type PermanentLockParams, type PoolFeesParams, type PoolState, type PositionState, type PreparePoolCreationParams, type PreparedPoolCreation, type RefreshVestingParams, type RemoveLiquidityParams, type RewardInfo, Rounding, SCALE_OFFSET, type SwapParams, type SwapQuotes, type TokenBadgeState, TradeDirection, type TxBuilder, type UpdateRewardDurationParams, type UpdateRewardFunderParams, type VestingState, type WithdrawIneligibleRewardParams, calculateSwap, CpAmmIDL as default, deriveClaimFeeOperatorAddress, deriveConfigAddress, deriveCustomizablePoolAddress, deriveEventAuthority, derivePoolAddress, derivePoolAuthority, derivePositionAddress, derivePositionNftAccount, deriveRewardVaultAddress, deriveTokenBadgeAddress, deriveTokenVaultAddress, getBaseFeeNumerator, getDeltaAmountA, getDeltaAmountB, getDynamicFeeNumerator, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getFeeNumerator, getFirstKey, getLiquidityDeltaFromAmountA, getLiquidityDeltaFromAmountB, getNextSqrtPrice, getNftOwner, getOrCreateATAInstruction, getSecondKey, getSimulationComputeUnits, getTokenDecimals, getTokenProgram, unwrapSOLInstruction, wrapSOLInstruction };
12710
+ export { ActivationPoint, ActivationType, type AddLiquidityParams, type AmmProgram, BASIS_POINT_MAX, type BaseFee, CP_AMM_PROGRAM_ID, type ClaimPartnerFeeParams, type ClaimPositionFeeParams, type ClaimRewardParams, CollectFeeMode, type ConfigState, CpAmm, type CpAmm$1 as CpAmmTypes, type CreatePoolParams, type CreatePositionParams, type DynamicFee, FEE_DENOMINATOR, FeeSchedulerMode, type FundRewardParams, type GetQuoteParams, type InitializeCustomizeablePoolParams, type InitializeRewardParams, type LiquidityDeltaParams, type LockPositionParams, MAX_CU_BUFFER, MAX_FEE_NUMERATOR, MAX_SQRT_PRICE, MIN_CU_BUFFER, MIN_SQRT_PRICE, type PermanentLockParams, type PoolFeesParams, type PoolState, type PositionState, type PreparePoolCreationParams, type PreparedPoolCreation, type RefreshVestingParams, type RemoveLiquidityParams, type RewardInfo, Rounding, SCALE_OFFSET, type SwapParams, type SwapQuotes, type TokenBadgeState, TradeDirection, type TxBuilder, type UpdateRewardDurationParams, type UpdateRewardFunderParams, type VestingState, type WithdrawIneligibleRewardParams, calculateSwap, CpAmmIDL as default, deriveClaimFeeOperatorAddress, deriveConfigAddress, deriveCustomizablePoolAddress, deriveEventAuthority, derivePoolAddress, derivePoolAuthority, derivePositionAddress, derivePositionNftAccount, deriveRewardVaultAddress, deriveTokenBadgeAddress, deriveTokenVaultAddress, getAmountAFromLiquidityDelta, getAmountBFromLiquidityDelta, getBaseFeeNumerator, getDeltaAmountA, getDeltaAmountB, getDynamicFeeNumerator, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getFeeNumerator, getFirstKey, getLiquidityDeltaFromAmountA, getLiquidityDeltaFromAmountB, getNextSqrtPrice, getNftOwner, getOrCreateATAInstruction, getSecondKey, getSimulationComputeUnits, getTokenDecimals, getTokenProgram, unwrapSOLInstruction, wrapSOLInstruction };
package/dist/index.js CHANGED
@@ -6730,6 +6730,17 @@ function getLiquidityDeltaFromAmountB(maxAmountB, lowerSqrtPrice, upperSqrtPrice
6730
6730
  const result = maxAmountB.shln(SCALE_OFFSET * 2).div(denominator);
6731
6731
  return result;
6732
6732
  }
6733
+ function getAmountAFromLiquidityDelta(liquidity, currentSqrtPrice) {
6734
+ const prod = liquidity.mul(MAX_SQRT_PRICE.sub(currentSqrtPrice));
6735
+ const denominator = currentSqrtPrice.mul(MAX_SQRT_PRICE);
6736
+ const result = shlDiv(prod, denominator, SCALE_OFFSET, 1 /* Down */);
6737
+ return result.shrn(SCALE_OFFSET);
6738
+ }
6739
+ function getAmountBFromLiquidityDelta(liquidity, currentSqrtPrice) {
6740
+ const delta = currentSqrtPrice.sub(MIN_SQRT_PRICE);
6741
+ const prod = liquidity.mul(delta);
6742
+ return prod.shrn(SCALE_OFFSET * 2);
6743
+ }
6733
6744
 
6734
6745
  // src/utils/computeUnits.ts
6735
6746
 
@@ -7976,5 +7987,7 @@ var index_default = cp_amm_default;
7976
7987
 
7977
7988
 
7978
7989
 
7979
- exports.ActivationPoint = ActivationPoint; exports.ActivationType = ActivationType; exports.BASIS_POINT_MAX = BASIS_POINT_MAX; exports.CP_AMM_PROGRAM_ID = CP_AMM_PROGRAM_ID; exports.CollectFeeMode = CollectFeeMode; exports.CpAmm = CpAmm; exports.FEE_DENOMINATOR = FEE_DENOMINATOR; exports.FeeSchedulerMode = FeeSchedulerMode; exports.MAX_CU_BUFFER = MAX_CU_BUFFER; exports.MAX_FEE_NUMERATOR = MAX_FEE_NUMERATOR; exports.MAX_SQRT_PRICE = MAX_SQRT_PRICE; exports.MIN_CU_BUFFER = MIN_CU_BUFFER; exports.MIN_SQRT_PRICE = MIN_SQRT_PRICE; exports.Rounding = Rounding; exports.SCALE_OFFSET = SCALE_OFFSET; exports.TradeDirection = TradeDirection; exports.calculateSwap = calculateSwap; exports.default = index_default; exports.deriveClaimFeeOperatorAddress = deriveClaimFeeOperatorAddress; exports.deriveConfigAddress = deriveConfigAddress; exports.deriveCustomizablePoolAddress = deriveCustomizablePoolAddress; exports.deriveEventAuthority = deriveEventAuthority; exports.derivePoolAddress = derivePoolAddress; exports.derivePoolAuthority = derivePoolAuthority; exports.derivePositionAddress = derivePositionAddress; exports.derivePositionNftAccount = derivePositionNftAccount; exports.deriveRewardVaultAddress = deriveRewardVaultAddress; exports.deriveTokenBadgeAddress = deriveTokenBadgeAddress; exports.deriveTokenVaultAddress = deriveTokenVaultAddress; exports.getBaseFeeNumerator = getBaseFeeNumerator; exports.getDeltaAmountA = getDeltaAmountA; exports.getDeltaAmountB = getDeltaAmountB; exports.getDynamicFeeNumerator = getDynamicFeeNumerator; exports.getEstimatedComputeUnitIxWithBuffer = getEstimatedComputeUnitIxWithBuffer; exports.getEstimatedComputeUnitUsageWithBuffer = getEstimatedComputeUnitUsageWithBuffer; exports.getFeeNumerator = getFeeNumerator; exports.getFirstKey = getFirstKey; exports.getLiquidityDeltaFromAmountA = getLiquidityDeltaFromAmountA; exports.getLiquidityDeltaFromAmountB = getLiquidityDeltaFromAmountB; exports.getNextSqrtPrice = getNextSqrtPrice; exports.getNftOwner = getNftOwner; exports.getOrCreateATAInstruction = getOrCreateATAInstruction; exports.getSecondKey = getSecondKey; exports.getSimulationComputeUnits = getSimulationComputeUnits; exports.getTokenDecimals = getTokenDecimals; exports.getTokenProgram = getTokenProgram; exports.unwrapSOLInstruction = unwrapSOLInstruction; exports.wrapSOLInstruction = wrapSOLInstruction;
7990
+
7991
+
7992
+ exports.ActivationPoint = ActivationPoint; exports.ActivationType = ActivationType; exports.BASIS_POINT_MAX = BASIS_POINT_MAX; exports.CP_AMM_PROGRAM_ID = CP_AMM_PROGRAM_ID; exports.CollectFeeMode = CollectFeeMode; exports.CpAmm = CpAmm; exports.FEE_DENOMINATOR = FEE_DENOMINATOR; exports.FeeSchedulerMode = FeeSchedulerMode; exports.MAX_CU_BUFFER = MAX_CU_BUFFER; exports.MAX_FEE_NUMERATOR = MAX_FEE_NUMERATOR; exports.MAX_SQRT_PRICE = MAX_SQRT_PRICE; exports.MIN_CU_BUFFER = MIN_CU_BUFFER; exports.MIN_SQRT_PRICE = MIN_SQRT_PRICE; exports.Rounding = Rounding; exports.SCALE_OFFSET = SCALE_OFFSET; exports.TradeDirection = TradeDirection; exports.calculateSwap = calculateSwap; exports.default = index_default; exports.deriveClaimFeeOperatorAddress = deriveClaimFeeOperatorAddress; exports.deriveConfigAddress = deriveConfigAddress; exports.deriveCustomizablePoolAddress = deriveCustomizablePoolAddress; exports.deriveEventAuthority = deriveEventAuthority; exports.derivePoolAddress = derivePoolAddress; exports.derivePoolAuthority = derivePoolAuthority; exports.derivePositionAddress = derivePositionAddress; exports.derivePositionNftAccount = derivePositionNftAccount; exports.deriveRewardVaultAddress = deriveRewardVaultAddress; exports.deriveTokenBadgeAddress = deriveTokenBadgeAddress; exports.deriveTokenVaultAddress = deriveTokenVaultAddress; exports.getAmountAFromLiquidityDelta = getAmountAFromLiquidityDelta; exports.getAmountBFromLiquidityDelta = getAmountBFromLiquidityDelta; exports.getBaseFeeNumerator = getBaseFeeNumerator; exports.getDeltaAmountA = getDeltaAmountA; exports.getDeltaAmountB = getDeltaAmountB; exports.getDynamicFeeNumerator = getDynamicFeeNumerator; exports.getEstimatedComputeUnitIxWithBuffer = getEstimatedComputeUnitIxWithBuffer; exports.getEstimatedComputeUnitUsageWithBuffer = getEstimatedComputeUnitUsageWithBuffer; exports.getFeeNumerator = getFeeNumerator; exports.getFirstKey = getFirstKey; exports.getLiquidityDeltaFromAmountA = getLiquidityDeltaFromAmountA; exports.getLiquidityDeltaFromAmountB = getLiquidityDeltaFromAmountB; exports.getNextSqrtPrice = getNextSqrtPrice; exports.getNftOwner = getNftOwner; exports.getOrCreateATAInstruction = getOrCreateATAInstruction; exports.getSecondKey = getSecondKey; exports.getSimulationComputeUnits = getSimulationComputeUnits; exports.getTokenDecimals = getTokenDecimals; exports.getTokenProgram = getTokenProgram; exports.unwrapSOLInstruction = unwrapSOLInstruction; exports.wrapSOLInstruction = wrapSOLInstruction;
7980
7993
  //# sourceMappingURL=index.js.map