@meteora-ag/cp-amm-sdk 1.0.11-rc.2 → 1.0.11-rc.3
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 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +24 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -6372,6 +6372,28 @@ 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) {
|
|
6376
|
+
const poolReward = poolState.rewardInfos[rewardIndex];
|
|
6377
|
+
const userRewardInfo = positionState.rewardInfos[rewardIndex];
|
|
6378
|
+
const rewardPerTokenStore = new BN6(
|
|
6379
|
+
Buffer.from(poolReward.rewardPerTokenStored).reverse()
|
|
6380
|
+
);
|
|
6381
|
+
const userRewardPerTokenCheckPoint = new BN6(
|
|
6382
|
+
Buffer.from(userRewardInfo.rewardPerTokenCheckpoint).reverse()
|
|
6383
|
+
);
|
|
6384
|
+
const totalPositionLiquidity = positionState.unlockedLiquidity.add(positionState.vestedLiquidity).add(positionState.permanentLockedLiquidity);
|
|
6385
|
+
const newReward = totalPositionLiquidity.mul(rewardPerTokenStore.sub(userRewardPerTokenCheckPoint)).shrn(192);
|
|
6386
|
+
const totalRewardPerPeriod = poolReward.rewardRate.mul(periodTime);
|
|
6387
|
+
const rewardPerTokenStorePerPeriod = totalRewardPerPeriod.shln(128).div(poolState.liquidity);
|
|
6388
|
+
const totalUserRewardPerPeriod = totalPositionLiquidity.mul(rewardPerTokenStorePerPeriod).shrn(192);
|
|
6389
|
+
const totalReward = poolReward.rewardRate.mul(poolReward.rewardDuration).shrn(64);
|
|
6390
|
+
const totalRewardDistributed = rewardPerTokenStore.mul(poolState.liquidity).shrn(192);
|
|
6391
|
+
return {
|
|
6392
|
+
rewardPendings: userRewardInfo.rewardPendings.add(newReward),
|
|
6393
|
+
totalUserRewardPerPeriod,
|
|
6394
|
+
rewardBalance: totalReward.sub(totalRewardDistributed)
|
|
6395
|
+
};
|
|
6396
|
+
}
|
|
6375
6397
|
|
|
6376
6398
|
// src/helpers/accountFilters.ts
|
|
6377
6399
|
var positionByPoolFilter = (pool) => {
|
|
@@ -8993,6 +9015,7 @@ export {
|
|
|
8993
9015
|
getOrCreateATAInstruction,
|
|
8994
9016
|
getPriceFromSqrtPrice,
|
|
8995
9017
|
getPriceImpact,
|
|
9018
|
+
getRewardInfo,
|
|
8996
9019
|
getSecondKey,
|
|
8997
9020
|
getSimulationComputeUnits,
|
|
8998
9021
|
getSqrtPriceFromPrice,
|