@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 +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +8 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
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
|
|
6379
|
-
|
|
6380
|
-
);
|
|
6378
|
+
const lastTimeRewardApplicable = BN6.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 BN6(
|
|
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
|
}
|