@meteora-ag/cp-amm-sdk 1.0.11-rc.6 → 1.0.11-rc.8
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 +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +38 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -6742,8 +6742,12 @@ declare const getUnClaimReward: (poolState: PoolState, positionState: PositionSt
|
|
|
6742
6742
|
declare function getRewardInfo(poolState: PoolState, rewardIndex: number, periodTime: BN, currentTime: BN): {
|
|
6743
6743
|
rewardPerPeriod: BN;
|
|
6744
6744
|
rewardBalance: BN;
|
|
6745
|
+
totalRewardDistributed: BN;
|
|
6746
|
+
};
|
|
6747
|
+
declare function getUserRewardPending(poolState: PoolState, positionState: PositionState, rewardIndex: number, currentTime: BN, periodTime: BN): {
|
|
6748
|
+
userRewardPerPeriod: BN;
|
|
6749
|
+
userPendingReward: BN;
|
|
6745
6750
|
};
|
|
6746
|
-
declare function getUserRewardPending(poolState: PoolState, positionState: PositionState, rewardIndex: number, currentTime: BN): BN;
|
|
6747
6751
|
|
|
6748
6752
|
declare const positionByPoolFilter: (pool: PublicKey) => GetProgramAccountsFilter;
|
|
6749
6753
|
declare const vestingByPositionFilter: (position: PublicKey) => GetProgramAccountsFilter;
|
package/dist/index.d.ts
CHANGED
|
@@ -6742,8 +6742,12 @@ declare const getUnClaimReward: (poolState: PoolState, positionState: PositionSt
|
|
|
6742
6742
|
declare function getRewardInfo(poolState: PoolState, rewardIndex: number, periodTime: BN, currentTime: BN): {
|
|
6743
6743
|
rewardPerPeriod: BN;
|
|
6744
6744
|
rewardBalance: BN;
|
|
6745
|
+
totalRewardDistributed: BN;
|
|
6746
|
+
};
|
|
6747
|
+
declare function getUserRewardPending(poolState: PoolState, positionState: PositionState, rewardIndex: number, currentTime: BN, periodTime: BN): {
|
|
6748
|
+
userRewardPerPeriod: BN;
|
|
6749
|
+
userPendingReward: BN;
|
|
6745
6750
|
};
|
|
6746
|
-
declare function getUserRewardPending(poolState: PoolState, positionState: PositionState, rewardIndex: number, currentTime: BN): BN;
|
|
6747
6751
|
|
|
6748
6752
|
declare const positionByPoolFilter: (pool: PublicKey) => GetProgramAccountsFilter;
|
|
6749
6753
|
declare const vestingByPositionFilter: (position: PublicKey) => GetProgramAccountsFilter;
|
package/dist/index.js
CHANGED
|
@@ -6385,27 +6385,57 @@ function getRewardPerTokenStore(poolReward, poolLiquidity, currentTime) {
|
|
|
6385
6385
|
).add(rewardPerTokenStore);
|
|
6386
6386
|
return totalRewardPerTokenStore;
|
|
6387
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
|
+
}
|
|
6388
6394
|
function getRewardInfo(poolState, rewardIndex, periodTime, currentTime) {
|
|
6389
6395
|
const poolReward = poolState.rewardInfos[rewardIndex];
|
|
6390
|
-
const
|
|
6391
|
-
|
|
6392
|
-
|
|
6396
|
+
const rewardPerTokenStore = getRewardPerTokenStore(
|
|
6397
|
+
poolReward,
|
|
6398
|
+
poolState.liquidity,
|
|
6399
|
+
currentTime
|
|
6400
|
+
);
|
|
6393
6401
|
const totalRewardDistributed = rewardPerTokenStore.mul(poolState.liquidity).shrn(192);
|
|
6402
|
+
const rewardPerPeriod = getRewardPerPeriod(
|
|
6403
|
+
poolReward,
|
|
6404
|
+
currentTime,
|
|
6405
|
+
periodTime
|
|
6406
|
+
);
|
|
6407
|
+
const remainTime = poolReward.rewardDurationEnd.sub(currentTime);
|
|
6408
|
+
const rewardBalance = poolReward.rewardRate.mul(remainTime).shrn(64);
|
|
6394
6409
|
return {
|
|
6395
|
-
rewardPerPeriod:
|
|
6396
|
-
rewardBalance
|
|
6410
|
+
rewardPerPeriod: rewardPerPeriod.shrn(64),
|
|
6411
|
+
rewardBalance,
|
|
6412
|
+
totalRewardDistributed
|
|
6397
6413
|
};
|
|
6398
6414
|
}
|
|
6399
|
-
function getUserRewardPending(poolState, positionState, rewardIndex, currentTime) {
|
|
6415
|
+
function getUserRewardPending(poolState, positionState, rewardIndex, currentTime, periodTime) {
|
|
6400
6416
|
const poolReward = poolState.rewardInfos[rewardIndex];
|
|
6401
6417
|
const userRewardInfo = positionState.rewardInfos[rewardIndex];
|
|
6402
|
-
const rewardPerTokenStore = getRewardPerTokenStore(
|
|
6418
|
+
const rewardPerTokenStore = getRewardPerTokenStore(
|
|
6419
|
+
poolReward,
|
|
6420
|
+
poolState.liquidity,
|
|
6421
|
+
currentTime
|
|
6422
|
+
);
|
|
6403
6423
|
const totalPositionLiquidity = positionState.unlockedLiquidity.add(positionState.vestedLiquidity).add(positionState.permanentLockedLiquidity);
|
|
6404
6424
|
const userRewardPerTokenCheckPoint = new (0, _anchor.BN)(
|
|
6405
6425
|
Buffer.from(userRewardInfo.rewardPerTokenCheckpoint).reverse()
|
|
6406
6426
|
);
|
|
6407
6427
|
const newReward = totalPositionLiquidity.mul(rewardPerTokenStore.sub(userRewardPerTokenCheckPoint)).shrn(192);
|
|
6408
|
-
|
|
6428
|
+
const rewardPerPeriod = getRewardPerPeriod(
|
|
6429
|
+
poolReward,
|
|
6430
|
+
currentTime,
|
|
6431
|
+
periodTime
|
|
6432
|
+
);
|
|
6433
|
+
const rewardPerTokenStorePerPeriod = rewardPerPeriod.shln(128).div(poolState.liquidity);
|
|
6434
|
+
const userRewardPerPeriod = totalPositionLiquidity.mul(rewardPerTokenStorePerPeriod).shrn(192);
|
|
6435
|
+
return {
|
|
6436
|
+
userPendingReward: userRewardInfo.rewardPendings.add(newReward),
|
|
6437
|
+
userRewardPerPeriod
|
|
6438
|
+
};
|
|
6409
6439
|
}
|
|
6410
6440
|
|
|
6411
6441
|
// src/helpers/accountFilters.ts
|