@scallop-io/sui-scallop-sdk 0.44.12 → 0.44.14
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.js +19 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -35
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopClient.d.ts +4 -4
- package/dist/types/builder/borrowIncentive.d.ts +4 -4
- package/package.json +1 -1
- package/src/builders/borrowIncentiveBuilder.ts +12 -8
- package/src/models/scallopClient.ts +8 -26
- package/src/queries/coreQuery.ts +1 -1
- package/src/types/builder/borrowIncentive.ts +2 -6
|
@@ -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
|
*
|
|
@@ -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;
|
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 (
|
|
@@ -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(
|
package/src/queries/coreQuery.ts
CHANGED
|
@@ -154,7 +154,7 @@ export const queryMarket = async (
|
|
|
154
154
|
const parsedMarketCollateralData = parseOriginMarketCollateralData({
|
|
155
155
|
type: collateral.type,
|
|
156
156
|
collateralFactor: collateral.collateralFactor,
|
|
157
|
-
liquidationFactor: collateral.
|
|
157
|
+
liquidationFactor: collateral.liquidationFactor,
|
|
158
158
|
liquidationDiscount: collateral.liquidationDiscount,
|
|
159
159
|
liquidationPanelty: collateral.liquidationPanelty,
|
|
160
160
|
liquidationReserveFactor: collateral.liquidationReserveFactor,
|
|
@@ -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>;
|