@scallop-io/sui-scallop-sdk 0.44.13 → 0.44.15
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/constants/common.d.ts +1 -1
- package/dist/index.js +97 -43
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +97 -43
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopBuilder.d.ts +2 -2
- package/dist/models/scallopClient.d.ts +4 -4
- package/dist/models/scallopQuery.d.ts +12 -3
- package/dist/queries/coreQuery.d.ts +3 -3
- package/dist/queries/spoolQuery.d.ts +3 -0
- package/dist/types/builder/borrowIncentive.d.ts +4 -4
- package/dist/types/query/portfolio.d.ts +2 -1
- package/package.json +1 -1
- package/src/builders/borrowIncentiveBuilder.ts +12 -8
- package/src/builders/spoolBuilder.ts +2 -2
- package/src/constants/common.ts +8 -1
- package/src/constants/enum.ts +6 -0
- package/src/models/scallopAddress.ts +16 -0
- package/src/models/scallopBuilder.ts +5 -5
- package/src/models/scallopClient.ts +8 -26
- package/src/queries/portfolioQuery.ts +5 -0
- package/src/queries/spoolQuery.ts +36 -0
- package/src/types/builder/borrowIncentive.ts +2 -6
- package/src/types/query/portfolio.ts +4 -1
|
@@ -29,9 +29,9 @@ export declare class ScallopBuilder {
|
|
|
29
29
|
/**
|
|
30
30
|
* Request the scallop API to initialize data.
|
|
31
31
|
*
|
|
32
|
-
* @param
|
|
32
|
+
* @param force - Whether to force initialization.
|
|
33
33
|
*/
|
|
34
|
-
init(
|
|
34
|
+
init(force?: boolean): Promise<void>;
|
|
35
35
|
/**
|
|
36
36
|
* Create a scallop txBlock instance that enhances transaction block.
|
|
37
37
|
*
|
|
@@ -264,23 +264,23 @@ export declare class ScallopClient {
|
|
|
264
264
|
/**
|
|
265
265
|
* stake obligaion.
|
|
266
266
|
*
|
|
267
|
-
* @param sign - Decide to directly sign the transaction or return the transaction block.
|
|
268
267
|
* @param obligaionId - The obligation account object.
|
|
269
268
|
* @param obligaionKeyId - The obligation key account object.
|
|
269
|
+
* @param sign - Decide to directly sign the transaction or return the transaction block.
|
|
270
270
|
* @param walletAddress - The wallet address of the owner.
|
|
271
271
|
* @return Transaction block response or transaction block
|
|
272
272
|
*/
|
|
273
|
-
stakeObligation<S extends boolean>(
|
|
273
|
+
stakeObligation<S extends boolean>(obligaionId: string, obligaionKeyId: string, sign?: S, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
|
|
274
274
|
/**
|
|
275
275
|
* unstake obligaion.
|
|
276
276
|
*
|
|
277
|
-
* @param sign - Decide to directly sign the transaction or return the transaction block.
|
|
278
277
|
* @param obligaionId - The obligation account object.
|
|
279
278
|
* @param obligaionKeyId - The obligation key account object.
|
|
279
|
+
* @param sign - Decide to directly sign the transaction or return the transaction block.
|
|
280
280
|
* @param walletAddress - The wallet address of the owner.
|
|
281
281
|
* @return Transaction block response or transaction block
|
|
282
282
|
*/
|
|
283
|
-
unstakeObligation<S extends boolean>(
|
|
283
|
+
unstakeObligation<S extends boolean>(obligaionId: string, obligaionKeyId: string, sign?: S, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
|
|
284
284
|
/**
|
|
285
285
|
* unstake market coin from the specific spool.
|
|
286
286
|
*
|
|
@@ -151,14 +151,14 @@ export declare class ScallopQuery {
|
|
|
151
151
|
ssui?: number | undefined;
|
|
152
152
|
susdc?: number | undefined;
|
|
153
153
|
susdt?: number | undefined;
|
|
154
|
+
safsui?: number | undefined;
|
|
155
|
+
shasui?: number | undefined;
|
|
156
|
+
svsui?: number | undefined;
|
|
154
157
|
seth?: number | undefined;
|
|
155
158
|
sbtc?: number | undefined;
|
|
156
159
|
sapt?: number | undefined;
|
|
157
160
|
ssol?: number | undefined;
|
|
158
161
|
scetus?: number | undefined;
|
|
159
|
-
safsui?: number | undefined;
|
|
160
|
-
shasui?: number | undefined;
|
|
161
|
-
svsui?: number | undefined;
|
|
162
162
|
}>;
|
|
163
163
|
/**
|
|
164
164
|
* Get market coin amount.
|
|
@@ -186,6 +186,9 @@ export declare class ScallopQuery {
|
|
|
186
186
|
ssui?: import("../types").Spool | undefined;
|
|
187
187
|
susdc?: import("../types").Spool | undefined;
|
|
188
188
|
susdt?: import("../types").Spool | undefined;
|
|
189
|
+
safsui?: import("../types").Spool | undefined;
|
|
190
|
+
shasui?: import("../types").Spool | undefined;
|
|
191
|
+
svsui?: import("../types").Spool | undefined;
|
|
189
192
|
}>;
|
|
190
193
|
/**
|
|
191
194
|
* Get spool data.
|
|
@@ -224,6 +227,9 @@ export declare class ScallopQuery {
|
|
|
224
227
|
ssui?: import("../types").StakePool | undefined;
|
|
225
228
|
susdc?: import("../types").StakePool | undefined;
|
|
226
229
|
susdt?: import("../types").StakePool | undefined;
|
|
230
|
+
safsui?: import("../types").StakePool | undefined;
|
|
231
|
+
shasui?: import("../types").StakePool | undefined;
|
|
232
|
+
svsui?: import("../types").StakePool | undefined;
|
|
227
233
|
}>;
|
|
228
234
|
/**
|
|
229
235
|
* Get stake pool (spool) data.
|
|
@@ -250,6 +256,9 @@ export declare class ScallopQuery {
|
|
|
250
256
|
ssui?: import("../types").StakeRewardPool | undefined;
|
|
251
257
|
susdc?: import("../types").StakeRewardPool | undefined;
|
|
252
258
|
susdt?: import("../types").StakeRewardPool | undefined;
|
|
259
|
+
safsui?: import("../types").StakeRewardPool | undefined;
|
|
260
|
+
shasui?: import("../types").StakeRewardPool | undefined;
|
|
261
|
+
svsui?: import("../types").StakeRewardPool | undefined;
|
|
253
262
|
}>;
|
|
254
263
|
/**
|
|
255
264
|
* Get stake reward pool data.
|
|
@@ -154,14 +154,14 @@ export declare const getMarketCoinAmounts: (query: ScallopQuery, marketCoinNames
|
|
|
154
154
|
ssui?: number | undefined;
|
|
155
155
|
susdc?: number | undefined;
|
|
156
156
|
susdt?: number | undefined;
|
|
157
|
+
safsui?: number | undefined;
|
|
158
|
+
shasui?: number | undefined;
|
|
159
|
+
svsui?: number | undefined;
|
|
157
160
|
seth?: number | undefined;
|
|
158
161
|
sbtc?: number | undefined;
|
|
159
162
|
sapt?: number | undefined;
|
|
160
163
|
ssol?: number | undefined;
|
|
161
164
|
scetus?: number | undefined;
|
|
162
|
-
safsui?: number | undefined;
|
|
163
|
-
shasui?: number | undefined;
|
|
164
|
-
svsui?: number | undefined;
|
|
165
165
|
}>;
|
|
166
166
|
/**
|
|
167
167
|
* Query owned market coin (sCoin) amount.
|
|
@@ -12,6 +12,9 @@ export declare const getSpools: (query: ScallopQuery, stakeMarketCoinNames?: Sup
|
|
|
12
12
|
ssui?: Spool | undefined;
|
|
13
13
|
susdc?: Spool | undefined;
|
|
14
14
|
susdt?: Spool | undefined;
|
|
15
|
+
safsui?: Spool | undefined;
|
|
16
|
+
shasui?: Spool | undefined;
|
|
17
|
+
svsui?: Spool | undefined;
|
|
15
18
|
}>;
|
|
16
19
|
/**
|
|
17
20
|
* Get spool data.
|
|
@@ -10,13 +10,13 @@ export type BorrowIncentiveIds = {
|
|
|
10
10
|
obligationAccessStore: string;
|
|
11
11
|
};
|
|
12
12
|
export type BorrowIncentiveNormalMethods = {
|
|
13
|
-
stakeObligation: (obligation: SuiAddressArg, obligaionKey: SuiAddressArg
|
|
14
|
-
unstakeObligation: (obligation: SuiAddressArg, obligaionKey: SuiAddressArg
|
|
13
|
+
stakeObligation: (obligation: SuiAddressArg, obligaionKey: SuiAddressArg) => void;
|
|
14
|
+
unstakeObligation: (obligation: SuiAddressArg, obligaionKey: SuiAddressArg) => void;
|
|
15
15
|
claimBorrowIncentive: (obligation: SuiAddressArg, obligaionKey: SuiAddressArg, coinName: SupportBorrowIncentiveCoins) => TransactionResult;
|
|
16
16
|
};
|
|
17
17
|
export type BorrowIncentiveQuickMethods = {
|
|
18
|
-
stakeObligationQuick(
|
|
19
|
-
unstakeObligationQuick(
|
|
18
|
+
stakeObligationQuick(obligation?: SuiAddressArg, obligationKey?: SuiAddressArg): Promise<void>;
|
|
19
|
+
unstakeObligationQuick(obligation?: SuiAddressArg, obligationKey?: SuiAddressArg): Promise<void>;
|
|
20
20
|
claimBorrowIncentiveQuick(coinName: SupportBorrowIncentiveCoins, obligation?: SuiAddressArg, obligationKey?: SuiAddressArg): Promise<TransactionResult>;
|
|
21
21
|
};
|
|
22
22
|
export type SuiTxBlockWithBorrowIncentiveNormalMethods = SuiKitTxBlock & BorrowIncentiveNormalMethods;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { MarketPool } from './core';
|
|
2
|
+
import type { Spool } from './spool';
|
|
2
3
|
import type { SupportPoolCoins, SupportCollateralCoins } from '../constant';
|
|
3
4
|
type OptionalKeys<T> = {
|
|
4
5
|
[K in keyof T]?: T[K];
|
|
5
6
|
};
|
|
6
7
|
export type Lendings = OptionalKeys<Record<SupportPoolCoins, Lending>>;
|
|
7
8
|
export type ObligationAccounts = OptionalKeys<Record<string, ObligationAccount>>;
|
|
8
|
-
export type Lending = Required<Pick<MarketPool, 'coinName' | 'symbol' | 'coinType' | 'marketCoinType' | 'coinDecimal' | 'coinPrice'>> & {
|
|
9
|
+
export type Lending = Required<Pick<MarketPool, 'coinName' | 'symbol' | 'coinType' | 'marketCoinType' | 'coinDecimal' | 'coinPrice' | 'conversionRate'> & Pick<Spool, 'marketCoinPrice'>> & {
|
|
9
10
|
supplyApr: number;
|
|
10
11
|
supplyApy: number;
|
|
11
12
|
rewardApr: number;
|
package/package.json
CHANGED
|
@@ -81,8 +81,10 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
|
|
|
81
81
|
obligationAccessStore: builder.address.get('core.obligationAccessStore'),
|
|
82
82
|
};
|
|
83
83
|
return {
|
|
84
|
-
stakeObligation: (obligationId, obligaionKey
|
|
85
|
-
|
|
84
|
+
stakeObligation: (obligationId, obligaionKey) => {
|
|
85
|
+
// NOTE: Pools without incentives also need to stake after change obligation,
|
|
86
|
+
// the default here use sui as reward coin.
|
|
87
|
+
const rewardCoinName = 'sui';
|
|
86
88
|
const rewardType = builder.utils.parseCoinType(rewardCoinName);
|
|
87
89
|
txBlock.moveCall(
|
|
88
90
|
`${borrowIncentiveIds.borrowIncentivePkg}::user::stake`,
|
|
@@ -97,8 +99,10 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
|
|
|
97
99
|
[rewardType]
|
|
98
100
|
);
|
|
99
101
|
},
|
|
100
|
-
unstakeObligation: (obligationId, obligaionKey
|
|
101
|
-
|
|
102
|
+
unstakeObligation: (obligationId, obligaionKey) => {
|
|
103
|
+
// NOTE: Pools without incentives also need to unstake to change obligation,
|
|
104
|
+
// the default here use sui as reward coin.
|
|
105
|
+
const rewardCoinName = 'sui';
|
|
102
106
|
const rewardType = builder.utils.parseCoinType(rewardCoinName);
|
|
103
107
|
txBlock.moveCall(
|
|
104
108
|
`${borrowIncentiveIds.borrowIncentivePkg}::user::unstake`,
|
|
@@ -145,7 +149,7 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
|
|
|
145
149
|
const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
|
|
146
150
|
({ builder, txBlock }) => {
|
|
147
151
|
return {
|
|
148
|
-
stakeObligationQuick: async (
|
|
152
|
+
stakeObligationQuick: async (obligation, obligationKey) => {
|
|
149
153
|
const {
|
|
150
154
|
obligationId: obligationArg,
|
|
151
155
|
obligationKey: obligationtKeyArg,
|
|
@@ -166,10 +170,10 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
|
|
|
166
170
|
);
|
|
167
171
|
|
|
168
172
|
if (!obligationLocked || unstakeObligationBeforeStake) {
|
|
169
|
-
txBlock.stakeObligation(obligationArg, obligationtKeyArg
|
|
173
|
+
txBlock.stakeObligation(obligationArg, obligationtKeyArg);
|
|
170
174
|
}
|
|
171
175
|
},
|
|
172
|
-
unstakeObligationQuick: async (
|
|
176
|
+
unstakeObligationQuick: async (obligation, obligationKey) => {
|
|
173
177
|
const {
|
|
174
178
|
obligationId: obligationArg,
|
|
175
179
|
obligationKey: obligationtKeyArg,
|
|
@@ -182,7 +186,7 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
|
|
|
182
186
|
);
|
|
183
187
|
|
|
184
188
|
if (obligationLocked) {
|
|
185
|
-
txBlock.unstakeObligation(obligationArg, obligationtKeyArg
|
|
189
|
+
txBlock.unstakeObligation(obligationArg, obligationtKeyArg);
|
|
186
190
|
}
|
|
187
191
|
},
|
|
188
192
|
claimBorrowIncentiveQuick: async (
|
|
@@ -21,7 +21,7 @@ import type {
|
|
|
21
21
|
* Check and get stake account id from transaction block.
|
|
22
22
|
*
|
|
23
23
|
* @description
|
|
24
|
-
* If the stake account id is provided,
|
|
24
|
+
* If the stake account id is provided, directly return it.
|
|
25
25
|
* Otherwise, automatically get all stake account id from the sender.
|
|
26
26
|
*
|
|
27
27
|
* @param builder - Scallop builder instance.
|
|
@@ -52,7 +52,7 @@ const requireStakeAccountIds = async (
|
|
|
52
52
|
* Check and get stake accounts information from transaction block.
|
|
53
53
|
*
|
|
54
54
|
* @description
|
|
55
|
-
* If the stake account id is provided,
|
|
55
|
+
* If the stake account id is provided, directly return its account.
|
|
56
56
|
* Otherwise, automatically get all stake account from the sender.
|
|
57
57
|
*
|
|
58
58
|
* @param builder - Scallop builder instance.
|
package/src/constants/common.ts
CHANGED
|
@@ -37,7 +37,14 @@ export const SUPPORT_COLLATERALS = [
|
|
|
37
37
|
'vsui',
|
|
38
38
|
] as const;
|
|
39
39
|
|
|
40
|
-
export const SUPPORT_SPOOLS = [
|
|
40
|
+
export const SUPPORT_SPOOLS = [
|
|
41
|
+
'ssui',
|
|
42
|
+
'susdc',
|
|
43
|
+
'susdt',
|
|
44
|
+
'safsui',
|
|
45
|
+
'shasui',
|
|
46
|
+
'svsui',
|
|
47
|
+
] as const;
|
|
41
48
|
|
|
42
49
|
export const SUPPORT_SPOOLS_REWARDS = ['sui'] as const;
|
|
43
50
|
|
package/src/constants/enum.ts
CHANGED
|
@@ -67,12 +67,18 @@ export const stakeMarketCoins: StakeMarketCoins = {
|
|
|
67
67
|
ssui: 'ssui',
|
|
68
68
|
susdc: 'susdc',
|
|
69
69
|
susdt: 'susdt',
|
|
70
|
+
safsui: 'safsui',
|
|
71
|
+
shasui: 'shasui',
|
|
72
|
+
svsui: 'svsui',
|
|
70
73
|
};
|
|
71
74
|
|
|
72
75
|
export const spoolRewardCoins: StakeRewardCoins = {
|
|
73
76
|
ssui: 'sui',
|
|
74
77
|
susdc: 'sui',
|
|
75
78
|
susdt: 'sui',
|
|
79
|
+
safsui: 'sui',
|
|
80
|
+
shasui: 'sui',
|
|
81
|
+
svsui: 'sui',
|
|
76
82
|
};
|
|
77
83
|
|
|
78
84
|
export const borrowIncentiveRewardCoins: BorrowIncentiveRewardCoins = {
|
|
@@ -199,6 +199,22 @@ const EMPTY_ADDRESSES: AddressesInterface = {
|
|
|
199
199
|
id: '',
|
|
200
200
|
rewardPoolId: '',
|
|
201
201
|
},
|
|
202
|
+
susdt: {
|
|
203
|
+
id: '',
|
|
204
|
+
rewardPoolId: '',
|
|
205
|
+
},
|
|
206
|
+
safsui: {
|
|
207
|
+
id: '',
|
|
208
|
+
rewardPoolId: '',
|
|
209
|
+
},
|
|
210
|
+
shasui: {
|
|
211
|
+
id: '',
|
|
212
|
+
rewardPoolId: '',
|
|
213
|
+
},
|
|
214
|
+
svsui: {
|
|
215
|
+
id: '',
|
|
216
|
+
rewardPoolId: '',
|
|
217
|
+
},
|
|
202
218
|
},
|
|
203
219
|
},
|
|
204
220
|
borrowIncentive: {
|
|
@@ -73,14 +73,14 @@ export class ScallopBuilder {
|
|
|
73
73
|
/**
|
|
74
74
|
* Request the scallop API to initialize data.
|
|
75
75
|
*
|
|
76
|
-
* @param
|
|
76
|
+
* @param force - Whether to force initialization.
|
|
77
77
|
*/
|
|
78
|
-
public async init(
|
|
79
|
-
if (
|
|
78
|
+
public async init(force: boolean = false) {
|
|
79
|
+
if (force || !this.address.getAddresses()) {
|
|
80
80
|
await this.address.read();
|
|
81
81
|
}
|
|
82
|
-
await this.query.init(
|
|
83
|
-
await this.utils.init(
|
|
82
|
+
await this.query.init(force);
|
|
83
|
+
await this.utils.init(force);
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
/**
|
|
@@ -485,11 +485,7 @@ export class ScallopClient {
|
|
|
485
485
|
SUPPORT_BORROW_INCENTIVE_POOLS as readonly SupportPoolCoins[]
|
|
486
486
|
).includes(poolCoinName);
|
|
487
487
|
if (sign && availableStake) {
|
|
488
|
-
await txBlock.unstakeObligationQuick(
|
|
489
|
-
poolCoinName as SupportBorrowIncentiveCoins,
|
|
490
|
-
obligationId,
|
|
491
|
-
obligationKey
|
|
492
|
-
);
|
|
488
|
+
await txBlock.unstakeObligationQuick(obligationId, obligationKey);
|
|
493
489
|
}
|
|
494
490
|
const coin = await txBlock.borrowQuick(
|
|
495
491
|
amount,
|
|
@@ -499,11 +495,7 @@ export class ScallopClient {
|
|
|
499
495
|
);
|
|
500
496
|
txBlock.transferObjects([coin], sender);
|
|
501
497
|
if (sign && availableStake) {
|
|
502
|
-
await txBlock.stakeObligationQuick(
|
|
503
|
-
poolCoinName as SupportBorrowIncentiveCoins,
|
|
504
|
-
obligationId,
|
|
505
|
-
obligationKey
|
|
506
|
-
);
|
|
498
|
+
await txBlock.stakeObligationQuick(obligationId, obligationKey);
|
|
507
499
|
}
|
|
508
500
|
|
|
509
501
|
if (sign) {
|
|
@@ -541,19 +533,11 @@ export class ScallopClient {
|
|
|
541
533
|
SUPPORT_BORROW_INCENTIVE_POOLS as readonly SupportPoolCoins[]
|
|
542
534
|
).includes(poolCoinName);
|
|
543
535
|
if (sign && availableStake) {
|
|
544
|
-
await txBlock.unstakeObligationQuick(
|
|
545
|
-
poolCoinName as SupportBorrowIncentiveCoins,
|
|
546
|
-
obligationId,
|
|
547
|
-
obligationKey
|
|
548
|
-
);
|
|
536
|
+
await txBlock.unstakeObligationQuick(obligationId, obligationKey);
|
|
549
537
|
}
|
|
550
538
|
await txBlock.repayQuick(amount, poolCoinName, obligationId);
|
|
551
539
|
if (sign && availableStake) {
|
|
552
|
-
await txBlock.stakeObligationQuick(
|
|
553
|
-
poolCoinName as SupportBorrowIncentiveCoins,
|
|
554
|
-
obligationId,
|
|
555
|
-
obligationKey
|
|
556
|
-
);
|
|
540
|
+
await txBlock.stakeObligationQuick(obligationId, obligationKey);
|
|
557
541
|
}
|
|
558
542
|
|
|
559
543
|
if (sign) {
|
|
@@ -860,14 +844,13 @@ export class ScallopClient {
|
|
|
860
844
|
/**
|
|
861
845
|
* stake obligaion.
|
|
862
846
|
*
|
|
863
|
-
* @param sign - Decide to directly sign the transaction or return the transaction block.
|
|
864
847
|
* @param obligaionId - The obligation account object.
|
|
865
848
|
* @param obligaionKeyId - The obligation key account object.
|
|
849
|
+
* @param sign - Decide to directly sign the transaction or return the transaction block.
|
|
866
850
|
* @param walletAddress - The wallet address of the owner.
|
|
867
851
|
* @return Transaction block response or transaction block
|
|
868
852
|
*/
|
|
869
853
|
public async stakeObligation<S extends boolean>(
|
|
870
|
-
coinName: SupportBorrowIncentiveCoins,
|
|
871
854
|
obligaionId: string,
|
|
872
855
|
obligaionKeyId: string,
|
|
873
856
|
sign: S = true as S,
|
|
@@ -877,7 +860,7 @@ export class ScallopClient {
|
|
|
877
860
|
const sender = walletAddress || this.walletAddress;
|
|
878
861
|
txBlock.setSender(sender);
|
|
879
862
|
|
|
880
|
-
await txBlock.stakeObligationQuick(
|
|
863
|
+
await txBlock.stakeObligationQuick(obligaionId, obligaionKeyId);
|
|
881
864
|
|
|
882
865
|
if (sign) {
|
|
883
866
|
return (await this.suiKit.signAndSendTxn(
|
|
@@ -891,14 +874,13 @@ export class ScallopClient {
|
|
|
891
874
|
/**
|
|
892
875
|
* unstake obligaion.
|
|
893
876
|
*
|
|
894
|
-
* @param sign - Decide to directly sign the transaction or return the transaction block.
|
|
895
877
|
* @param obligaionId - The obligation account object.
|
|
896
878
|
* @param obligaionKeyId - The obligation key account object.
|
|
879
|
+
* @param sign - Decide to directly sign the transaction or return the transaction block.
|
|
897
880
|
* @param walletAddress - The wallet address of the owner.
|
|
898
881
|
* @return Transaction block response or transaction block
|
|
899
882
|
*/
|
|
900
883
|
public async unstakeObligation<S extends boolean>(
|
|
901
|
-
coinName: SupportBorrowIncentiveCoins,
|
|
902
884
|
obligaionId: string,
|
|
903
885
|
obligaionKeyId: string,
|
|
904
886
|
sign: S = true as S,
|
|
@@ -908,7 +890,7 @@ export class ScallopClient {
|
|
|
908
890
|
const sender = walletAddress || this.walletAddress;
|
|
909
891
|
txBlock.setSender(sender);
|
|
910
892
|
|
|
911
|
-
await txBlock.unstakeObligationQuick(
|
|
893
|
+
await txBlock.unstakeObligationQuick(obligaionId, obligaionKeyId);
|
|
912
894
|
|
|
913
895
|
if (sign) {
|
|
914
896
|
return (await this.suiKit.signAndSendTxn(
|
|
@@ -200,6 +200,9 @@ export const getLending = async (
|
|
|
200
200
|
const suppliedCoin = suppliedAmount.shiftedBy(-1 * coinDecimal);
|
|
201
201
|
const suppliedValue = suppliedCoin.multipliedBy(coinPrice ?? 0);
|
|
202
202
|
|
|
203
|
+
const marketCoinPrice = BigNumber(coinPrice ?? 0).multipliedBy(
|
|
204
|
+
marketPool?.conversionRate ?? 1
|
|
205
|
+
);
|
|
203
206
|
const unstakedMarketAmount = BigNumber(marketCoinAmount);
|
|
204
207
|
const unstakedMarketCoin = unstakedMarketAmount.shiftedBy(-1 * coinDecimal);
|
|
205
208
|
|
|
@@ -221,6 +224,8 @@ export const getLending = async (
|
|
|
221
224
|
marketCoinType: query.utils.parseMarketCoinType(poolCoinName),
|
|
222
225
|
coinDecimal: coinDecimal,
|
|
223
226
|
coinPrice: coinPrice ?? 0,
|
|
227
|
+
conversionRate: marketPool?.conversionRate ?? 1,
|
|
228
|
+
marketCoinPrice: marketCoinPrice.toNumber(),
|
|
224
229
|
supplyApr: marketPool?.supplyApr ?? 0,
|
|
225
230
|
supplyApy: marketPool?.supplyApy ?? 0,
|
|
226
231
|
rewardApr: spool?.rewardApr ?? 0,
|
|
@@ -292,6 +292,9 @@ export const getStakeAccounts = async (
|
|
|
292
292
|
ssui: [],
|
|
293
293
|
susdc: [],
|
|
294
294
|
susdt: [],
|
|
295
|
+
safsui: [],
|
|
296
|
+
shasui: [],
|
|
297
|
+
svsui: [],
|
|
295
298
|
};
|
|
296
299
|
|
|
297
300
|
const stakeMarketCoinTypes: Record<SupportStakeMarketCoins, string> =
|
|
@@ -357,6 +360,39 @@ export const getStakeAccounts = async (
|
|
|
357
360
|
points,
|
|
358
361
|
totalPoints,
|
|
359
362
|
});
|
|
363
|
+
} else if (normalizeStructTag(type) === stakeMarketCoinTypes.safsui) {
|
|
364
|
+
stakeAccounts.safsui.push({
|
|
365
|
+
id,
|
|
366
|
+
type: normalizeStructTag(type),
|
|
367
|
+
stakePoolId,
|
|
368
|
+
stakeType: normalizeStructTag(stakeType),
|
|
369
|
+
staked,
|
|
370
|
+
index,
|
|
371
|
+
points,
|
|
372
|
+
totalPoints,
|
|
373
|
+
});
|
|
374
|
+
} else if (normalizeStructTag(type) === stakeMarketCoinTypes.shasui) {
|
|
375
|
+
stakeAccounts.shasui.push({
|
|
376
|
+
id,
|
|
377
|
+
type: normalizeStructTag(type),
|
|
378
|
+
stakePoolId,
|
|
379
|
+
stakeType: normalizeStructTag(stakeType),
|
|
380
|
+
staked,
|
|
381
|
+
index,
|
|
382
|
+
points,
|
|
383
|
+
totalPoints,
|
|
384
|
+
});
|
|
385
|
+
} else if (normalizeStructTag(type) === stakeMarketCoinTypes.svsui) {
|
|
386
|
+
stakeAccounts.svsui.push({
|
|
387
|
+
id,
|
|
388
|
+
type: normalizeStructTag(type),
|
|
389
|
+
stakePoolId,
|
|
390
|
+
stakeType: normalizeStructTag(stakeType),
|
|
391
|
+
staked,
|
|
392
|
+
index,
|
|
393
|
+
points,
|
|
394
|
+
totalPoints,
|
|
395
|
+
});
|
|
360
396
|
}
|
|
361
397
|
}
|
|
362
398
|
}
|
|
@@ -17,13 +17,11 @@ export type BorrowIncentiveIds = {
|
|
|
17
17
|
export type BorrowIncentiveNormalMethods = {
|
|
18
18
|
stakeObligation: (
|
|
19
19
|
obligation: SuiAddressArg,
|
|
20
|
-
obligaionKey: SuiAddressArg
|
|
21
|
-
coinName: SupportBorrowIncentiveCoins
|
|
20
|
+
obligaionKey: SuiAddressArg
|
|
22
21
|
) => void;
|
|
23
22
|
unstakeObligation: (
|
|
24
23
|
obligation: SuiAddressArg,
|
|
25
|
-
obligaionKey: SuiAddressArg
|
|
26
|
-
coinName: SupportBorrowIncentiveCoins
|
|
24
|
+
obligaionKey: SuiAddressArg
|
|
27
25
|
) => void;
|
|
28
26
|
claimBorrowIncentive: (
|
|
29
27
|
obligation: SuiAddressArg,
|
|
@@ -34,12 +32,10 @@ export type BorrowIncentiveNormalMethods = {
|
|
|
34
32
|
|
|
35
33
|
export type BorrowIncentiveQuickMethods = {
|
|
36
34
|
stakeObligationQuick(
|
|
37
|
-
coinName: SupportBorrowIncentiveCoins,
|
|
38
35
|
obligation?: SuiAddressArg,
|
|
39
36
|
obligationKey?: SuiAddressArg
|
|
40
37
|
): Promise<void>;
|
|
41
38
|
unstakeObligationQuick(
|
|
42
|
-
coinName: SupportBorrowIncentiveCoins,
|
|
43
39
|
obligation?: SuiAddressArg,
|
|
44
40
|
obligationKey?: SuiAddressArg
|
|
45
41
|
): Promise<void>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { MarketPool } from './core';
|
|
2
|
+
import type { Spool } from './spool';
|
|
2
3
|
import type { SupportPoolCoins, SupportCollateralCoins } from '../constant';
|
|
3
4
|
|
|
4
5
|
type OptionalKeys<T> = {
|
|
@@ -19,7 +20,9 @@ export type Lending = Required<
|
|
|
19
20
|
| 'marketCoinType'
|
|
20
21
|
| 'coinDecimal'
|
|
21
22
|
| 'coinPrice'
|
|
22
|
-
|
|
23
|
+
| 'conversionRate'
|
|
24
|
+
> &
|
|
25
|
+
Pick<Spool, 'marketCoinPrice'>
|
|
23
26
|
> & {
|
|
24
27
|
supplyApr: number;
|
|
25
28
|
supplyApy: number;
|