@meteora-ag/cp-amm-sdk 1.0.11-rc.5 → 1.0.11-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 +7 -5
- package/dist/index.d.ts +7 -5
- package/dist/index.js +56 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -6739,12 +6739,14 @@ declare const getUnClaimReward: (poolState: PoolState, positionState: PositionSt
|
|
|
6739
6739
|
feeTokenB: BN;
|
|
6740
6740
|
rewards: BN[];
|
|
6741
6741
|
};
|
|
6742
|
-
declare function getRewardInfo(poolState: PoolState,
|
|
6743
|
-
|
|
6744
|
-
totalUserRewardPerPeriod: BN;
|
|
6745
|
-
totalPoolRewardPerPeriod: BN;
|
|
6742
|
+
declare function getRewardInfo(poolState: PoolState, rewardIndex: number, periodTime: BN, currentTime: BN): {
|
|
6743
|
+
rewardPerPeriod: BN;
|
|
6746
6744
|
rewardBalance: BN;
|
|
6747
6745
|
};
|
|
6746
|
+
declare function getUserRewardPending(poolState: PoolState, positionState: PositionState, rewardIndex: number, currentTime: BN, periodTime: BN): {
|
|
6747
|
+
userRewardPerPeriod: BN;
|
|
6748
|
+
userPendingReward: BN;
|
|
6749
|
+
};
|
|
6748
6750
|
|
|
6749
6751
|
declare const positionByPoolFilter: (pool: PublicKey) => GetProgramAccountsFilter;
|
|
6750
6752
|
declare const vestingByPositionFilter: (position: PublicKey) => GetProgramAccountsFilter;
|
|
@@ -13682,4 +13684,4 @@ var CpAmmIDL = {
|
|
|
13682
13684
|
types: types
|
|
13683
13685
|
};
|
|
13684
13686
|
|
|
13685
|
-
export { ActivationPoint, ActivationType, type AddLiquidityParams, type AmmProgram, BASIS_POINT_MAX, BIN_STEP_BPS_DEFAULT, BIN_STEP_BPS_U128_DEFAULT, type BaseFee, type BuildAddLiquidityParams, type BuildLiquidatePositionInstructionParams, type BuildRemoveAllLiquidityInstructionParams, CP_AMM_PROGRAM_ID, type ClaimPartnerFeeParams, type ClaimPositionFeeInstructionParams, type ClaimPositionFeeParams, type ClaimPositionFeeParams2, type ClaimRewardParams, type ClosePositionInstructionParams, type ClosePositionParams, CollectFeeMode, type ConfigState, CpAmm, type CpAmm$1 as CpAmmTypes, type CreatePoolParams, type CreatePositionAndAddLiquidity, type CreatePositionParams, DYNAMIC_FEE_DECAY_PERIOD_DEFAULT, DYNAMIC_FEE_FILTER_PERIOD_DEFAULT, DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT, type DepositQuote, type DynamicFee, type DynamicFeeParams, FEE_DENOMINATOR, type FeeMode, FeeSchedulerMode, type FundRewardParams, type GetDepositQuoteParams, type GetQuoteParams, type GetWithdrawQuoteParams, type InitializeAndFundReward, type InitializeCustomizeablePoolParams, type InitializeCustomizeablePoolWithDynamicConfigParams, type InitializeRewardParams, LIQUIDITY_SCALE, type LiquidityDeltaParams, type LockPositionParams, MAX_CU_BUFFER, MAX_FEE_NUMERATOR, MAX_PRICE_CHANGE_BPS_DEFAULT, MAX_SQRT_PRICE, MIN_CU_BUFFER, MIN_SQRT_PRICE, type MergePositionParams, ONE, type PermanentLockParams, type PoolFeesParams, type PoolState, type PositionState, type PrepareCustomizablePoolParams, type PreparePoolCreationParams, type PreparePoolCreationSingleSide, type PrepareTokenAccountParams, type PreparedPoolCreation, type RefreshVestingParams, type RemoveAllLiquidityAndClosePositionParams, type RemoveAllLiquidityParams, type RemoveLiquidityParams, type RewardInfo, Rounding, SCALE_OFFSET, type SetupFeeClaimAccountsParams, type SwapParams, type SwapQuotes, type TokenBadgeState, TradeDirection, type TxBuilder, type UpdateRewardDurationParams, type UpdateRewardFunderParams, type UserRewardInfo, type VestingState, type WithdrawIneligibleRewardParams, type WithdrawQuote, bpsToFeeNumerator, calculateInitSqrtPrice, calculateTransferFeeExcludedAmount, calculateTransferFeeIncludedAmount, decimalToQ64, CpAmmIDL as default, deriveClaimFeeOperatorAddress, deriveConfigAddress, deriveCustomizablePoolAddress, derivePoolAddress, derivePoolAuthority, derivePositionAddress, derivePositionNftAccount, deriveRewardVaultAddress, deriveTokenBadgeAddress, deriveTokenVaultAddress, feeNumeratorToBps, getAllPositionNftAccountByOwner, getAllUserPositionNftAccount, getAmountAFromLiquidityDelta, getAmountBFromLiquidityDelta, getAvailableVestingLiquidity, getBaseFeeNumerator, getBaseFeeParams, getDynamicFeeNumerator, getDynamicFeeParams, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getFeeNumerator, getFirstKey, getLiquidityDeltaFromAmountA, getLiquidityDeltaFromAmountB, getMaxAmountWithSlippage, getMinAmountWithSlippage, getNextSqrtPrice, getOrCreateATAInstruction, getPriceFromSqrtPrice, getPriceImpact, getRewardInfo, getSecondKey, getSimulationComputeUnits, getSqrtPriceFromPrice, getSwapAmount, getTokenDecimals, getTokenProgram, getTotalLockedLiquidity, getUnClaimReward, isVestingComplete, mulDiv, positionByPoolFilter, pow, q64ToDecimal, unwrapSOLInstruction, vestingByPositionFilter, wrapSOLInstruction };
|
|
13687
|
+
export { ActivationPoint, ActivationType, type AddLiquidityParams, type AmmProgram, BASIS_POINT_MAX, BIN_STEP_BPS_DEFAULT, BIN_STEP_BPS_U128_DEFAULT, type BaseFee, type BuildAddLiquidityParams, type BuildLiquidatePositionInstructionParams, type BuildRemoveAllLiquidityInstructionParams, CP_AMM_PROGRAM_ID, type ClaimPartnerFeeParams, type ClaimPositionFeeInstructionParams, type ClaimPositionFeeParams, type ClaimPositionFeeParams2, type ClaimRewardParams, type ClosePositionInstructionParams, type ClosePositionParams, CollectFeeMode, type ConfigState, CpAmm, type CpAmm$1 as CpAmmTypes, type CreatePoolParams, type CreatePositionAndAddLiquidity, type CreatePositionParams, DYNAMIC_FEE_DECAY_PERIOD_DEFAULT, DYNAMIC_FEE_FILTER_PERIOD_DEFAULT, DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT, type DepositQuote, type DynamicFee, type DynamicFeeParams, FEE_DENOMINATOR, type FeeMode, FeeSchedulerMode, type FundRewardParams, type GetDepositQuoteParams, type GetQuoteParams, type GetWithdrawQuoteParams, type InitializeAndFundReward, type InitializeCustomizeablePoolParams, type InitializeCustomizeablePoolWithDynamicConfigParams, type InitializeRewardParams, LIQUIDITY_SCALE, type LiquidityDeltaParams, type LockPositionParams, MAX_CU_BUFFER, MAX_FEE_NUMERATOR, MAX_PRICE_CHANGE_BPS_DEFAULT, MAX_SQRT_PRICE, MIN_CU_BUFFER, MIN_SQRT_PRICE, type MergePositionParams, ONE, type PermanentLockParams, type PoolFeesParams, type PoolState, type PositionState, type PrepareCustomizablePoolParams, type PreparePoolCreationParams, type PreparePoolCreationSingleSide, type PrepareTokenAccountParams, type PreparedPoolCreation, type RefreshVestingParams, type RemoveAllLiquidityAndClosePositionParams, type RemoveAllLiquidityParams, type RemoveLiquidityParams, type RewardInfo, Rounding, SCALE_OFFSET, type SetupFeeClaimAccountsParams, type SwapParams, type SwapQuotes, type TokenBadgeState, TradeDirection, type TxBuilder, type UpdateRewardDurationParams, type UpdateRewardFunderParams, type UserRewardInfo, type VestingState, type WithdrawIneligibleRewardParams, type WithdrawQuote, bpsToFeeNumerator, calculateInitSqrtPrice, calculateTransferFeeExcludedAmount, calculateTransferFeeIncludedAmount, decimalToQ64, CpAmmIDL as default, deriveClaimFeeOperatorAddress, deriveConfigAddress, deriveCustomizablePoolAddress, derivePoolAddress, derivePoolAuthority, derivePositionAddress, derivePositionNftAccount, deriveRewardVaultAddress, deriveTokenBadgeAddress, deriveTokenVaultAddress, feeNumeratorToBps, getAllPositionNftAccountByOwner, getAllUserPositionNftAccount, getAmountAFromLiquidityDelta, getAmountBFromLiquidityDelta, getAvailableVestingLiquidity, getBaseFeeNumerator, getBaseFeeParams, getDynamicFeeNumerator, getDynamicFeeParams, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getFeeNumerator, getFirstKey, getLiquidityDeltaFromAmountA, getLiquidityDeltaFromAmountB, getMaxAmountWithSlippage, getMinAmountWithSlippage, getNextSqrtPrice, getOrCreateATAInstruction, getPriceFromSqrtPrice, getPriceImpact, getRewardInfo, getSecondKey, getSimulationComputeUnits, getSqrtPriceFromPrice, getSwapAmount, getTokenDecimals, getTokenProgram, getTotalLockedLiquidity, getUnClaimReward, getUserRewardPending, isVestingComplete, mulDiv, positionByPoolFilter, pow, q64ToDecimal, unwrapSOLInstruction, vestingByPositionFilter, wrapSOLInstruction };
|
package/dist/index.d.ts
CHANGED
|
@@ -6739,12 +6739,14 @@ declare const getUnClaimReward: (poolState: PoolState, positionState: PositionSt
|
|
|
6739
6739
|
feeTokenB: BN;
|
|
6740
6740
|
rewards: BN[];
|
|
6741
6741
|
};
|
|
6742
|
-
declare function getRewardInfo(poolState: PoolState,
|
|
6743
|
-
|
|
6744
|
-
totalUserRewardPerPeriod: BN;
|
|
6745
|
-
totalPoolRewardPerPeriod: BN;
|
|
6742
|
+
declare function getRewardInfo(poolState: PoolState, rewardIndex: number, periodTime: BN, currentTime: BN): {
|
|
6743
|
+
rewardPerPeriod: BN;
|
|
6746
6744
|
rewardBalance: BN;
|
|
6747
6745
|
};
|
|
6746
|
+
declare function getUserRewardPending(poolState: PoolState, positionState: PositionState, rewardIndex: number, currentTime: BN, periodTime: BN): {
|
|
6747
|
+
userRewardPerPeriod: BN;
|
|
6748
|
+
userPendingReward: BN;
|
|
6749
|
+
};
|
|
6748
6750
|
|
|
6749
6751
|
declare const positionByPoolFilter: (pool: PublicKey) => GetProgramAccountsFilter;
|
|
6750
6752
|
declare const vestingByPositionFilter: (position: PublicKey) => GetProgramAccountsFilter;
|
|
@@ -13682,4 +13684,4 @@ var CpAmmIDL = {
|
|
|
13682
13684
|
types: types
|
|
13683
13685
|
};
|
|
13684
13686
|
|
|
13685
|
-
export { ActivationPoint, ActivationType, type AddLiquidityParams, type AmmProgram, BASIS_POINT_MAX, BIN_STEP_BPS_DEFAULT, BIN_STEP_BPS_U128_DEFAULT, type BaseFee, type BuildAddLiquidityParams, type BuildLiquidatePositionInstructionParams, type BuildRemoveAllLiquidityInstructionParams, CP_AMM_PROGRAM_ID, type ClaimPartnerFeeParams, type ClaimPositionFeeInstructionParams, type ClaimPositionFeeParams, type ClaimPositionFeeParams2, type ClaimRewardParams, type ClosePositionInstructionParams, type ClosePositionParams, CollectFeeMode, type ConfigState, CpAmm, type CpAmm$1 as CpAmmTypes, type CreatePoolParams, type CreatePositionAndAddLiquidity, type CreatePositionParams, DYNAMIC_FEE_DECAY_PERIOD_DEFAULT, DYNAMIC_FEE_FILTER_PERIOD_DEFAULT, DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT, type DepositQuote, type DynamicFee, type DynamicFeeParams, FEE_DENOMINATOR, type FeeMode, FeeSchedulerMode, type FundRewardParams, type GetDepositQuoteParams, type GetQuoteParams, type GetWithdrawQuoteParams, type InitializeAndFundReward, type InitializeCustomizeablePoolParams, type InitializeCustomizeablePoolWithDynamicConfigParams, type InitializeRewardParams, LIQUIDITY_SCALE, type LiquidityDeltaParams, type LockPositionParams, MAX_CU_BUFFER, MAX_FEE_NUMERATOR, MAX_PRICE_CHANGE_BPS_DEFAULT, MAX_SQRT_PRICE, MIN_CU_BUFFER, MIN_SQRT_PRICE, type MergePositionParams, ONE, type PermanentLockParams, type PoolFeesParams, type PoolState, type PositionState, type PrepareCustomizablePoolParams, type PreparePoolCreationParams, type PreparePoolCreationSingleSide, type PrepareTokenAccountParams, type PreparedPoolCreation, type RefreshVestingParams, type RemoveAllLiquidityAndClosePositionParams, type RemoveAllLiquidityParams, type RemoveLiquidityParams, type RewardInfo, Rounding, SCALE_OFFSET, type SetupFeeClaimAccountsParams, type SwapParams, type SwapQuotes, type TokenBadgeState, TradeDirection, type TxBuilder, type UpdateRewardDurationParams, type UpdateRewardFunderParams, type UserRewardInfo, type VestingState, type WithdrawIneligibleRewardParams, type WithdrawQuote, bpsToFeeNumerator, calculateInitSqrtPrice, calculateTransferFeeExcludedAmount, calculateTransferFeeIncludedAmount, decimalToQ64, CpAmmIDL as default, deriveClaimFeeOperatorAddress, deriveConfigAddress, deriveCustomizablePoolAddress, derivePoolAddress, derivePoolAuthority, derivePositionAddress, derivePositionNftAccount, deriveRewardVaultAddress, deriveTokenBadgeAddress, deriveTokenVaultAddress, feeNumeratorToBps, getAllPositionNftAccountByOwner, getAllUserPositionNftAccount, getAmountAFromLiquidityDelta, getAmountBFromLiquidityDelta, getAvailableVestingLiquidity, getBaseFeeNumerator, getBaseFeeParams, getDynamicFeeNumerator, getDynamicFeeParams, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getFeeNumerator, getFirstKey, getLiquidityDeltaFromAmountA, getLiquidityDeltaFromAmountB, getMaxAmountWithSlippage, getMinAmountWithSlippage, getNextSqrtPrice, getOrCreateATAInstruction, getPriceFromSqrtPrice, getPriceImpact, getRewardInfo, getSecondKey, getSimulationComputeUnits, getSqrtPriceFromPrice, getSwapAmount, getTokenDecimals, getTokenProgram, getTotalLockedLiquidity, getUnClaimReward, isVestingComplete, mulDiv, positionByPoolFilter, pow, q64ToDecimal, unwrapSOLInstruction, vestingByPositionFilter, wrapSOLInstruction };
|
|
13687
|
+
export { ActivationPoint, ActivationType, type AddLiquidityParams, type AmmProgram, BASIS_POINT_MAX, BIN_STEP_BPS_DEFAULT, BIN_STEP_BPS_U128_DEFAULT, type BaseFee, type BuildAddLiquidityParams, type BuildLiquidatePositionInstructionParams, type BuildRemoveAllLiquidityInstructionParams, CP_AMM_PROGRAM_ID, type ClaimPartnerFeeParams, type ClaimPositionFeeInstructionParams, type ClaimPositionFeeParams, type ClaimPositionFeeParams2, type ClaimRewardParams, type ClosePositionInstructionParams, type ClosePositionParams, CollectFeeMode, type ConfigState, CpAmm, type CpAmm$1 as CpAmmTypes, type CreatePoolParams, type CreatePositionAndAddLiquidity, type CreatePositionParams, DYNAMIC_FEE_DECAY_PERIOD_DEFAULT, DYNAMIC_FEE_FILTER_PERIOD_DEFAULT, DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT, type DepositQuote, type DynamicFee, type DynamicFeeParams, FEE_DENOMINATOR, type FeeMode, FeeSchedulerMode, type FundRewardParams, type GetDepositQuoteParams, type GetQuoteParams, type GetWithdrawQuoteParams, type InitializeAndFundReward, type InitializeCustomizeablePoolParams, type InitializeCustomizeablePoolWithDynamicConfigParams, type InitializeRewardParams, LIQUIDITY_SCALE, type LiquidityDeltaParams, type LockPositionParams, MAX_CU_BUFFER, MAX_FEE_NUMERATOR, MAX_PRICE_CHANGE_BPS_DEFAULT, MAX_SQRT_PRICE, MIN_CU_BUFFER, MIN_SQRT_PRICE, type MergePositionParams, ONE, type PermanentLockParams, type PoolFeesParams, type PoolState, type PositionState, type PrepareCustomizablePoolParams, type PreparePoolCreationParams, type PreparePoolCreationSingleSide, type PrepareTokenAccountParams, type PreparedPoolCreation, type RefreshVestingParams, type RemoveAllLiquidityAndClosePositionParams, type RemoveAllLiquidityParams, type RemoveLiquidityParams, type RewardInfo, Rounding, SCALE_OFFSET, type SetupFeeClaimAccountsParams, type SwapParams, type SwapQuotes, type TokenBadgeState, TradeDirection, type TxBuilder, type UpdateRewardDurationParams, type UpdateRewardFunderParams, type UserRewardInfo, type VestingState, type WithdrawIneligibleRewardParams, type WithdrawQuote, bpsToFeeNumerator, calculateInitSqrtPrice, calculateTransferFeeExcludedAmount, calculateTransferFeeIncludedAmount, decimalToQ64, CpAmmIDL as default, deriveClaimFeeOperatorAddress, deriveConfigAddress, deriveCustomizablePoolAddress, derivePoolAddress, derivePoolAuthority, derivePositionAddress, derivePositionNftAccount, deriveRewardVaultAddress, deriveTokenBadgeAddress, deriveTokenVaultAddress, feeNumeratorToBps, getAllPositionNftAccountByOwner, getAllUserPositionNftAccount, getAmountAFromLiquidityDelta, getAmountBFromLiquidityDelta, getAvailableVestingLiquidity, getBaseFeeNumerator, getBaseFeeParams, getDynamicFeeNumerator, getDynamicFeeParams, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getFeeNumerator, getFirstKey, getLiquidityDeltaFromAmountA, getLiquidityDeltaFromAmountB, getMaxAmountWithSlippage, getMinAmountWithSlippage, getNextSqrtPrice, getOrCreateATAInstruction, getPriceFromSqrtPrice, getPriceImpact, getRewardInfo, getSecondKey, getSimulationComputeUnits, getSqrtPriceFromPrice, getSwapAmount, getTokenDecimals, getTokenProgram, getTotalLockedLiquidity, getUnClaimReward, getUserRewardPending, isVestingComplete, mulDiv, positionByPoolFilter, pow, q64ToDecimal, unwrapSOLInstruction, vestingByPositionFilter, wrapSOLInstruction };
|
package/dist/index.js
CHANGED
|
@@ -6372,30 +6372,67 @@ var getUnClaimReward = (poolState, positionState) => {
|
|
|
6372
6372
|
rewards: positionState.rewardInfos.length > 0 ? positionState.rewardInfos.map((item) => item.rewardPendings) : []
|
|
6373
6373
|
};
|
|
6374
6374
|
};
|
|
6375
|
-
function
|
|
6376
|
-
const
|
|
6377
|
-
|
|
6378
|
-
|
|
6375
|
+
function getRewardPerTokenStore(poolReward, poolLiquidity, currentTime) {
|
|
6376
|
+
const lastTimeRewardApplicable = _anchor.BN.min(
|
|
6377
|
+
currentTime,
|
|
6378
|
+
poolReward.rewardDurationEnd
|
|
6379
|
+
);
|
|
6379
6380
|
const timePeriod = lastTimeRewardApplicable.sub(poolReward.lastUpdateTime);
|
|
6380
6381
|
const currentTotalReward = timePeriod.mul(poolReward.rewardRate);
|
|
6381
|
-
const rewardPerTokenStore = currentTotalReward.shln(128).div(
|
|
6382
|
+
const rewardPerTokenStore = currentTotalReward.shln(128).div(poolLiquidity);
|
|
6383
|
+
const totalRewardPerTokenStore = new (0, _anchor.BN)(
|
|
6384
|
+
Buffer.from(poolReward.rewardPerTokenStored).reverse()
|
|
6385
|
+
).add(rewardPerTokenStore);
|
|
6386
|
+
return totalRewardPerTokenStore;
|
|
6387
|
+
}
|
|
6388
|
+
function getRewardPerPeriod(poolReward, currentTime, periodTime) {
|
|
6389
|
+
const timeRewardAppicable = currentTime.add(periodTime);
|
|
6390
|
+
const period = timeRewardAppicable <= poolReward.rewardDurationEnd ? periodTime : poolReward.rewardDurationEnd.sub(currentTime);
|
|
6391
|
+
const rewardPerPeriod = poolReward.rewardRate.mul(period);
|
|
6392
|
+
return rewardPerPeriod;
|
|
6393
|
+
}
|
|
6394
|
+
function getRewardInfo(poolState, rewardIndex, periodTime, currentTime) {
|
|
6395
|
+
const poolReward = poolState.rewardInfos[rewardIndex];
|
|
6396
|
+
const totalReward = poolReward.rewardRate.mul(poolReward.rewardDuration).shrn(64);
|
|
6397
|
+
const rewardPerTokenStore = getRewardPerTokenStore(
|
|
6398
|
+
poolReward,
|
|
6399
|
+
poolState.liquidity,
|
|
6400
|
+
currentTime
|
|
6401
|
+
);
|
|
6402
|
+
const totalRewardDistributed = rewardPerTokenStore.mul(poolState.liquidity).shrn(192);
|
|
6403
|
+
const rewardPerPeriod = getRewardPerPeriod(
|
|
6404
|
+
poolReward,
|
|
6405
|
+
currentTime,
|
|
6406
|
+
periodTime
|
|
6407
|
+
);
|
|
6408
|
+
return {
|
|
6409
|
+
rewardPerPeriod: rewardPerPeriod.shrn(64),
|
|
6410
|
+
rewardBalance: totalReward.sub(totalRewardDistributed)
|
|
6411
|
+
};
|
|
6412
|
+
}
|
|
6413
|
+
function getUserRewardPending(poolState, positionState, rewardIndex, currentTime, periodTime) {
|
|
6414
|
+
const poolReward = poolState.rewardInfos[rewardIndex];
|
|
6415
|
+
const userRewardInfo = positionState.rewardInfos[rewardIndex];
|
|
6416
|
+
const rewardPerTokenStore = getRewardPerTokenStore(
|
|
6417
|
+
poolReward,
|
|
6418
|
+
poolState.liquidity,
|
|
6419
|
+
currentTime
|
|
6420
|
+
);
|
|
6421
|
+
const totalPositionLiquidity = positionState.unlockedLiquidity.add(positionState.vestedLiquidity).add(positionState.permanentLockedLiquidity);
|
|
6382
6422
|
const userRewardPerTokenCheckPoint = new (0, _anchor.BN)(
|
|
6383
6423
|
Buffer.from(userRewardInfo.rewardPerTokenCheckpoint).reverse()
|
|
6384
6424
|
);
|
|
6385
|
-
const totalPositionLiquidity = positionState.unlockedLiquidity.add(positionState.vestedLiquidity).add(positionState.permanentLockedLiquidity);
|
|
6386
6425
|
const newReward = totalPositionLiquidity.mul(rewardPerTokenStore.sub(userRewardPerTokenCheckPoint)).shrn(192);
|
|
6387
|
-
const
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
|
|
6426
|
+
const rewardPerPeriod = getRewardPerPeriod(
|
|
6427
|
+
poolReward,
|
|
6428
|
+
currentTime,
|
|
6429
|
+
periodTime
|
|
6430
|
+
);
|
|
6431
|
+
const rewardPerTokenStorePerPeriod = rewardPerPeriod.shln(128).div(poolState.liquidity);
|
|
6432
|
+
const userRewardPerPeriod = totalPositionLiquidity.mul(rewardPerTokenStorePerPeriod).shrn(192);
|
|
6394
6433
|
return {
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
totalPoolRewardPerPeriod: totalRewardPerPeriod.shrn(64),
|
|
6398
|
-
rewardBalance: totalReward.sub(totalRewardDistributed)
|
|
6434
|
+
userPendingReward: userRewardInfo.rewardPendings.add(newReward),
|
|
6435
|
+
userRewardPerPeriod
|
|
6399
6436
|
};
|
|
6400
6437
|
}
|
|
6401
6438
|
|
|
@@ -9036,5 +9073,6 @@ var index_default = cp_amm_default;
|
|
|
9036
9073
|
|
|
9037
9074
|
|
|
9038
9075
|
|
|
9039
|
-
|
|
9076
|
+
|
|
9077
|
+
exports.ActivationPoint = ActivationPoint; exports.ActivationType = ActivationType; exports.BASIS_POINT_MAX = BASIS_POINT_MAX; exports.BIN_STEP_BPS_DEFAULT = BIN_STEP_BPS_DEFAULT; exports.BIN_STEP_BPS_U128_DEFAULT = BIN_STEP_BPS_U128_DEFAULT; exports.CP_AMM_PROGRAM_ID = CP_AMM_PROGRAM_ID; exports.CollectFeeMode = CollectFeeMode; exports.CpAmm = CpAmm; exports.DYNAMIC_FEE_DECAY_PERIOD_DEFAULT = DYNAMIC_FEE_DECAY_PERIOD_DEFAULT; exports.DYNAMIC_FEE_FILTER_PERIOD_DEFAULT = DYNAMIC_FEE_FILTER_PERIOD_DEFAULT; exports.DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT = DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT; 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_PRICE_CHANGE_BPS_DEFAULT = MAX_PRICE_CHANGE_BPS_DEFAULT; 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.feeNumeratorToBps = feeNumeratorToBps; exports.getAllPositionNftAccountByOwner = getAllPositionNftAccountByOwner; exports.getAllUserPositionNftAccount = getAllUserPositionNftAccount; exports.getAmountAFromLiquidityDelta = getAmountAFromLiquidityDelta; exports.getAmountBFromLiquidityDelta = getAmountBFromLiquidityDelta; exports.getAvailableVestingLiquidity = getAvailableVestingLiquidity; exports.getBaseFeeNumerator = getBaseFeeNumerator; exports.getBaseFeeParams = getBaseFeeParams; exports.getDynamicFeeNumerator = getDynamicFeeNumerator; exports.getDynamicFeeParams = getDynamicFeeParams; 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.getRewardInfo = getRewardInfo; 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.getUserRewardPending = getUserRewardPending; exports.isVestingComplete = isVestingComplete; exports.mulDiv = mulDiv; exports.positionByPoolFilter = positionByPoolFilter; exports.pow = pow; exports.q64ToDecimal = q64ToDecimal; exports.unwrapSOLInstruction = unwrapSOLInstruction; exports.vestingByPositionFilter = vestingByPositionFilter; exports.wrapSOLInstruction = wrapSOLInstruction;
|
|
9040
9078
|
//# sourceMappingURL=index.js.map
|