@scallop-io/sui-scallop-sdk 0.46.36 → 0.46.38

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.
Files changed (45) hide show
  1. package/dist/builders/loyaltyProgramBuilder.d.ts +12 -0
  2. package/dist/builders/referralBuilder.d.ts +1 -1
  3. package/dist/constants/testAddress.d.ts +2 -0
  4. package/dist/index.js +684 -172
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +674 -162
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/models/scallopQuery.d.ts +10 -3
  9. package/dist/models/scallopUtils.d.ts +1 -1
  10. package/dist/queries/index.d.ts +1 -0
  11. package/dist/queries/loyaltyProgramQuery.d.ts +10 -0
  12. package/dist/queries/vescaQuery.d.ts +8 -6
  13. package/dist/types/address.d.ts +6 -0
  14. package/dist/types/builder/index.d.ts +3 -1
  15. package/dist/types/builder/loyaltyProgram.d.ts +23 -0
  16. package/dist/types/builder/vesca.d.ts +16 -0
  17. package/dist/types/query/index.d.ts +1 -0
  18. package/dist/types/query/loyaltyProgram.d.ts +5 -0
  19. package/dist/types/query/vesca.d.ts +18 -0
  20. package/dist/utils/builder.d.ts +6 -5
  21. package/package.json +7 -6
  22. package/src/builders/index.ts +6 -1
  23. package/src/builders/loyaltyProgramBuilder.ts +115 -0
  24. package/src/builders/referralBuilder.ts +1 -1
  25. package/src/builders/vescaBuilder.ts +5 -1
  26. package/src/constants/testAddress.ts +383 -0
  27. package/src/models/scallopAddress.ts +12 -2
  28. package/src/models/scallopCache.ts +0 -1
  29. package/src/models/scallopQuery.ts +28 -16
  30. package/src/models/scallopUtils.ts +3 -3
  31. package/src/queries/borrowIncentiveQuery.ts +9 -8
  32. package/src/queries/coreQuery.ts +70 -66
  33. package/src/queries/index.ts +1 -0
  34. package/src/queries/loyaltyProgramQuery.ts +77 -0
  35. package/src/queries/portfolioQuery.ts +36 -28
  36. package/src/queries/vescaQuery.ts +70 -15
  37. package/src/types/address.ts +6 -0
  38. package/src/types/builder/index.ts +3 -0
  39. package/src/types/builder/loyaltyProgram.ts +35 -0
  40. package/src/types/builder/vesca.ts +16 -0
  41. package/src/types/query/index.ts +1 -0
  42. package/src/types/query/loyaltyProgram.ts +5 -0
  43. package/src/types/query/vesca.ts +21 -0
  44. package/src/utils/builder.ts +69 -53
  45. package/src/utils/query.ts +6 -5
@@ -4,6 +4,7 @@ import { ScallopAddress } from './scallopAddress';
4
4
  import { ScallopUtils } from './scallopUtils';
5
5
  import { ScallopIndexer } from './scallopIndexer';
6
6
  import { ScallopCache } from './scallopCache';
7
+ import { SuiObjectData } from '@mysten/sui.js/src/client';
7
8
  /**
8
9
  * @description
9
10
  * It provides methods for getting on-chain data from the Scallop contract.
@@ -370,14 +371,14 @@ export declare class ScallopQuery {
370
371
  * @param walletAddress
371
372
  * @returns array of veSca
372
373
  */
373
- getVeScas(walletAddress: string): Promise<(import("../types").Vesca | undefined)[]>;
374
+ getVeScas(walletAddress?: string): Promise<import("../types").Vesca[]>;
374
375
  /**
375
376
  * Get total vesca treasury with movecall
376
377
  * @returns Promise<string | undefined>
377
378
  */
378
- getTotalVeScaTreasuryAmount(): Promise<string>;
379
+ getVeScaTreasuryInfo(): Promise<import("../types").VeScaTreasuryInfo | null>;
379
380
  /**
380
- * Return binded veScaKeyId of walletAddress if exist
381
+ * Return binded referrer veScaKeyId of referee walletAddress if exist
381
382
  * @param walletAddress
382
383
  * @returns veScaKeyId
383
384
  */
