@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scallop-io/sui-scallop-sdk",
3
- "version": "2.1.3-merge-split-ve-sca-alpha.1",
3
+ "version": "2.1.3-merge-split-ve-sca-alpha.2",
4
4
  "description": "Typescript sdk for interacting with Scallop contract on SUI",
5
5
  "keywords": [
6
6
  "sui",
@@ -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
- const reserveVeSca = await query.getVeSca(reserveVeScaKey);
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.pendingVeScaReward = userVeScaRewardFieldsZod.parse(
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
  };
@@ -6,6 +6,7 @@ export type LoyaltyProgramInfo = {
6
6
 
7
7
  export type VeScaLoyaltyProgramInfo = {
8
8
  pendingVeScaReward: number;
9
+ pendingScaReward: number;
9
10
  totalPoolReward: number;
10
11
  isClaimEnabled: boolean;
11
12
  };