@meteora-ag/cp-amm-sdk 1.0.11-rc.3 → 1.0.11-rc.4

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
@@ -6739,9 +6739,10 @@ declare const getUnClaimReward: (poolState: PoolState, positionState: PositionSt
6739
6739
  feeTokenB: BN;
6740
6740
  rewards: BN[];
6741
6741
  };
6742
- declare function getRewardInfo(poolState: PoolState, positionState: PositionState, rewardIndex: number, periodTime: BN): {
6742
+ declare function getRewardInfo(poolState: PoolState, positionState: PositionState, rewardIndex: number, currentTime: BN, periodTime: BN): {
6743
6743
  rewardPendings: BN;
6744
6744
  totalUserRewardPerPeriod: BN;
6745
+ totalPoolRewardPerPeriod: BN;
6745
6746
  rewardBalance: BN;
6746
6747
  };
6747
6748
 
package/dist/index.d.ts CHANGED
@@ -6739,9 +6739,10 @@ declare const getUnClaimReward: (poolState: PoolState, positionState: PositionSt
6739
6739
  feeTokenB: BN;
6740
6740
  rewards: BN[];
6741
6741
  };
6742
- declare function getRewardInfo(poolState: PoolState, positionState: PositionState, rewardIndex: number, periodTime: BN): {
6742
+ declare function getRewardInfo(poolState: PoolState, positionState: PositionState, rewardIndex: number, currentTime: BN, periodTime: BN): {
6743
6743
  rewardPendings: BN;
6744
6744
  totalUserRewardPerPeriod: BN;
6745
+ totalPoolRewardPerPeriod: BN;
6745
6746
  rewardBalance: BN;
6746
6747
  };
6747
6748
 
package/dist/index.js CHANGED
@@ -6372,12 +6372,13 @@ var getUnClaimReward = (poolState, positionState) => {
6372
6372
  rewards: positionState.rewardInfos.length > 0 ? positionState.rewardInfos.map((item) => item.rewardPendings) : []
6373
6373
  };
6374
6374
  };
6375
- function getRewardInfo(poolState, positionState, rewardIndex, periodTime) {
6375
+ function getRewardInfo(poolState, positionState, rewardIndex, currentTime, periodTime) {
6376
6376
  const poolReward = poolState.rewardInfos[rewardIndex];
6377
6377
  const userRewardInfo = positionState.rewardInfos[rewardIndex];
6378
- const rewardPerTokenStore = new (0, _anchor.BN)(
6379
- Buffer.from(poolReward.rewardPerTokenStored).reverse()
6380
- );
6378
+ const lastTimeRewardApplicable = _anchor.BN.min(currentTime, poolReward.rewardDurationEnd);
6379
+ const timePeriod = lastTimeRewardApplicable.sub(poolReward.lastUpdateTime);
6380
+ const currentTotalReward = timePeriod.mul(poolReward.rewardRate);
6381
+ const rewardPerTokenStore = currentTotalReward.shln(128).div(poolState.liquidity);
6381
6382
  const userRewardPerTokenCheckPoint = new (0, _anchor.BN)(
6382
6383
  Buffer.from(userRewardInfo.rewardPerTokenCheckpoint).reverse()
6383
6384
  );
@@ -6388,9 +6389,12 @@ function getRewardInfo(poolState, positionState, rewardIndex, periodTime) {
6388
6389
  const totalUserRewardPerPeriod = totalPositionLiquidity.mul(rewardPerTokenStorePerPeriod).shrn(192);
6389
6390
  const totalReward = poolReward.rewardRate.mul(poolReward.rewardDuration).shrn(64);
6390
6391
  const totalRewardDistributed = rewardPerTokenStore.mul(poolState.liquidity).shrn(192);
6392
+ console.log("userRewardInfo.rewardPendings: ", userRewardInfo.rewardPendings.toString());
6393
+ console.log("newReward: ", newReward.toString());
6391
6394
  return {
6392
6395
  rewardPendings: userRewardInfo.rewardPendings.add(newReward),
6393
6396
  totalUserRewardPerPeriod,
6397
+ totalPoolRewardPerPeriod: totalRewardPerPeriod,
6394
6398
  rewardBalance: totalReward.sub(totalRewardDistributed)
6395
6399
  };
6396
6400
  }