@@ -394,4 +395,10 @@ export declare class ScallopQuery {
394
395
  * @returns veScaKey
395
396
  */
396
397
  getBindedVeScaKey(obligationId: string): Promise<string | null>;
398
+ /**
399
+ * Get user's veSCA loyalty program informations
400
+ * @param walletAddress
401
+ * @returns Loyalty program information
402
+ */
403
+ getLoyaltyProgramInfos(veScaKey?: string | SuiObjectData): Promise<import("../types").LoyaltyProgramInfo | null>;
397
404
  }
@@ -171,5 +171,5 @@ export declare class ScallopUtils {
171
171
  * @param unlockAtInSecondTimestamp The unlock timestamp from veSca object.
172
172
  * @return New unlock at in seconds timestamp.
173
173
  */
174
- getUnlockAt(extendLockPeriodInDay?: number, unlockAtInSecondTimestamp?: number): number;
174
+ getUnlockAt(extendLockPeriodInDay?: number, unlockAtInMillisTimestamp?: number): number;
175
175
  }
@@ -5,3 +5,4 @@ export * from './priceQuery';
5
5
  export * from './portfolioQuery';
6
6
  export * from './vescaQuery';
7
7
  export * from './referralQuery';
8
+ export * from './loyaltyProgramQuery';
@@ -0,0 +1,10 @@
1
+ import { SuiObjectData } from '@mysten/sui.js/src/client';
2
+ import { ScallopQuery } from 'src/models';
3
+ import { LoyaltyProgramInfo } from 'src/types';
4
+ /**
5
+ * Get user's loyalty program information and pending rewards if exists
6
+ * @param query
7
+ * @param veScaKey
8
+ * @returns
9
+ */
10
+ export declare const getLoyaltyProgramInformations: (query: ScallopQuery, veScaKey?: string | SuiObjectData) => Promise<LoyaltyProgramInfo | null>;
@@ -1,4 +1,4 @@
1
- import { Vesca } from '../types';
1
+ import { VeScaTreasuryInfo, Vesca } from '../types';
2
2
  import { type SuiObjectData } from '@mysten/sui.js/client';
3
3
  import type { ScallopQuery } from '../models';
4
4
  /**
@@ -16,17 +16,19 @@ export declare const getVescaKeys: (query: ScallopQuery, ownerAddress?: string)
16
16
  * @param ownerAddress - The owner address.
17
17
  * @return Owned veScas.
18
18
  */
19
- export declare const getVeScas: (query: ScallopQuery, ownerAddress?: string) => Promise<(Vesca | undefined)[]>;
19
+ export declare const getVeScas: (query: ScallopQuery, ownerAddress?: string) => Promise<Vesca[]>;
20
20
  /**
21
21
  * Get veSca data.
22
22
  *
23
23
  * @param query - The Scallop query instance.
24
- * @param veScaKeyId - The vesca key id.
24
+ * @param veScaKey - The vesca key id.
25
25
  * @param ownerAddress - The owner address.
26
26
  * @returns Vesca data.
27
27
  */
28
- export declare const getVeSca: (query: ScallopQuery, veScaKeyId?: string, ownerAddress?: string) => Promise<Vesca | undefined>;
28
+ export declare const getVeSca: (query: ScallopQuery, veScaKey?: string | SuiObjectData, ownerAddress?: string) => Promise<Vesca | undefined>;
29
29
  /**
30
- * Get current total veSca treasury amount.
30
+ * Get veSCA treasury informations
31
+ * @param query
32
+ * @returns VeScaTreasuryInfo
31
33
  */
32
- export declare const getTotalVeScaTreasuryAmount: (query: ScallopQuery) => Promise<string>;
34
+ export declare const getVeScaTreasuryInfo: (query: ScallopQuery) => Promise<VeScaTreasuryInfo | null>;
@@ -85,6 +85,12 @@ export interface AddressesInterface {
85
85
  tiersTableId: string;
86
86
  authorizedWitnessList: string;
87
87
  };
88
+ loyaltyProgram: {
89
+ id: string;
90
+ object: string;
91
+ rewardPool: string;
92
+ userRewardTableId: string;
93
+ };
88
94
  }
