@scallop-io/sui-scallop-sdk 2.1.3-merge-split-ve-sca-alpha.2 → 2.1.3-merge-split-ve-sca-alpha.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/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.2",
3
+ "version": "2.1.3-merge-split-ve-sca-alpha.4",
4
4
  "description": "Typescript sdk for interacting with Scallop contract on SUI",
5
5
  "keywords": [
6
6
  "sui",
@@ -18,6 +18,7 @@ const generateLoyaltyProgramNormalMethod: GenerateLoyaltyProgramNormalMethod =
18
18
  };
19
19
 
20
20
  const veScaProgramIds = {
21
+ object: builder.address.get('vesca.object'),
21
22
  protocolConfig: builder.address.get('vesca.config'),
22
23
  veScaTable: builder.address.get('vesca.table'),
23
24
  subsTable: builder.address.get('vesca.subsTable'),
@@ -28,6 +28,7 @@ import type {
28
28
  SuiTxBlockWithVeScaNormalMethods,
29
29
  VeScaTxBlock,
30
30
  } from 'src/types';
31
+ import { SuiObjectData } from '@mysten/sui/client';
31
32
 
32
33
  /**
33
34
  * Check and get veSCA data from transaction block.
@@ -46,11 +47,11 @@ export const requireVeSca = async (
46
47
  ...params: [
47
48
  builder: ScallopBuilder,
48
49
  SuiTxBlock: SuiTxBlock,
49
- veScaKey?: SuiObjectArg,
50
+ veScaKey?: SuiObjectData,
50
51
  ]
51
52
  ) => {
52
53
  const [builder, txBlock, veScaKey] = params;
53
- if (params.length === 3 && veScaKey && typeof veScaKey === 'string') {
54
+ if (params.length === 3 && veScaKey && typeof veScaKey !== 'undefined') {
54
55
  const veSca = await getVeSca(builder.utils, veScaKey);
55
56
 
56
57
  if (!veSca) {
@@ -67,7 +68,13 @@ export const requireVeSca = async (
67
68
  }
68
69
 
69
70
  // return veSCA with the same veScaKey or the highest veSCA balance
70
- return veScaKey ? veScas.find(({ keyId }) => veScaKey === keyId) : veScas[0];
71
+ return veScaKey
72
+ ? veScas.find(
73
+ ({ keyId }) =>
74
+ (typeof veScaKey === 'string' ? veScaKey : veScaKey.objectId) ===
75
+ keyId
76
+ )
77
+ : veScas[0];
71
78
  };
72
79
 
73
80
  export const isInSubsTable = async (
@@ -248,9 +255,14 @@ const generateQuickVeScaMethod: GenerateVeScaQuickMethod = ({
248
255
  txBlock,
249
256
  }) => {
250
257
  return {
251
- lockScaQuick: async (amountOrCoin, lockPeriodInDays, autoCheck = true) => {
258
+ lockScaQuick: async (
259
+ amountOrCoin,
260
+ lockPeriodInDays,
261
+ veScaKey,
262
+ autoCheck = true
263
+ ) => {
252
264
  const sender = requireSender(txBlock);
253
- const veSca = await requireVeSca(builder, txBlock);
265
+ const veSca = await requireVeSca(builder, txBlock, veScaKey);
254
266
 
255
267
  let scaCoin: TransactionObjectArgument | SuiObjectArg | undefined =
256
268
  undefined;
@@ -285,9 +297,9 @@ const generateQuickVeScaMethod: GenerateVeScaQuickMethod = ({
285
297
  veSca?.unlockAt
286
298
  );
287
299
 
288
- const isInitialLock = !veSca?.unlockAt;
300
+ const isInitialLock = !veSca;
289
301
  const isLockExpired =
290
- !isInitialLock && veSca.unlockAt * 1000 <= new Date().getTime();
302
+ !isInitialLock && veSca.unlockAt <= new Date().getTime();
291
303
  if (isInitialLock || isLockExpired) {
292
304
  if (scaCoin) {
293
305
  if (isInitialLock) {
@@ -308,15 +308,15 @@ export const TEST_ADDRESSES: AddressesInterface = {
308
308
  '0x574a11f8a0fbaa05b8f559cb65634e8eb20f26b1ec29e7d58de9167f3cedd0f7',
309
309
  },
310
310
  veScaLoyaltyProgram: {
311
- id: '0x7e95dc10fb96ffb2341f664926417b0fb261c9f3dc417344d2a3b11a2f5bb812',
311
+ id: '0x51bd8c455caedad9d7fd47f9ee75876668c4d6bbede95af39c0aebde46043f00',
312
312
  object:
313
- '0x7e95dc10fb96ffb2341f664926417b0fb261c9f3dc417344d2a3b11a2f5bb812',
313
+ '0x51bd8c455caedad9d7fd47f9ee75876668c4d6bbede95af39c0aebde46043f00',
314
314
  adminCap:
315
- '0x4fc52ce8aab57eaa154d9ee42e9d8ecb7add6176d19ff65ebac59bf196b12de8',
315
+ '0xb2d52e0ebb260cb42699be6a9804e12d6fa17b79ef1e43f9996df5ca71bac0ae',
316
316
  veScaRewardPool:
317
- '0x59025ec74adfcde1e0d793ff432fa0281f47fe4239aa8811430f10307292eca4',
317
+ '0x4fe34992bf2261c3c6c14b2dbf9606ce65a505c45ff778ac129ce7dea9b0cadf',
318
318
  veScaRewardTableId:
319
- '0xbfa64d2dcd45c9dee92b8c0e052954c05bd687b4e3b132ace9c1f6d6cf619eba',
319
+ '0x85d3e557d9bbed617b9cbc09982a0c9a6f6f4fc9ecce49b59124206c409c4774',
320
320
  },
321
321
  scoin: {
322
322
  id: '0x826a4934bee9487e558eed603cf42f30cdc4321d6f31083930791b95f903b9f9',
@@ -53,6 +53,7 @@ export type VeScaQuickMethods = {
53
53
  lockScaQuick(
54
54
  amountOrCoin?: SuiObjectArg | number,
55
55
  lockPeriodInDays?: number,
56
+ veScaKey?: SuiObjectArg,
56
57
  autoCheck?: boolean
57
58
  ): Promise<void>;
58
59
  extendLockPeriodQuick: (