@meteora-ag/cp-amm-sdk 1.0.0-rc.6 → 1.0.0-rc.7
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 +36 -6
- package/dist/index.d.ts +36 -6
- package/dist/index.js +56 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -5625,11 +5625,6 @@ declare class CpAmm {
|
|
|
5625
5625
|
_program: AmmProgram;
|
|
5626
5626
|
private poolAuthority;
|
|
5627
5627
|
constructor(connection: Connection);
|
|
5628
|
-
/**
|
|
5629
|
-
* Returns the Anchor program instance.
|
|
5630
|
-
* @returns The AmmProgram instance.
|
|
5631
|
-
*/
|
|
5632
|
-
getProgram(): AmmProgram;
|
|
5633
5628
|
/**
|
|
5634
5629
|
* Prepares token accounts for a transaction by retrieving or creating associated token accounts.
|
|
5635
5630
|
* @private
|
|
@@ -6089,6 +6084,41 @@ declare function getSwapAmount(inAmount: BN, sqrtPrice: BN, liquidity: BN, trade
|
|
|
6089
6084
|
amountOut: BN;
|
|
6090
6085
|
totalFee: BN;
|
|
6091
6086
|
};
|
|
6087
|
+
/**
|
|
6088
|
+
* Converts basis points (bps) to a fee numerator
|
|
6089
|
+
* 1 bps = 0.01% = 0.0001 in decimal
|
|
6090
|
+
*
|
|
6091
|
+
* @param bps - The value in basis points [1-10_000]
|
|
6092
|
+
* @returns The equivalent fee numerator
|
|
6093
|
+
*/
|
|
6094
|
+
declare function bpsToFeeNumerator(bps: number): number;
|
|
6095
|
+
/**
|
|
6096
|
+
* Converts a fee numerator back to basis points (bps)
|
|
6097
|
+
*
|
|
6098
|
+
* @param feeNumerator - The fee numerator to convert
|
|
6099
|
+
* @returns The equivalent value in basis points [1-10_000]
|
|
6100
|
+
*/
|
|
6101
|
+
declare function feeNumeratorToBps(feeNumerator: number): number;
|
|
6102
|
+
/**
|
|
6103
|
+
* Calculates the reduction factor for a Linear fee schedule
|
|
6104
|
+
* Formula: fee = cliff_fee_numerator - passed_period * reduction_factor
|
|
6105
|
+
*
|
|
6106
|
+
* @param cliffFeeBps - The initial fee value at the cliff in basis points
|
|
6107
|
+
* @param targetFeeBps - The desired final fee value after all periods in basis points
|
|
6108
|
+
* @param totalPeriods - The total number of periods over which the reduction occurs
|
|
6109
|
+
* @returns The estimate of reduction factor
|
|
6110
|
+
*/
|
|
6111
|
+
declare function estimateLinearReductionFactor(cliffFeeBps: number, targetFeeBps: number, totalPeriods: number): number;
|
|
6112
|
+
/**
|
|
6113
|
+
* Calculates the reduction factor for an Exponential fee schedule
|
|
6114
|
+
* Formula: fee_numerator = cliff_fee_numerator * (1 - reduction_factor/BASIS_POINT_MAX)^passed_period
|
|
6115
|
+
* reduction_factor = BASIS_POINT_MAX * (1 - (fee_numerator/cliff_fee_numerator)^(1/totalPeriods))
|
|
6116
|
+
* @param cliffFeeBps - The initial fee value at the cliff in basis points
|
|
6117
|
+
* @param targetFeeBps - The desired final fee value after all periods in basis points
|
|
6118
|
+
* @param totalPeriods - The total number of periods over which the reduction occurs
|
|
6119
|
+
* @returns The estimate of reduction factor
|
|
6120
|
+
*/
|
|
6121
|
+
declare function estimateExponentialReductionFactor(cliffFeeBps: number, targetFeeBps: number, totalPeriods: number): number;
|
|
6092
6122
|
|
|
6093
6123
|
declare function getNextSqrtPrice(amount: BN, sqrtPrice: BN, liquidity: BN, aToB: boolean): BN;
|
|
6094
6124
|
declare function getLiquidityDeltaFromAmountA(amountA: BN, lowerSqrtPrice: BN, // current sqrt price
|
|
@@ -12537,4 +12567,4 @@ var CpAmmIDL = {
|
|
|
12537
12567
|
types: types
|
|
12538
12568
|
};
|
|
12539
12569
|
|
|
12540
|
-
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 CreatePositionAndAddLiquidity, type CreatePositionParams, type DepositQuote, type DynamicFee, type DynamicFeeParams, 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, 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, deriveTokenBadgeAddress, deriveTokenVaultAddress, getAllPositionNftAccountByOwner, getAllUserPositionNftAccount, getAmountAFromLiquidityDelta, getAmountBFromLiquidityDelta, getAvailableVestingLiquidity, getBaseFeeNumerator, getDynamicFeeNumerator, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getFeeNumerator, getFirstKey, getLiquidityDeltaFromAmountA, getLiquidityDeltaFromAmountB, getMaxAmountWithSlippage, getMinAmountWithSlippage, getNextSqrtPrice, getOrCreateATAInstruction, getPriceFromSqrtPrice, getPriceImpact, getSecondKey, getSimulationComputeUnits, getSqrtPriceFromPrice, getSwapAmount, getTokenDecimals, getTokenProgram, getTotalLockedLiquidity, getUnClaimReward, isVestingComplete, mulDiv, positionByPoolFilter, pow, q64ToDecimal, unwrapSOLInstruction, vestingByPositionFilter, wrapSOLInstruction };
|
|
12570
|
+
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 CreatePositionAndAddLiquidity, type CreatePositionParams, type DepositQuote, type DynamicFee, type DynamicFeeParams, 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, 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, bpsToFeeNumerator, calculateInitSqrtPrice, calculateTransferFeeExcludedAmount, calculateTransferFeeIncludedAmount, decimalToQ64, CpAmmIDL as default, deriveClaimFeeOperatorAddress, deriveConfigAddress, deriveCustomizablePoolAddress, derivePoolAddress, derivePoolAuthority, derivePositionAddress, derivePositionNftAccount, deriveRewardVaultAddress, deriveTokenBadgeAddress, deriveTokenVaultAddress, estimateExponentialReductionFactor, estimateLinearReductionFactor, feeNumeratorToBps, getAllPositionNftAccountByOwner, getAllUserPositionNftAccount, getAmountAFromLiquidityDelta, getAmountBFromLiquidityDelta, getAvailableVestingLiquidity, getBaseFeeNumerator, getDynamicFeeNumerator, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getFeeNumerator, getFirstKey, getLiquidityDeltaFromAmountA, getLiquidityDeltaFromAmountB, getMaxAmountWithSlippage, getMinAmountWithSlippage, getNextSqrtPrice, 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
|
@@ -5625,11 +5625,6 @@ declare class CpAmm {
|
|
|
5625
5625
|
_program: AmmProgram;
|
|
5626
5626
|
private poolAuthority;
|
|
5627
5627
|
constructor(connection: Connection);
|
|
5628
|
-
/**
|
|
5629
|
-
* Returns the Anchor program instance.
|
|
5630
|
-
* @returns The AmmProgram instance.
|
|
5631
|
-
*/
|
|
5632
|
-
getProgram(): AmmProgram;
|
|
5633
5628
|
/**
|
|
5634
5629
|
* Prepares token accounts for a transaction by retrieving or creating associated token accounts.
|
|
5635
5630
|
* @private
|
|
@@ -6089,6 +6084,41 @@ declare function getSwapAmount(inAmount: BN, sqrtPrice: BN, liquidity: BN, trade
|
|
|
6089
6084
|
amountOut: BN;
|
|
6090
6085
|
totalFee: BN;
|
|
6091
6086
|
};
|
|
6087
|
+
/**
|
|
6088
|
+
* Converts basis points (bps) to a fee numerator
|
|
6089
|
+
* 1 bps = 0.01% = 0.0001 in decimal
|
|
6090
|
+
*
|
|
6091
|
+
* @param bps - The value in basis points [1-10_000]
|
|
6092
|
+
* @returns The equivalent fee numerator
|
|
6093
|
+
*/
|
|
6094
|
+
declare function bpsToFeeNumerator(bps: number): number;
|
|
6095
|
+
/**
|
|
6096
|
+
* Converts a fee numerator back to basis points (bps)
|
|
6097
|
+
*
|
|
6098
|
+
* @param feeNumerator - The fee numerator to convert
|
|
6099
|
+
* @returns The equivalent value in basis points [1-10_000]
|
|
6100
|
+
*/
|
|
6101
|
+
declare function feeNumeratorToBps(feeNumerator: number): number;
|
|
6102
|
+
/**
|
|
6103
|
+
* Calculates the reduction factor for a Linear fee schedule
|
|
6104
|
+
* Formula: fee = cliff_fee_numerator - passed_period * reduction_factor
|
|
6105
|
+
*
|
|
6106
|
+
* @param cliffFeeBps - The initial fee value at the cliff in basis points
|
|
6107
|
+
* @param targetFeeBps - The desired final fee value after all periods in basis points
|
|
6108
|
+
* @param totalPeriods - The total number of periods over which the reduction occurs
|
|
6109
|
+
* @returns The estimate of reduction factor
|
|
6110
|
+
*/
|
|
6111
|
+
declare function estimateLinearReductionFactor(cliffFeeBps: number, targetFeeBps: number, totalPeriods: number): number;
|
|
6112
|
+
/**
|
|
6113
|
+
* Calculates the reduction factor for an Exponential fee schedule
|
|
6114
|
+
* Formula: fee_numerator = cliff_fee_numerator * (1 - reduction_factor/BASIS_POINT_MAX)^passed_period
|
|
6115
|
+
* reduction_factor = BASIS_POINT_MAX * (1 - (fee_numerator/cliff_fee_numerator)^(1/totalPeriods))
|
|
6116
|
+
* @param cliffFeeBps - The initial fee value at the cliff in basis points
|
|
6117
|
+
* @param targetFeeBps - The desired final fee value after all periods in basis points
|
|
6118
|
+
* @param totalPeriods - The total number of periods over which the reduction occurs
|
|
6119
|
+
* @returns The estimate of reduction factor
|
|
6120
|
+
*/
|
|
6121
|
+
declare function estimateExponentialReductionFactor(cliffFeeBps: number, targetFeeBps: number, totalPeriods: number): number;
|
|
6092
6122
|
|
|
6093
6123
|
declare function getNextSqrtPrice(amount: BN, sqrtPrice: BN, liquidity: BN, aToB: boolean): BN;
|
|
6094
6124
|
declare function getLiquidityDeltaFromAmountA(amountA: BN, lowerSqrtPrice: BN, // current sqrt price
|
|
@@ -12537,4 +12567,4 @@ var CpAmmIDL = {
|
|
|
12537
12567
|
types: types
|
|
12538
12568
|
};
|
|
12539
12569
|
|
|
12540
|
-
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 CreatePositionAndAddLiquidity, type CreatePositionParams, type DepositQuote, type DynamicFee, type DynamicFeeParams, 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, 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, deriveTokenBadgeAddress, deriveTokenVaultAddress, getAllPositionNftAccountByOwner, getAllUserPositionNftAccount, getAmountAFromLiquidityDelta, getAmountBFromLiquidityDelta, getAvailableVestingLiquidity, getBaseFeeNumerator, getDynamicFeeNumerator, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getFeeNumerator, getFirstKey, getLiquidityDeltaFromAmountA, getLiquidityDeltaFromAmountB, getMaxAmountWithSlippage, getMinAmountWithSlippage, getNextSqrtPrice, getOrCreateATAInstruction, getPriceFromSqrtPrice, getPriceImpact, getSecondKey, getSimulationComputeUnits, getSqrtPriceFromPrice, getSwapAmount, getTokenDecimals, getTokenProgram, getTotalLockedLiquidity, getUnClaimReward, isVestingComplete, mulDiv, positionByPoolFilter, pow, q64ToDecimal, unwrapSOLInstruction, vestingByPositionFilter, wrapSOLInstruction };
|
|
12570
|
+
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 CreatePositionAndAddLiquidity, type CreatePositionParams, type DepositQuote, type DynamicFee, type DynamicFeeParams, 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, 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, bpsToFeeNumerator, calculateInitSqrtPrice, calculateTransferFeeExcludedAmount, calculateTransferFeeIncludedAmount, decimalToQ64, CpAmmIDL as default, deriveClaimFeeOperatorAddress, deriveConfigAddress, deriveCustomizablePoolAddress, derivePoolAddress, derivePoolAuthority, derivePositionAddress, derivePositionNftAccount, deriveRewardVaultAddress, deriveTokenBadgeAddress, deriveTokenVaultAddress, estimateExponentialReductionFactor, estimateLinearReductionFactor, feeNumeratorToBps, getAllPositionNftAccountByOwner, getAllUserPositionNftAccount, getAmountAFromLiquidityDelta, getAmountBFromLiquidityDelta, getAvailableVestingLiquidity, getBaseFeeNumerator, getDynamicFeeNumerator, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getFeeNumerator, getFirstKey, getLiquidityDeltaFromAmountA, getLiquidityDeltaFromAmountB, getMaxAmountWithSlippage, getMinAmountWithSlippage, getNextSqrtPrice, getOrCreateATAInstruction, getPriceFromSqrtPrice, getPriceImpact, getSecondKey, getSimulationComputeUnits, getSqrtPriceFromPrice, getSwapAmount, getTokenDecimals, getTokenProgram, getTotalLockedLiquidity, getUnClaimReward, isVestingComplete, mulDiv, positionByPoolFilter, pow, q64ToDecimal, unwrapSOLInstruction, vestingByPositionFilter, wrapSOLInstruction };
|
package/dist/index.js
CHANGED
|
@@ -6886,6 +6886,57 @@ function getSwapAmount(inAmount, sqrtPrice, liquidity, tradeFeeNumerator, aToB,
|
|
|
6886
6886
|
const amountOut = feeMode.feeOnInput ? outAmount : (totalFee = getTotalFeeOnAmount(outAmount, tradeFeeNumerator), outAmount.sub(totalFee));
|
|
6887
6887
|
return { amountOut, totalFee };
|
|
6888
6888
|
}
|
|
6889
|
+
function bpsToFeeNumerator(bps) {
|
|
6890
|
+
return bps * FEE_DENOMINATOR / BASIS_POINT_MAX;
|
|
6891
|
+
}
|
|
6892
|
+
function feeNumeratorToBps(feeNumerator) {
|
|
6893
|
+
return feeNumerator * BASIS_POINT_MAX / FEE_DENOMINATOR;
|
|
6894
|
+
}
|
|
6895
|
+
function estimateLinearReductionFactor(cliffFeeBps, targetFeeBps, totalPeriods) {
|
|
6896
|
+
if (totalPeriods <= 0) {
|
|
6897
|
+
throw new Error("Total periods must be greater than zero");
|
|
6898
|
+
}
|
|
6899
|
+
if (cliffFeeBps > feeNumeratorToBps(MAX_FEE_NUMERATOR)) {
|
|
6900
|
+
throw new Error(
|
|
6901
|
+
`Cliff fee (${cliffFeeBps} bps) exceeds maximum allowed value of ${feeNumeratorToBps(
|
|
6902
|
+
MAX_FEE_NUMERATOR
|
|
6903
|
+
)} bps`
|
|
6904
|
+
);
|
|
6905
|
+
}
|
|
6906
|
+
if (targetFeeBps > cliffFeeBps) {
|
|
6907
|
+
throw new Error(
|
|
6908
|
+
"Target fee must be less than or equal to cliff fee for reduction"
|
|
6909
|
+
);
|
|
6910
|
+
}
|
|
6911
|
+
const cliffFeeNumerator = bpsToFeeNumerator(cliffFeeBps);
|
|
6912
|
+
const targetFeeNumerator = bpsToFeeNumerator(targetFeeBps);
|
|
6913
|
+
const totalReduction = cliffFeeNumerator - targetFeeNumerator;
|
|
6914
|
+
const reductionFactor = totalReduction / totalPeriods;
|
|
6915
|
+
return Math.floor(reductionFactor);
|
|
6916
|
+
}
|
|
6917
|
+
function estimateExponentialReductionFactor(cliffFeeBps, targetFeeBps, totalPeriods) {
|
|
6918
|
+
if (totalPeriods <= 0) {
|
|
6919
|
+
throw new Error("Total periods must be greater than zero");
|
|
6920
|
+
}
|
|
6921
|
+
if (cliffFeeBps > feeNumeratorToBps(MAX_FEE_NUMERATOR)) {
|
|
6922
|
+
throw new Error(
|
|
6923
|
+
`Cliff fee (${cliffFeeBps} bps) exceeds maximum allowed value of ${feeNumeratorToBps(
|
|
6924
|
+
MAX_FEE_NUMERATOR
|
|
6925
|
+
)} bps`
|
|
6926
|
+
);
|
|
6927
|
+
}
|
|
6928
|
+
if (targetFeeBps > cliffFeeBps) {
|
|
6929
|
+
throw new Error(
|
|
6930
|
+
"Target fee bps must be less than or equal to cliff fee bps for reduction"
|
|
6931
|
+
);
|
|
6932
|
+
}
|
|
6933
|
+
const cliffFeeNumerator = bpsToFeeNumerator(cliffFeeBps);
|
|
6934
|
+
const targetFeeNumerator = bpsToFeeNumerator(targetFeeBps);
|
|
6935
|
+
const ratio = targetFeeNumerator / cliffFeeNumerator;
|
|
6936
|
+
const decayBase = Math.pow(ratio, 1 / totalPeriods);
|
|
6937
|
+
const reductionFactor = BASIS_POINT_MAX * (1 - decayBase);
|
|
6938
|
+
return Math.floor(reductionFactor);
|
|
6939
|
+
}
|
|
6889
6940
|
|
|
6890
6941
|
// src/helpers/computeUnits.ts
|
|
6891
6942
|
|
|
@@ -7185,13 +7236,6 @@ var CpAmm = class {
|
|
|
7185
7236
|
});
|
|
7186
7237
|
this.poolAuthority = derivePoolAuthority();
|
|
7187
7238
|
}
|
|
7188
|
-
/**
|
|
7189
|
-
* Returns the Anchor program instance.
|
|
7190
|
-
* @returns The AmmProgram instance.
|
|
7191
|
-
*/
|
|
7192
|
-
getProgram() {
|
|
7193
|
-
return this._program;
|
|
7194
|
-
}
|
|
7195
7239
|
/**
|
|
7196
7240
|
* Prepares token accounts for a transaction by retrieving or creating associated token accounts.
|
|
7197
7241
|
* @private
|
|
@@ -9254,5 +9298,9 @@ var index_default = cp_amm_default;
|
|
|
9254
9298
|
|
|
9255
9299
|
|
|
9256
9300
|
|
|
9257
|
-
|
|
9301
|
+
|
|
9302
|
+
|
|
9303
|
+
|
|
9304
|
+
|
|
9305
|
+
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.LIQUIDITY_SCALE = LIQUIDITY_SCALE; 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.ONE = ONE; exports.Rounding = Rounding; exports.SCALE_OFFSET = SCALE_OFFSET; exports.TradeDirection = TradeDirection; exports.bpsToFeeNumerator = bpsToFeeNumerator; exports.calculateInitSqrtPrice = calculateInitSqrtPrice; exports.calculateTransferFeeExcludedAmount = calculateTransferFeeExcludedAmount; exports.calculateTransferFeeIncludedAmount = calculateTransferFeeIncludedAmount; exports.decimalToQ64 = decimalToQ64; exports.default = index_default; exports.deriveClaimFeeOperatorAddress = deriveClaimFeeOperatorAddress; exports.deriveConfigAddress = deriveConfigAddress; exports.deriveCustomizablePoolAddress = deriveCustomizablePoolAddress; exports.derivePoolAddress = derivePoolAddress; exports.derivePoolAuthority = derivePoolAuthority; exports.derivePositionAddress = derivePositionAddress; exports.derivePositionNftAccount = derivePositionNftAccount; exports.deriveRewardVaultAddress = deriveRewardVaultAddress; exports.deriveTokenBadgeAddress = deriveTokenBadgeAddress; exports.deriveTokenVaultAddress = deriveTokenVaultAddress; exports.estimateExponentialReductionFactor = estimateExponentialReductionFactor; exports.estimateLinearReductionFactor = estimateLinearReductionFactor; exports.feeNumeratorToBps = feeNumeratorToBps; exports.getAllPositionNftAccountByOwner = getAllPositionNftAccountByOwner; exports.getAllUserPositionNftAccount = getAllUserPositionNftAccount; exports.getAmountAFromLiquidityDelta = getAmountAFromLiquidityDelta; exports.getAmountBFromLiquidityDelta = getAmountBFromLiquidityDelta; exports.getAvailableVestingLiquidity = getAvailableVestingLiquidity; exports.getBaseFeeNumerator = getBaseFeeNumerator; exports.getDynamicFeeNumerator = getDynamicFeeNumerator; exports.getEstimatedComputeUnitIxWithBuffer = getEstimatedComputeUnitIxWithBuffer; exports.getEstimatedComputeUnitUsageWithBuffer = getEstimatedComputeUnitUsageWithBuffer; exports.getFeeNumerator = getFeeNumerator; exports.getFirstKey = getFirstKey; exports.getLiquidityDeltaFromAmountA = getLiquidityDeltaFromAmountA; exports.getLiquidityDeltaFromAmountB = getLiquidityDeltaFromAmountB; exports.getMaxAmountWithSlippage = getMaxAmountWithSlippage; exports.getMinAmountWithSlippage = getMinAmountWithSlippage; exports.getNextSqrtPrice = getNextSqrtPrice; exports.getOrCreateATAInstruction = getOrCreateATAInstruction; exports.getPriceFromSqrtPrice = getPriceFromSqrtPrice; exports.getPriceImpact = getPriceImpact; exports.getSecondKey = getSecondKey; exports.getSimulationComputeUnits = getSimulationComputeUnits; exports.getSqrtPriceFromPrice = getSqrtPriceFromPrice; exports.getSwapAmount = getSwapAmount; exports.getTokenDecimals = getTokenDecimals; exports.getTokenProgram = getTokenProgram; exports.getTotalLockedLiquidity = getTotalLockedLiquidity; exports.getUnClaimReward = getUnClaimReward; exports.isVestingComplete = isVestingComplete; exports.mulDiv = mulDiv; exports.positionByPoolFilter = positionByPoolFilter; exports.pow = pow; exports.q64ToDecimal = q64ToDecimal; exports.unwrapSOLInstruction = unwrapSOLInstruction; exports.vestingByPositionFilter = vestingByPositionFilter; exports.wrapSOLInstruction = wrapSOLInstruction;
|
|
9258
9306
|
//# sourceMappingURL=index.js.map
|