89
95
  type AddressPathsProps<T> = T extends string ? [] : {
90
96
  [K in Extract<keyof T, string>]: [K, ...AddressPathsProps<T[K]>];
@@ -3,8 +3,10 @@ import type { SpoolTxBlock } from './spool';
3
3
  import type { BorrowIncentiveTxBlock } from './borrowIncentive';
4
4
  import type { VeScaTxBlock } from './vesca';
5
5
  import type { ReferralTxBlock } from './referral';
6
+ import { LoyaltyProgramTxBlock } from './loyaltyProgram';
6
7
  export type * from './core';
7
8
  export type * from './spool';
8
9
  export type * from './borrowIncentive';
9
10
  export type * from './vesca';
10
- export type ScallopTxBlock = CoreTxBlock & SpoolTxBlock & ReferralTxBlock & BorrowIncentiveTxBlock & VeScaTxBlock;
11
+ export type * from './loyaltyProgram';
12
+ export type ScallopTxBlock = CoreTxBlock & SpoolTxBlock & ReferralTxBlock & LoyaltyProgramTxBlock & BorrowIncentiveTxBlock & VeScaTxBlock;
@@ -0,0 +1,23 @@
1
+ import { SuiObjectArg, SuiTxBlock as SuiKitTxBlock, TransactionResult } from '@scallop-io/sui-kit';
2
+ import { type ScallopBuilder } from 'src/models';
3
+ export type LoyaltyProgramIds = {
4
+ loyaltyProgramPkgId: string;
5
+ rewardPool: string;
6
+ userRewardTableId: string;
7
+ };
8
+ export type LoyaltyProgramNormalMethods = {
9
+ claimLoyaltyRevenue: (veScaKey: SuiObjectArg) => TransactionResult;
10
+ };
11
+ export type LoyaltyProgramQuickMethods = {
12
+ claimLoyaltyRevenueQuick: (veScaKey?: SuiObjectArg) => Promise<void>;
13
+ };
14
+ export type SuiTxBlockWithLoyaltyProgramNormalMethods = SuiKitTxBlock & LoyaltyProgramNormalMethods;
15
+ export type LoyaltyProgramTxBlock = SuiTxBlockWithLoyaltyProgramNormalMethods & LoyaltyProgramQuickMethods;
16
+ export type GenerateLoyaltyProgramNormalMethod = (params: {
17
+ builder: ScallopBuilder;
18
+ txBlock: SuiKitTxBlock;
19
+ }) => LoyaltyProgramNormalMethods;
20
+ export type GenerateLoyaltyProgramQuickMethod = (params: {
21
+ builder: ScallopBuilder;
22
+ txBlock: SuiTxBlockWithLoyaltyProgramNormalMethods;
23
+ }) => LoyaltyProgramQuickMethods;
@@ -16,6 +16,22 @@ export type VeScaNormalMethods = {
16
16
  mintEmptyVeSca: () => TransactionResult;
17
17
  };
18
18
  export type VeScaQuickMethods = {
19
+ /**
20
+ * Quick methods to automate
21
+ * lock initial SCA, extend lock period, lock more SCA, renew expired VeSCA, and redeem SCA
22
+ *
23
+ * **Flow:**
24
+ * - If only `amountOrCoin` is provided, it will lock the amount of existing not expired veSCA
25
+ * - If only `lockPeriodInDays` is provided, it will extend the lock period of existing not expired veSCA
26
+ *
27
+ * **Note:**
28
+ * - If one or both flow above is used on a expired veSCA, it will claim the unlocked SCA
29
+ * and renew the veSCA first, and then flow continues
30
+ * - If users has no veSCA yet, they need to provide both `amountOrCoin` and `lockPeriodInDays` for initial lock
31
+ * @param amountOrCoin
32
+ * @param lockPeriodInDays
33
+ * @param autoCheck
34
+ */
19
35
  lockScaQuick(amountOrCoin?: SuiObjectArg | number, lockPeriodInDays?: number, autoCheck?: boolean): Promise<void>;
20
36
  extendLockPeriodQuick: (lockPeriodInDays: number, veScaKey?: SuiObjectArg, autoCheck?: boolean) => Promise<void>;
21
37
  extendLockAmountQuick: (scaAmount: number, veScaKey?: SuiObjectArg, autoCheck?: boolean) => Promise<void>;
@@ -3,3 +3,4 @@ export type * from './spool';
3
3
  export type * from './borrowIncentive';
4
4
  export type * from './portfolio';
5
5
  export type * from './vesca';
6
+ export type * from './loyaltyProgram';
@@ -0,0 +1,5 @@
1
+ export type LoyaltyProgramInfo = {
2
+ pendingReward: number;
3
+ totalPoolReward: number;
4
+ isClaimEnabled: boolean;
5
+ };
@@ -1,8 +1,26 @@
1
+ import type { SuiObjectRef } from '@mysten/sui.js/client';
1
2
  export type Vesca = {
2
3
  id: string;
3
4
  keyId: string;
5
+ keyObject?: SuiObjectRef;
6
+ object?: SuiObjectRef;
4
7
  lockedScaAmount: string;
5
8
  lockedScaCoin: number;
6
9
  currentVeScaBalance: number;
7
10
  unlockAt: number;
8
11
  };
12
+ export type VeScaTreasuryFields = {
13
+ total_ve_sca_amount: string;
14
+ sca_balance: string;
15
+ unlock_schedule: {
16
+ fields: {
17
+ locked_sca_amount: string;
18
+ };
19
+ };
20
+ };
21
+ export type VeScaTreasuryInfo = {
22
+ totalLockedSca: number;
23
+ totalVeSca: number;
24
+ averageLockingPeriod: number;
25
+ averageLockingPeriodUnit: string;
26
+ };
@@ -7,8 +7,9 @@ import type { SuiObjectArg } from '@scallop-io/sui-kit';
7
7
  * @return Sender of transaction.
8
8
  */
9
9
  export declare const requireSender: (txBlock: SuiKitTxBlock) => string;
10
- export declare const checkLockSca: (scaAmountOrCoin?: number | SuiObjectArg | undefined, lockPeriodInDays?: number, newUnlockAtInSecondTimestamp?: number, prevUnlockAtInSecondTimestamp?: number) => void;
11
- export declare const checkExtendLockPeriod: (lockPeriodInDays: number, newUnlockAtInSecondTimestamp: number, prevUnlockAtInSecondTimestamp?: number) => void;
12
- export declare const checkExtendLockAmount: (scaAmount: number, prevUnlockAtInSecondTimestamp?: number) => void;
13
- export declare const checkRenewExpiredVeSca: (scaAmount: number, lockPeriodInDays: number, prevUnlockAtInSecondTimestamp?: number) => void;
14
- export declare const checkVesca: (prevUnlockAtInSecondTimestamp?: number) => void;
10
+ export declare const checkVesca: (prevUnlockAtInMillisTimestamp?: number) => void;
11
+ export declare const checkVescaExpired: (prevUnlockAtInMillisTimestamp: number) => void;
12
+ export declare const checkExtendLockPeriod: (lockPeriodInDays: number, newUnlockAtInSecondTimestamp: number, prevUnlockAtInMillisTimestamp?: number) => void;
13
+ export declare const checkLockSca: (scaAmountOrCoin: number | SuiObjectArg | undefined, lockPeriodInDays?: number, newUnlockAtInSecondTimestamp?: number, prevUnlockAtInMillisTimestamp?: number) => void;
14
+ export declare const checkExtendLockAmount: (scaAmount: number, prevUnlockAtInMillisTimestamp?: number) => void;
15
+ export declare const checkRenewExpiredVeSca: (scaAmount: number, lockPeriodInDays: number, prevUnlockAtInMillisTimestamp?: number) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scallop-io/sui-scallop-sdk",
3
- "version": "0.46.36",
3
+ "version": "0.46.38",
4
4
  "description": "Typescript sdk for interacting with Scallop contract on SUI",
5
5
  "keywords": [
6
6
  "sui",
@@ -20,7 +20,7 @@
20
20
  "access": "public"
21
21
  },
22
22
  "engines": {
23
- "node": ">=16"
23
+ "node": ">=18.15.0"
24
24
  },
25
25
  "main": "./dist/index.js",
26
26
  "module": "./dist/index.mjs",
@@ -39,7 +39,7 @@
39
39
  ],
40
40
  "dependencies": {
41
41
  "@mysten/bcs": "^0.8.1",
42
- "@mysten/sui.js": "^0.49.1",
42
+ "@mysten/sui.js": "^0.52.0",
43
43
  "@noble/curves": "^1.2.0",
44
44
  "@noble/hashes": "^1.3.2",
45
45
  "@pythnetwork/price-service-client": "^1.8.2",
@@ -51,7 +51,8 @@
51
51
  "bech32": "^2.0.0",
52
52
  "bignumber.js": "^9.1.2",
53
53
  "superstruct": "^1.0.3",
54
- "tweetnacl": "^1.0.3"
54
+ "tweetnacl": "^1.0.3",
55
+ "zod": "^3.23.8"
55
56
  },
56
57
  "devDependencies": {
57
58
  "@commitlint/cli": "^18.2.0",
@@ -75,8 +76,8 @@
75
76
  "vitest": "^0.34.6"
76
77
  },
77
78
  "peerDependencies": {
78
- "@mysten/sui.js": "0.49.1",
79
- "@scallop-io/sui-kit": "^0.44.2",
79
+ "@mysten/sui.js": "0.52.0",
80
+ "@scallop-io/sui-kit": "^0.45.0",
80
81
  "bn.js": "^5.2.1"
81
82
  },
82
83
  "lint-staged": {
@@ -7,6 +7,7 @@ import { newVeScaTxBlock } from './vescaBuilder';
7
7
  import type { ScallopBuilder } from '../models';
8
8
  import type { ScallopTxBlock } from '../types';
9
9
  import { newReferralTxBlock } from './referralBuilder';
10
+ import { newLoyaltyProgramTxBlock } from './loyaltyProgramBuilder';
10
11
 
11
12
  /**
12
13
  * Create a new ScallopTxBlock instance.
@@ -20,13 +21,15 @@ export const newScallopTxBlock = (
20
21
  initTxBlock?: ScallopTxBlock | SuiKitTxBlock | TransactionBlock
21
22
  ): ScallopTxBlock => {
22
23
  const vescaTxBlock = newVeScaTxBlock(builder, initTxBlock);
24
+ const loyaltyTxBlock = newLoyaltyProgramTxBlock(builder, vescaTxBlock);
23
25
  const borrowIncentiveTxBlock = newBorrowIncentiveTxBlock(
24
26
  builder,
25
- vescaTxBlock
27
+ loyaltyTxBlock
26
28
  );
27
29
  const referralTxBlock = newReferralTxBlock(builder, borrowIncentiveTxBlock);
28
30
  const spoolTxBlock = newSpoolTxBlock(builder, referralTxBlock);
29
31
  const coreTxBlock = newCoreTxBlock(builder, spoolTxBlock);
32
+
30
33
  return new Proxy(coreTxBlock, {
31
34
  get: (target, prop) => {
32
35
  if (prop in vescaTxBlock) {
@@ -37,6 +40,8 @@ export const newScallopTxBlock = (
37
40
  return Reflect.get(referralTxBlock, prop);
38
41
  } else if (prop in spoolTxBlock) {
39
42
  return Reflect.get(spoolTxBlock, prop);
43
+ } else if (prop in loyaltyTxBlock) {
44
+ return Reflect.get(loyaltyTxBlock, prop);
40
45
  }
41
46
  return Reflect.get(target, prop);
42
47
  },
@@ -0,0 +1,115 @@
1
+ import { TransactionBlock } from '@mysten/sui.js/transactions';
2
+ import { SuiObjectArg, SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
3
+ import { coinIds } from 'src/constants';
4
+ import { ScallopBuilder } from 'src/models';
5
+ import {
6
+ GenerateLoyaltyProgramNormalMethod,
7
+ GenerateLoyaltyProgramQuickMethod,
8
+ LoyaltyProgramIds,
9
+ LoyaltyProgramTxBlock,
10
+ ScallopTxBlock,
11
+ SuiTxBlockWithLoyaltyProgramNormalMethods,
12
+ } from 'src/types';
13
+ import { requireSender } from 'src/utils';
14
+
15
+ const generateLoyaltyProgramNormalMethod: GenerateLoyaltyProgramNormalMethod =
16
+ ({ builder, txBlock }) => {
17
+ const loyaltyProgramIds: LoyaltyProgramIds = {
18
+ loyaltyProgramPkgId: builder.address.get('loyaltyProgram.id'),
19
+ rewardPool: builder.address.get('loyaltyProgram.rewardPool'),
20
+ userRewardTableId: builder.address.get(
21
+ 'loyaltyProgram.userRewardTableId'
22
+ ),
23
+ };
24
+
25
+ return {
26
+ claimLoyaltyRevenue: (veScaKey) => {
27
+ return txBlock.moveCall(
28
+ `${loyaltyProgramIds.loyaltyProgramPkgId}::reward_pool::redeem_reward`,
29
+ [loyaltyProgramIds.rewardPool, veScaKey]
30
+ );
31
+ },
32
+ };
33
+ };
34
+
35
+ const generateLoyaltyProgramQuickMethod: GenerateLoyaltyProgramQuickMethod = ({
36
+ builder,
37
+ txBlock,
38
+ }) => {
39
+ return {
40
+ claimLoyaltyRevenueQuick: async (veScaKey) => {
41
+ veScaKey = veScaKey || (await builder.query.getVeScas())[0]?.keyObject;
42
+ const sender = requireSender(txBlock);
43
+ if (!veScaKey) throw new Error(`No veScaKey found for user ${sender}`);
44
+
45
+ // claim the pending reward
46
+ const toTransferObject: SuiObjectArg[] = [];
47
+ const rewardCoin = txBlock.claimLoyaltyRevenue(veScaKey);
48
+
49
+ // get existing sca coin to merge with
50
+ try {
51
+ const existingScaCoin = await builder.suiKit.suiInteractor.selectCoins(
52
+ sender,
53
+ Infinity,
54
+ coinIds.sca
55
+ );
56
+ txBlock.mergeCoins(rewardCoin, existingScaCoin);
57
+ } catch (e) {
58
+ // ignore
59
+ } finally {
60
+ toTransferObject.push(rewardCoin);
61
+ }
62
+
63
+ if (toTransferObject.length > 0) {
64
+ txBlock.transferObjects(toTransferObject, sender);
65
+ }
66
+ },
67
+ };
68
+ };
69
+
70
+ /**
71
+ * Create an enhanced transaction block instance for interaction with borrow incentive modules of the Scallop contract.
72
+ *
73
+ * @param builder - Scallop builder instance.
74
+ * @param initTxBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
75
+ * @return Scallop loyalty program txBlock.
76
+ */
77
+ export const newLoyaltyProgramTxBlock = (
78
+ builder: ScallopBuilder,
79
+ initTxBlock?: ScallopTxBlock | SuiKitTxBlock | TransactionBlock
80
+ ) => {
81
+ const txBlock =
82
+ initTxBlock instanceof TransactionBlock
83
+ ? new SuiKitTxBlock(initTxBlock)
84
+ : initTxBlock
85
+ ? initTxBlock
86
+ : new SuiKitTxBlock();
87
+
88
+ const normalMethod = generateLoyaltyProgramNormalMethod({
89
+ builder,
90
+ txBlock,
91
+ });
92
+
93
+ const normalTxBlock = new Proxy(txBlock, {
94
+ get: (target, prop) => {
95
+ if (prop in normalMethod) {
96
+ return Reflect.get(normalMethod, prop);
97
+ }
98
+ return Reflect.get(target, prop);
99
+ },
100
+ }) as SuiTxBlockWithLoyaltyProgramNormalMethods;
101
+
102
+ const quickMethod = generateLoyaltyProgramQuickMethod({
103
+ builder,
104
+ txBlock: normalTxBlock,
105
+ });
106
+
107
+ return new Proxy(normalTxBlock, {
108
+ get: (target, prop) => {
109
+ if (prop in quickMethod) {
110
+ return Reflect.get(quickMethod, prop);
111
+ }
112
+ return Reflect.get(target, prop);
113
+ },
114
+ }) as LoyaltyProgramTxBlock;
115
+ };
@@ -137,7 +137,7 @@ const generateReferralQuickMethod: GenerateReferralQuickMethod = ({
137
137
  *
138
138
  * @param builder - Scallop builder instance.
139
139
  * @param initTxBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
140
- * @return Scallop borrow incentive txBlock.
140
+ * @return Scallop referral txBlock.
141
141
  */
142
142
  export const newReferralTxBlock = (
143
143
  builder: ScallopBuilder,
@@ -212,6 +212,7 @@ const generateQuickVeScaMethod: GenerateVeScaQuickMethod = ({
212
212
  lockPeriodInDays,
213
213
  veSca?.unlockAt
214
214
  );
215
+
215
216
  if (autoCheck)
216
217
  checkLockSca(
217
218
  amountOrCoin,
@@ -259,8 +260,11 @@ const generateQuickVeScaMethod: GenerateVeScaQuickMethod = ({
259
260
  autoCheck = true
260
261
  ) => {
261
262
  const veSca = await requireVeSca(builder, txBlock, veScaKey);
263
+ const newUnlockAt = builder.utils.getUnlockAt(
264
+ lockPeriodInDays,
265
+ veSca?.unlockAt
266
+ );
262
267
 
263
- const newUnlockAt = builder.utils.getUnlockAt(lockPeriodInDays);
264
268
  if (autoCheck)
265
269
  checkExtendLockPeriod(lockPeriodInDays, newUnlockAt, veSca?.unlockAt);
266
270