@scallop-io/sui-scallop-sdk 2.1.3-merge-split-ve-sca-alpha.1 → 2.1.3-merge-split-ve-sca-alpha.2
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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
- package/src/queries/loyaltyProgramQuery.ts +15 -2
- package/src/types/query/loyaltyProgram.ts +1 -0
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SuiObjectData } from '@mysten/sui/client';
|
|
2
2
|
import BigNumber from 'bignumber.js';
|
|
3
|
+
import { MAX_LOCK_DURATION } from 'src/constants';
|
|
3
4
|
import { ScallopQuery } from 'src/models';
|
|
4
5
|
import { LoyaltyProgramInfo, VeScaLoyaltyProgramInfo } from 'src/types';
|
|
5
6
|
import { z as zod } from 'zod';
|
|
@@ -121,13 +122,15 @@ export const getVeScaLoyaltyProgramInformations = async (
|
|
|
121
122
|
|
|
122
123
|
const result: VeScaLoyaltyProgramInfo = {
|
|
123
124
|
pendingVeScaReward: 0,
|
|
125
|
+
pendingScaReward: 0,
|
|
124
126
|
totalPoolReward: 0,
|
|
125
127
|
isClaimEnabled,
|
|
126
128
|
};
|
|
127
129
|
|
|
130
|
+
let reserveVeSca;
|
|
128
131
|
// calculate totalPoolreward from reserveVeScaKey
|
|
129
132
|
if (reserveVeScaKey) {
|
|
130
|
-
|
|
133
|
+
reserveVeSca = await query.getVeSca(reserveVeScaKey);
|
|
131
134
|
result.totalPoolReward = reserveVeSca?.currentVeScaBalance ?? 0;
|
|
132
135
|
}
|
|
133
136
|
|
|
@@ -151,8 +154,18 @@ export const getVeScaLoyaltyProgramInformations = async (
|
|
|
151
154
|
|
|
152
155
|
if (userRewardObject?.data?.content?.dataType !== 'moveObject') return result;
|
|
153
156
|
const userRewardFields = userRewardObject.data.content.fields;
|
|
154
|
-
result.
|
|
157
|
+
result.pendingScaReward = userVeScaRewardFieldsZod.parse(
|
|
155
158
|
userRewardFields
|
|
156
159
|
) as UserVeScaRewardFields;
|
|
160
|
+
|
|
161
|
+
const remainingLockPeriodInMilliseconds = Math.max(
|
|
162
|
+
(reserveVeSca?.unlockAt ?? 0) - Date.now(),
|
|
163
|
+
0
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
result.pendingVeScaReward =
|
|
167
|
+
result.pendingScaReward *
|
|
168
|
+
(Math.floor(remainingLockPeriodInMilliseconds / 1000) / MAX_LOCK_DURATION);
|
|
169
|
+
|
|
157
170
|
return result;
|
|
158
171
|
};
|