@scallop-io/sui-scallop-sdk 0.42.8 → 0.44.1
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 +2 -2
- package/dist/index.js +20 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -6
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopBuilder.d.ts +4 -60
- package/dist/models/scallopClient.d.ts +10 -10
- package/dist/models/scallopQuery.d.ts +10 -0
- package/dist/models/scallopUtils.d.ts +4 -1
- package/dist/queries/coreQuery.d.ts +10 -1
- package/dist/queries/portfolioQuery.d.ts +2 -0
- package/dist/types/builder/core.d.ts +18 -18
- package/dist/types/builder/index.d.ts +0 -2
- package/dist/types/builder/spool.d.ts +8 -9
- package/package.json +24 -18
- package/src/builders/coreBuilder.ts +7 -7
- package/src/builders/spoolBuilder.ts +4 -4
- package/src/constants/common.ts +4 -0
- package/src/constants/enum.ts +10 -0
- package/src/models/scallopClient.ts +20 -20
- package/src/models/scallopUtils.ts +2 -2
- package/src/queries/coreQuery.ts +2 -1
- package/src/types/builder/core.ts +34 -29
- package/src/types/builder/index.ts +0 -2
- package/src/types/builder/spool.ts +15 -17
|
@@ -49,36 +49,8 @@ export declare class ScallopBuilder {
|
|
|
49
49
|
* @return Take coin and left coin.
|
|
50
50
|
*/
|
|
51
51
|
selectCoin(txBlock: ScallopTxBlock | SuiKitTxBlock, assetCoinName: SupportAssetCoins, amount: number, sender: string): Promise<{
|
|
52
|
-
takeCoin:
|
|
53
|
-
|
|
54
|
-
index: number;
|
|
55
|
-
type?: "object" | "pure" | undefined;
|
|
56
|
-
value?: any;
|
|
57
|
-
} | {
|
|
58
|
-
kind: "GasCoin";
|
|
59
|
-
} | {
|
|
60
|
-
kind: "Result";
|
|
61
|
-
index: number;
|
|
62
|
-
} | {
|
|
63
|
-
kind: "NestedResult";
|
|
64
|
-
index: number;
|
|
65
|
-
resultIndex: number;
|
|
66
|
-
};
|
|
67
|
-
leftCoin: {
|
|
68
|
-
kind: "Input";
|
|
69
|
-
index: number;
|
|
70
|
-
type?: "object" | "pure" | undefined;
|
|
71
|
-
value?: any;
|
|
72
|
-
} | {
|
|
73
|
-
kind: "GasCoin";
|
|
74
|
-
} | {
|
|
75
|
-
kind: "Result";
|
|
76
|
-
index: number;
|
|
77
|
-
} | {
|
|
78
|
-
kind: "NestedResult";
|
|
79
|
-
index: number;
|
|
80
|
-
resultIndex: number;
|
|
81
|
-
};
|
|
52
|
+
takeCoin: import("@scallop-io/sui-kit").TransactionObjectArgument;
|
|
53
|
+
leftCoin: import("@scallop-io/sui-kit").TransactionObjectArgument;
|
|
82
54
|
}>;
|
|
83
55
|
/**
|
|
84
56
|
* Specifying the sender's amount of market coins to get coins args from transaction result.
|
|
@@ -90,36 +62,8 @@ export declare class ScallopBuilder {
|
|
|
90
62
|
* @return Take coin and left coin.
|
|
91
63
|
*/
|
|
92
64
|
selectMarketCoin(txBlock: ScallopTxBlock | SuiKitTxBlock, marketCoinName: SupportMarketCoins, amount: number, sender: string): Promise<{
|
|
93
|
-
takeCoin:
|
|
94
|
-
|
|
95
|
-
index: number;
|
|
96
|
-
type?: "object" | "pure" | undefined;
|
|
97
|
-
value?: any;
|
|
98
|
-
} | {
|
|
99
|
-
kind: "GasCoin";
|
|
100
|
-
} | {
|
|
101
|
-
kind: "Result";
|
|
102
|
-
index: number;
|
|
103
|
-
} | {
|
|
104
|
-
kind: "NestedResult";
|
|
105
|
-
index: number;
|
|
106
|
-
resultIndex: number;
|
|
107
|
-
};
|
|
108
|
-
leftCoin: {
|
|
109
|
-
kind: "Input";
|
|
110
|
-
index: number;
|
|
111
|
-
type?: "object" | "pure" | undefined;
|
|
112
|
-
value?: any;
|
|
113
|
-
} | {
|
|
114
|
-
kind: "GasCoin";
|
|
115
|
-
} | {
|
|
116
|
-
kind: "Result";
|
|
117
|
-
index: number;
|
|
118
|
-
} | {
|
|
119
|
-
kind: "NestedResult";
|
|
120
|
-
index: number;
|
|
121
|
-
resultIndex: number;
|
|
122
|
-
};
|
|
65
|
+
takeCoin: import("@scallop-io/sui-kit").TransactionObjectArgument;
|
|
66
|
+
leftCoin: import("@scallop-io/sui-kit").TransactionObjectArgument;
|
|
123
67
|
}>;
|
|
124
68
|
/**
|
|
125
69
|
* Execute Scallop txBlock using the `signAndSendTxn` methods in suikit.
|
|
@@ -4,8 +4,8 @@ import { ScallopUtils } from './scallopUtils';
|
|
|
4
4
|
import { ScallopBuilder } from './scallopBuilder';
|
|
5
5
|
import { ScallopQuery } from './scallopQuery';
|
|
6
6
|
import type { SuiTransactionBlockResponse } from '@mysten/sui.js/client';
|
|
7
|
-
import type {
|
|
8
|
-
import type {
|
|
7
|
+
import type { TransactionObjectArgument } from '@mysten/sui.js/transactions';
|
|
8
|
+
import type { SuiObjectArg } from '@scallop-io/sui-kit';
|
|
9
9
|
import type { ScallopClientFnReturnType, ScallopInstanceParams, ScallopClientParams, SupportPoolCoins, SupportCollateralCoins, SupportAssetCoins, SupportStakeCoins, SupportStakeMarketCoins, ScallopTxBlock } from '../types';
|
|
10
10
|
/**
|
|
11
11
|
* @description
|
|
@@ -123,7 +123,7 @@ export declare class ScallopClient {
|
|
|
123
123
|
* @return Transaction block response or transaction block.
|
|
124
124
|
*/
|
|
125
125
|
depositCollateral(collateralCoinName: SupportCollateralCoins, amount: number): Promise<SuiTransactionBlockResponse>;
|
|
126
|
-
depositCollateral<S extends boolean>(collateralCoinName: SupportCollateralCoins, amount: number, sign?: S, obligationId?:
|
|
126
|
+
depositCollateral<S extends boolean>(collateralCoinName: SupportCollateralCoins, amount: number, sign?: S, obligationId?: string, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
|
|
127
127
|
/**
|
|
128
128
|
* Withdraw collateral from the specific pool.
|
|
129
129
|
*
|
|
@@ -158,7 +158,7 @@ export declare class ScallopClient {
|
|
|
158
158
|
* @return Transaction block response or transaction block.
|
|
159
159
|
*/
|
|
160
160
|
depositAndStake(stakeCoinName: SupportStakeCoins, amount: number): Promise<SuiTransactionBlockResponse>;
|
|
161
|
-
depositAndStake<S extends boolean>(stakeCoinName: SupportStakeCoins, amount: number, sign?: S, stakeAccountId?:
|
|
161
|
+
depositAndStake<S extends boolean>(stakeCoinName: SupportStakeCoins, amount: number, sign?: S, stakeAccountId?: string, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
|
|
162
162
|
/**
|
|
163
163
|
* Withdraw asset from the specific pool, must return market coin.
|
|
164
164
|
*
|
|
@@ -202,8 +202,8 @@ export declare class ScallopClient {
|
|
|
202
202
|
* @param sign - Decide to directly sign the transaction or return the transaction block.
|
|
203
203
|
* @return Transaction block response or transaction block.
|
|
204
204
|
*/
|
|
205
|
-
flashLoan(poolCoinName: SupportPoolCoins, amount: number, callback: (txBlock: ScallopTxBlock, coin:
|
|
206
|
-
flashLoan<S extends boolean>(poolCoinName: SupportPoolCoins, amount: number, callback: (txBlock: ScallopTxBlock, coin:
|
|
205
|
+
flashLoan(poolCoinName: SupportPoolCoins, amount: number, callback: (txBlock: ScallopTxBlock, coin: TransactionObjectArgument | string) => SuiObjectArg): Promise<SuiTransactionBlockResponse>;
|
|
206
|
+
flashLoan<S extends boolean>(poolCoinName: SupportPoolCoins, amount: number, callback: (txBlock: ScallopTxBlock, coin: TransactionObjectArgument | string) => SuiObjectArg, sign?: S, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
|
|
207
207
|
/**
|
|
208
208
|
* Create stake account.
|
|
209
209
|
*
|
|
@@ -224,7 +224,7 @@ export declare class ScallopClient {
|
|
|
224
224
|
* @return Transaction block response or transaction block.
|
|
225
225
|
*/
|
|
226
226
|
stake(stakeMarketCoinName: SupportStakeMarketCoins, amount: number): Promise<SuiTransactionBlockResponse>;
|
|
227
|
-
stake<S extends boolean>(stakeMarketCoinName: SupportStakeMarketCoins, amount: number, sign?: S, stakeAccountId?:
|
|
227
|
+
stake<S extends boolean>(stakeMarketCoinName: SupportStakeMarketCoins, amount: number, sign?: S, stakeAccountId?: string, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
|
|
228
228
|
/**
|
|
229
229
|
* Unstake market coin from the specific spool.
|
|
230
230
|
*
|
|
@@ -236,7 +236,7 @@ export declare class ScallopClient {
|
|
|
236
236
|
* @return Transaction block response or transaction block.
|
|
237
237
|
*/
|
|
238
238
|
unstake(stakeMarketCoinName: SupportStakeMarketCoins, amount: number): Promise<SuiTransactionBlockResponse>;
|
|
239
|
-
unstake<S extends boolean>(stakeMarketCoinName: SupportStakeMarketCoins, amount: number, sign?: S, stakeAccountId?:
|
|
239
|
+
unstake<S extends boolean>(stakeMarketCoinName: SupportStakeMarketCoins, amount: number, sign?: S, stakeAccountId?: string, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
|
|
240
240
|
/**
|
|
241
241
|
* Unstake market coin from the specific spool and withdraw asset from the corresponding pool.
|
|
242
242
|
*
|
|
@@ -248,7 +248,7 @@ export declare class ScallopClient {
|
|
|
248
248
|
* @return Transaction block response or transaction block.
|
|
249
249
|
*/
|
|
250
250
|
unstakeAndWithdraw(stakeMarketCoinName: SupportStakeMarketCoins, amount: number): Promise<SuiTransactionBlockResponse>;
|
|
251
|
-
unstakeAndWithdraw<S extends boolean>(stakeMarketCoinName: SupportStakeMarketCoins, amount: number, sign?: S, stakeAccountId?:
|
|
251
|
+
unstakeAndWithdraw<S extends boolean>(stakeMarketCoinName: SupportStakeMarketCoins, amount: number, sign?: S, stakeAccountId?: string, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
|
|
252
252
|
/**
|
|
253
253
|
* Claim reward coin from the specific spool.
|
|
254
254
|
*
|
|
@@ -260,7 +260,7 @@ export declare class ScallopClient {
|
|
|
260
260
|
* @return Transaction block response or transaction block.
|
|
261
261
|
*/
|
|
262
262
|
claim(stakeMarketCoinName: SupportStakeMarketCoins): Promise<SuiTransactionBlockResponse>;
|
|
263
|
-
claim<S extends boolean>(stakeMarketCoinName: SupportStakeMarketCoins, sign?: S, stakeAccountId?:
|
|
263
|
+
claim<S extends boolean>(stakeMarketCoinName: SupportStakeMarketCoins, sign?: S, stakeAccountId?: string, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
|
|
264
264
|
/**
|
|
265
265
|
* Mint and get test coin.
|
|
266
266
|
*
|
|
@@ -51,6 +51,8 @@ export declare class ScallopQuery {
|
|
|
51
51
|
apt?: import("../types").MarketPool | undefined;
|
|
52
52
|
sol?: import("../types").MarketPool | undefined;
|
|
53
53
|
cetus?: import("../types").MarketPool | undefined;
|
|
54
|
+
afsui?: import("../types").MarketPool | undefined;
|
|
55
|
+
hasui?: import("../types").MarketPool | undefined;
|
|
54
56
|
}>;
|
|
55
57
|
/**
|
|
56
58
|
* Get market pool
|
|
@@ -78,6 +80,8 @@ export declare class ScallopQuery {
|
|
|
78
80
|
apt?: import("../types").MarketCollateral | undefined;
|
|
79
81
|
sol?: import("../types").MarketCollateral | undefined;
|
|
80
82
|
cetus?: import("../types").MarketCollateral | undefined;
|
|
83
|
+
afsui?: import("../types").MarketCollateral | undefined;
|
|
84
|
+
hasui?: import("../types").MarketCollateral | undefined;
|
|
81
85
|
}>;
|
|
82
86
|
/**
|
|
83
87
|
* Get market collateral
|
|
@@ -116,6 +120,8 @@ export declare class ScallopQuery {
|
|
|
116
120
|
apt?: number | undefined;
|
|
117
121
|
sol?: number | undefined;
|
|
118
122
|
cetus?: number | undefined;
|
|
123
|
+
afsui?: number | undefined;
|
|
124
|
+
hasui?: number | undefined;
|
|
119
125
|
}>;
|
|
120
126
|
/**
|
|
121
127
|
* Get asset coin amount.
|
|
@@ -141,6 +147,8 @@ export declare class ScallopQuery {
|
|
|
141
147
|
sapt?: number | undefined;
|
|
142
148
|
ssol?: number | undefined;
|
|
143
149
|
scetus?: number | undefined;
|
|
150
|
+
safsui?: number | undefined;
|
|
151
|
+
shasui?: number | undefined;
|
|
144
152
|
}>;
|
|
145
153
|
/**
|
|
146
154
|
* Get market coin amount.
|
|
@@ -258,6 +266,8 @@ export declare class ScallopQuery {
|
|
|
258
266
|
apt?: import("../types").Lending | undefined;
|
|
259
267
|
sol?: import("../types").Lending | undefined;
|
|
260
268
|
cetus?: import("../types").Lending | undefined;
|
|
269
|
+
afsui?: import("../types").Lending | undefined;
|
|
270
|
+
hasui?: import("../types").Lending | undefined;
|
|
261
271
|
}>;
|
|
262
272
|
/**
|
|
263
273
|
* Get user lending and spool information for specific pool.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SuiAddressArg } from '@scallop-io/sui-kit';
|
|
1
2
|
import type { ScallopUtilsParams, ScallopInstanceParams, SupportCoins, SupportAssetCoins, SupportMarketCoins, SupportStakeMarketCoins, CoinWrappedType } from '../types';
|
|
2
3
|
/**
|
|
3
4
|
* @description
|
|
@@ -117,7 +118,7 @@ export declare class ScallopUtils {
|
|
|
117
118
|
* @param obligationId - The obligation id.
|
|
118
119
|
* @return Asset coin Names.
|
|
119
120
|
*/
|
|
120
|
-
getObligationCoinNames(obligationId:
|
|
121
|
+
getObligationCoinNames(obligationId: SuiAddressArg): Promise<SupportAssetCoins[]>;
|
|
121
122
|
/**
|
|
122
123
|
* Get asset coin price.
|
|
123
124
|
*
|
|
@@ -139,6 +140,8 @@ export declare class ScallopUtils {
|
|
|
139
140
|
apt?: number | undefined;
|
|
140
141
|
sol?: number | undefined;
|
|
141
142
|
cetus?: number | undefined;
|
|
143
|
+
afsui?: number | undefined;
|
|
144
|
+
hasui?: number | undefined;
|
|
142
145
|
}>;
|
|
143
146
|
/**
|
|
144
147
|
* Convert apr to apy.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SuiObjectData } from '@mysten/sui.js/client';
|
|
2
|
+
import type { SuiAddressArg } from '@scallop-io/sui-kit';
|
|
2
3
|
import type { ScallopQuery } from '../models';
|
|
3
4
|
import { Market, MarketPool, MarketCollateral, SupportAssetCoins, SupportPoolCoins, SupportCollateralCoins, ObligationQueryInterface, Obligation, SupportMarketCoins } from '../types';
|
|
4
5
|
/**
|
|
@@ -32,6 +33,8 @@ export declare const getMarketPools: (query: ScallopQuery, poolCoinNames?: Suppo
|
|
|
32
33
|
apt?: MarketPool | undefined;
|
|
33
34
|
sol?: MarketPool | undefined;
|
|
34
35
|
cetus?: MarketPool | undefined;
|
|
36
|
+
afsui?: MarketPool | undefined;
|
|
37
|
+
hasui?: MarketPool | undefined;
|
|
35
38
|
}>;
|
|
36
39
|
/**
|
|
37
40
|
* Get market pool data.
|
|
@@ -63,6 +66,8 @@ export declare const getMarketCollaterals: (query: ScallopQuery, collateralCoinN
|
|
|
63
66
|
apt?: MarketCollateral | undefined;
|
|
64
67
|
sol?: MarketCollateral | undefined;
|
|
65
68
|
cetus?: MarketCollateral | undefined;
|
|
69
|
+
afsui?: MarketCollateral | undefined;
|
|
70
|
+
hasui?: MarketCollateral | undefined;
|
|
66
71
|
}>;
|
|
67
72
|
/**
|
|
68
73
|
* Get market collateral data.
|
|
@@ -92,7 +97,7 @@ export declare const getObligations: (query: ScallopQuery, ownerAddress?: string
|
|
|
92
97
|
* @param obligationId - The obligation id.
|
|
93
98
|
* @return Obligation data.
|
|
94
99
|
*/
|
|
95
|
-
export declare const queryObligation: (query: ScallopQuery, obligationId:
|
|
100
|
+
export declare const queryObligation: (query: ScallopQuery, obligationId: SuiAddressArg) => Promise<ObligationQueryInterface>;
|
|
96
101
|
/**
|
|
97
102
|
* Query all owned coin amount.
|
|
98
103
|
*
|
|
@@ -110,6 +115,8 @@ export declare const getCoinAmounts: (query: ScallopQuery, assetCoinNames?: Supp
|
|
|
110
115
|
apt?: number | undefined;
|
|
111
116
|
sol?: number | undefined;
|
|
112
117
|
cetus?: number | undefined;
|
|
118
|
+
afsui?: number | undefined;
|
|
119
|
+
hasui?: number | undefined;
|
|
113
120
|
}>;
|
|
114
121
|
/**
|
|
115
122
|
* Query owned coin amount.
|
|
@@ -137,6 +144,8 @@ export declare const getMarketCoinAmounts: (query: ScallopQuery, marketCoinNames
|
|
|
137
144
|
sapt?: number | undefined;
|
|
138
145
|
ssol?: number | undefined;
|
|
139
146
|
scetus?: number | undefined;
|
|
147
|
+
safsui?: number | undefined;
|
|
148
|
+
shasui?: number | undefined;
|
|
140
149
|
}>;
|
|
141
150
|
/**
|
|
142
151
|
* Query owned market coin (sCoin) amount.
|
|
@@ -17,6 +17,8 @@ export declare const getLendings: (query: ScallopQuery, poolCoinNames?: SupportP
|
|
|
17
17
|
apt?: Lending | undefined;
|
|
18
18
|
sol?: Lending | undefined;
|
|
19
19
|
cetus?: Lending | undefined;
|
|
20
|
+
afsui?: Lending | undefined;
|
|
21
|
+
hasui?: Lending | undefined;
|
|
20
22
|
}>;
|
|
21
23
|
/**
|
|
22
24
|
* Get user lending infomation for specific pool.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { SuiTxBlock as SuiKitTxBlock, SuiTxArg } from '@scallop-io/sui-kit';
|
|
1
|
+
import type { SuiTxBlock as SuiKitTxBlock, SuiAddressArg, SuiObjectArg, SuiTxArg } from '@scallop-io/sui-kit';
|
|
2
|
+
import type { TransactionResult } from '@mysten/sui.js/transactions';
|
|
2
3
|
import type { ScallopBuilder } from '../../models';
|
|
3
4
|
import type { SupportCollateralCoins, SupportPoolCoins, SupportAssetCoins } from '../constant';
|
|
4
|
-
import type { TransactionResult } from './index';
|
|
5
5
|
export type CoreIds = {
|
|
6
6
|
protocolPkg: string;
|
|
7
7
|
market: string;
|
|
@@ -11,27 +11,27 @@ export type CoreIds = {
|
|
|
11
11
|
};
|
|
12
12
|
export type CoreNormalMethods = {
|
|
13
13
|
openObligation: () => TransactionResult;
|
|
14
|
-
returnObligation: (obligation:
|
|
14
|
+
returnObligation: (obligation: SuiAddressArg, obligationHotPotato: SuiObjectArg) => void;
|
|
15
15
|
openObligationEntry: () => void;
|
|
16
|
-
addCollateral: (obligation:
|
|
17
|
-
takeCollateral: (obligation:
|
|
18
|
-
deposit: (coin:
|
|
19
|
-
depositEntry: (coin:
|
|
20
|
-
withdraw: (marketCoin:
|
|
21
|
-
withdrawEntry: (marketCoin:
|
|
22
|
-
borrow: (obligation:
|
|
23
|
-
borrowEntry: (obligation:
|
|
24
|
-
repay: (obligation:
|
|
25
|
-
borrowFlashLoan: (amount:
|
|
26
|
-
repayFlashLoan: (coin:
|
|
16
|
+
addCollateral: (obligation: SuiAddressArg, coin: SuiObjectArg, collateralCoinName: SupportCollateralCoins) => void;
|
|
17
|
+
takeCollateral: (obligation: SuiAddressArg, obligationKey: SuiAddressArg, amount: SuiTxArg, collateralCoinName: SupportCollateralCoins) => TransactionResult;
|
|
18
|
+
deposit: (coin: SuiObjectArg, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
19
|
+
depositEntry: (coin: SuiObjectArg, poolCoinName: SupportPoolCoins) => void;
|
|
20
|
+
withdraw: (marketCoin: SuiObjectArg, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
21
|
+
withdrawEntry: (marketCoin: SuiObjectArg, poolCoinName: SupportPoolCoins) => void;
|
|
22
|
+
borrow: (obligation: SuiAddressArg, obligationKey: SuiAddressArg, amount: SuiTxArg, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
23
|
+
borrowEntry: (obligation: SuiAddressArg, obligationKey: SuiAddressArg, amount: SuiTxArg, poolCoinName: SupportPoolCoins) => void;
|
|
24
|
+
repay: (obligation: SuiAddressArg, coin: SuiObjectArg, poolCoinName: SupportPoolCoins) => void;
|
|
25
|
+
borrowFlashLoan: (amount: SuiTxArg, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
26
|
+
repayFlashLoan: (coin: SuiObjectArg, loan: SuiAddressArg, poolCoinName: SupportPoolCoins) => void;
|
|
27
27
|
};
|
|
28
28
|
export type CoreQuickMethods = {
|
|
29
|
-
addCollateralQuick: (amount: number, collateralCoinName: SupportCollateralCoins, obligationId?:
|
|
30
|
-
takeCollateralQuick: (amount: number, collateralCoinName: SupportCollateralCoins, obligationId?:
|
|
31
|
-
borrowQuick: (amount: number, poolCoinName: SupportPoolCoins, obligationId?:
|
|
29
|
+
addCollateralQuick: (amount: number, collateralCoinName: SupportCollateralCoins, obligationId?: SuiAddressArg) => Promise<void>;
|
|
30
|
+
takeCollateralQuick: (amount: number, collateralCoinName: SupportCollateralCoins, obligationId?: SuiAddressArg, obligationKey?: SuiAddressArg) => Promise<TransactionResult>;
|
|
31
|
+
borrowQuick: (amount: number, poolCoinName: SupportPoolCoins, obligationId?: SuiAddressArg, obligationKey?: SuiAddressArg) => Promise<TransactionResult>;
|
|
32
32
|
depositQuick: (amount: number, poolCoinName: SupportPoolCoins) => Promise<TransactionResult>;
|
|
33
33
|
withdrawQuick: (amount: number, poolCoinName: SupportPoolCoins) => Promise<TransactionResult>;
|
|
34
|
-
repayQuick: (amount: number, poolCoinName: SupportPoolCoins, obligationId?:
|
|
34
|
+
repayQuick: (amount: number, poolCoinName: SupportPoolCoins, obligationId?: SuiAddressArg) => Promise<void>;
|
|
35
35
|
updateAssetPricesQuick: (assetCoinNames?: SupportAssetCoins[]) => Promise<void>;
|
|
36
36
|
};
|
|
37
37
|
export type SuiTxBlockWithCoreNormalMethods = SuiKitTxBlock & CoreNormalMethods;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import type { TransactionArgument } from '@mysten/sui.js/transactions';
|
|
2
1
|
import type { CoreTxBlock } from './core';
|
|
3
2
|
import type { SpoolTxBlock } from './spool';
|
|
4
3
|
export type * from './core';
|
|
5
4
|
export type * from './spool';
|
|
6
5
|
export type ScallopTxBlock = CoreTxBlock & SpoolTxBlock;
|
|
7
|
-
export type TransactionResult = TransactionArgument & TransactionArgument[];
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import type { SuiTxBlock as SuiKitTxBlock, SuiTxArg } from '@scallop-io/sui-kit';
|
|
1
|
+
import type { SuiTxBlock as SuiKitTxBlock, SuiAddressArg, SuiObjectArg, SuiTxArg } from '@scallop-io/sui-kit';
|
|
2
|
+
import type { TransactionResult } from '@mysten/sui.js/transactions';
|
|
2
3
|
import type { ScallopBuilder } from '../../models';
|
|
3
4
|
import type { SupportStakeMarketCoins } from '../constant';
|
|
4
|
-
import type { TransactionResult } from './index';
|
|
5
5
|
export type SpoolIds = {
|
|
6
6
|
spoolPkg: string;
|
|
7
7
|
};
|
|
8
8
|
export type SpoolNormalMethods = {
|
|
9
9
|
createStakeAccount: (stakeMarketCoinName: SupportStakeMarketCoins) => TransactionResult;
|
|
10
|
-
stake: (stakeAccount:
|
|
11
|
-
unstake: (stakeAccount:
|
|
12
|
-
claim: (stakeAccount:
|
|
10
|
+
stake: (stakeAccount: SuiAddressArg, coin: SuiObjectArg, stakeMarketCoinName: SupportStakeMarketCoins) => void;
|
|
11
|
+
unstake: (stakeAccount: SuiAddressArg, amount: SuiTxArg, stakeMarketCoinName: SupportStakeMarketCoins) => TransactionResult;
|
|
12
|
+
claim: (stakeAccount: SuiAddressArg, stakeMarketCoinName: SupportStakeMarketCoins) => TransactionResult;
|
|
13
13
|
};
|
|
14
14
|
export type SpoolQuickMethods = {
|
|
15
|
-
stakeQuick(amountOrMarketCoin: number, stakeMarketCoinName: SupportStakeMarketCoins, stakeAccountId?:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
claimQuick(stakeMarketCoinName: SupportStakeMarketCoins, stakeAccountId?: SuiTxArg): Promise<TransactionResult>;
|
|
15
|
+
stakeQuick(amountOrMarketCoin: SuiObjectArg | number, stakeMarketCoinName: SupportStakeMarketCoins, stakeAccountId?: SuiAddressArg): Promise<void>;
|
|
16
|
+
unstakeQuick(amount: number, stakeMarketCoinName: SupportStakeMarketCoins, stakeAccountId?: SuiAddressArg): Promise<TransactionResult[]>;
|
|
17
|
+
claimQuick(stakeMarketCoinName: SupportStakeMarketCoins, stakeAccountId?: SuiAddressArg): Promise<TransactionResult[]>;
|
|
19
18
|
};
|
|
20
19
|
export type SuiTxBlockWithSpoolNormalMethods = SuiKitTxBlock & SpoolNormalMethods;
|
|
21
20
|
export type SpoolTxBlock = SuiTxBlockWithSpoolNormalMethods & SpoolQuickMethods;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scallop-io/sui-scallop-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.44.1",
|
|
4
4
|
"description": "Typescript sdk for interacting with Scallop contract on SUI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sui",
|
|
@@ -38,37 +38,43 @@
|
|
|
38
38
|
"src"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@mysten/
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
-
"@
|
|
41
|
+
"@mysten/bcs": "^0.8.1",
|
|
42
|
+
"@mysten/sui.js": "^0.44.0",
|
|
43
|
+
"@noble/curves": "^1.2.0",
|
|
44
|
+
"@noble/hashes": "^1.3.2",
|
|
45
|
+
"@pythnetwork/price-service-client": "^1.8.1",
|
|
46
|
+
"@pythnetwork/pyth-sui-js": "^1.2.3",
|
|
47
|
+
"@scallop-io/sui-kit": "^0.44.0",
|
|
48
|
+
"@scure/bip39": "^1.2.1",
|
|
45
49
|
"axios": "^1.5.1",
|
|
46
|
-
"bignumber.js": "^9.1.2"
|
|
50
|
+
"bignumber.js": "^9.1.2",
|
|
51
|
+
"superstruct": "^1.0.3",
|
|
52
|
+
"tweetnacl": "^1.0.3"
|
|
47
53
|
},
|
|
48
54
|
"devDependencies": {
|
|
49
|
-
"@commitlint/cli": "^
|
|
50
|
-
"@commitlint/config-conventional": "^
|
|
51
|
-
"@commitlint/prompt-cli": "^
|
|
52
|
-
"@types/node": "^20.8.
|
|
53
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
54
|
-
"@typescript-eslint/parser": "^6.
|
|
55
|
+
"@commitlint/cli": "^18.0.0",
|
|
56
|
+
"@commitlint/config-conventional": "^18.0.0",
|
|
57
|
+
"@commitlint/prompt-cli": "^18.0.0",
|
|
58
|
+
"@types/node": "^20.8.7",
|
|
59
|
+
"@typescript-eslint/eslint-plugin": "^6.8.0",
|
|
60
|
+
"@typescript-eslint/parser": "^6.8.0",
|
|
55
61
|
"dotenv": "^16.3.1",
|
|
56
|
-
"eslint": "^8.
|
|
62
|
+
"eslint": "^8.52.0",
|
|
57
63
|
"eslint-config-prettier": "^9.0.0",
|
|
58
|
-
"eslint-plugin-prettier": "^5.0.
|
|
64
|
+
"eslint-plugin-prettier": "^5.0.1",
|
|
59
65
|
"husky": "^8.0.3",
|
|
60
|
-
"lint-staged": "^
|
|
66
|
+
"lint-staged": "^15.0.2",
|
|
61
67
|
"prettier": "^3.0.3",
|
|
62
68
|
"standard-version": "^9.5.0",
|
|
63
69
|
"tsconfig-paths": "^4.2.0",
|
|
64
70
|
"tsup": "^7.2.0",
|
|
65
|
-
"typedoc": "^0.25.
|
|
71
|
+
"typedoc": "^0.25.2",
|
|
66
72
|
"typescript": "^5.2.2",
|
|
67
73
|
"vitest": "^0.34.6"
|
|
68
74
|
},
|
|
69
75
|
"peerDependencies": {
|
|
70
|
-
"@mysten/sui.js": "^0.
|
|
71
|
-
"@scallop-io/sui-kit": "^0.
|
|
76
|
+
"@mysten/sui.js": "^0.44.0",
|
|
77
|
+
"@scallop-io/sui-kit": "^0.44.0"
|
|
72
78
|
},
|
|
73
79
|
"lint-staged": {
|
|
74
80
|
"**/*.ts": [
|
|
@@ -3,7 +3,7 @@ import { SUI_CLOCK_OBJECT_ID } from '@mysten/sui.js/utils';
|
|
|
3
3
|
import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
4
4
|
import { getObligations } from '../queries';
|
|
5
5
|
import { updateOracles } from './oracle';
|
|
6
|
-
import type {
|
|
6
|
+
import type { SuiAddressArg } from '@scallop-io/sui-kit';
|
|
7
7
|
import type { ScallopBuilder } from '../models';
|
|
8
8
|
import type {
|
|
9
9
|
CoreIds,
|
|
@@ -46,8 +46,8 @@ const requireObligationInfo = async (
|
|
|
46
46
|
...params: [
|
|
47
47
|
builder: ScallopBuilder,
|
|
48
48
|
txBlock: SuiKitTxBlock,
|
|
49
|
-
obligationId?:
|
|
50
|
-
obligationKey?:
|
|
49
|
+
obligationId?: SuiAddressArg,
|
|
50
|
+
obligationKey?: SuiAddressArg,
|
|
51
51
|
]
|
|
52
52
|
) => {
|
|
53
53
|
const [builder, txBlock, obligationId, obligationKey] = params;
|
|
@@ -275,12 +275,12 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
275
275
|
obligationKey
|
|
276
276
|
);
|
|
277
277
|
const updateCoinNames = await builder.utils.getObligationCoinNames(
|
|
278
|
-
obligationInfo.obligationId
|
|
278
|
+
obligationInfo.obligationId
|
|
279
279
|
);
|
|
280
280
|
await updateOracles(builder, txBlock, updateCoinNames);
|
|
281
281
|
return txBlock.takeCollateral(
|
|
282
282
|
obligationInfo.obligationId,
|
|
283
|
-
obligationInfo.obligationKey as
|
|
283
|
+
obligationInfo.obligationKey as SuiAddressArg,
|
|
284
284
|
amount,
|
|
285
285
|
collateralCoinName
|
|
286
286
|
);
|
|
@@ -321,13 +321,13 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
321
321
|
obligationKey
|
|
322
322
|
);
|
|
323
323
|
const obligationCoinNames = await builder.utils.getObligationCoinNames(
|
|
324
|
-
obligationInfo.obligationId
|
|
324
|
+
obligationInfo.obligationId
|
|
325
325
|
);
|
|
326
326
|
const updateCoinNames = [...obligationCoinNames, poolCoinName];
|
|
327
327
|
await updateOracles(builder, txBlock, updateCoinNames);
|
|
328
328
|
return txBlock.borrow(
|
|
329
329
|
obligationInfo.obligationId,
|
|
330
|
-
obligationInfo.obligationKey as
|
|
330
|
+
obligationInfo.obligationKey as SuiAddressArg,
|
|
331
331
|
amount,
|
|
332
332
|
poolCoinName
|
|
333
333
|
);
|
|
@@ -3,7 +3,8 @@ import { SUI_CLOCK_OBJECT_ID } from '@mysten/sui.js/utils';
|
|
|
3
3
|
import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
4
4
|
import { rewardCoins } from '../constants/enum';
|
|
5
5
|
import { getStakeAccounts } from '../queries/spoolQuery';
|
|
6
|
-
import type {
|
|
6
|
+
import type { SuiAddressArg } from '@scallop-io/sui-kit';
|
|
7
|
+
import type { TransactionResult } from '@mysten/sui.js/transactions';
|
|
7
8
|
import type { ScallopBuilder } from '../models';
|
|
8
9
|
import type {
|
|
9
10
|
SpoolIds,
|
|
@@ -13,7 +14,6 @@ import type {
|
|
|
13
14
|
SpoolTxBlock,
|
|
14
15
|
SupportStakeMarketCoins,
|
|
15
16
|
ScallopTxBlock,
|
|
16
|
-
TransactionResult,
|
|
17
17
|
} from '../types';
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -48,7 +48,7 @@ const requireStakeAccountIds = async (
|
|
|
48
48
|
builder: ScallopBuilder,
|
|
49
49
|
txBlock: SuiKitTxBlock,
|
|
50
50
|
stakeMarketCoinName: SupportStakeMarketCoins,
|
|
51
|
-
stakeAccountId?:
|
|
51
|
+
stakeAccountId?: SuiAddressArg,
|
|
52
52
|
]
|
|
53
53
|
) => {
|
|
54
54
|
const [builder, txBlock, stakeMarketCoinName, stakeAccountId] = params;
|
|
@@ -79,7 +79,7 @@ const requireStakeAccounts = async (
|
|
|
79
79
|
builder: ScallopBuilder,
|
|
80
80
|
txBlock: SuiKitTxBlock,
|
|
81
81
|
stakeMarketCoinName: SupportStakeMarketCoins,
|
|
82
|
-
stakeAccountId?:
|
|
82
|
+
stakeAccountId?: SuiAddressArg,
|
|
83
83
|
]
|
|
84
84
|
) => {
|
|
85
85
|
const [builder, txBlock, stakeMarketCoinName, stakeAccountId] = params;
|
package/src/constants/common.ts
CHANGED
|
@@ -14,6 +14,8 @@ export const SUPPORT_POOLS = [
|
|
|
14
14
|
'apt',
|
|
15
15
|
'sol',
|
|
16
16
|
'cetus',
|
|
17
|
+
'afsui',
|
|
18
|
+
'hasui',
|
|
17
19
|
] as const;
|
|
18
20
|
|
|
19
21
|
export const SUPPORT_COLLATERALS = [
|
|
@@ -25,6 +27,8 @@ export const SUPPORT_COLLATERALS = [
|
|
|
25
27
|
'apt',
|
|
26
28
|
'sol',
|
|
27
29
|
'cetus',
|
|
30
|
+
'afsui',
|
|
31
|
+
'hasui',
|
|
28
32
|
] as const;
|
|
29
33
|
|
|
30
34
|
export const SUPPORT_SPOOLS = ['ssui', 'susdc', 'susdt'] as const;
|
package/src/constants/enum.ts
CHANGED
|
@@ -17,6 +17,8 @@ export const coinDecimals: SupportCoinDecimals = {
|
|
|
17
17
|
apt: 8,
|
|
18
18
|
sol: 8,
|
|
19
19
|
cetus: 9,
|
|
20
|
+
afsui: 9,
|
|
21
|
+
hasui: 9,
|
|
20
22
|
seth: 8,
|
|
21
23
|
sbtc: 8,
|
|
22
24
|
susdc: 6,
|
|
@@ -25,6 +27,8 @@ export const coinDecimals: SupportCoinDecimals = {
|
|
|
25
27
|
sapt: 8,
|
|
26
28
|
ssol: 8,
|
|
27
29
|
scetus: 9,
|
|
30
|
+
safsui: 9,
|
|
31
|
+
shasui: 9,
|
|
28
32
|
};
|
|
29
33
|
|
|
30
34
|
export const assetCoins: AssetCoins = {
|
|
@@ -36,6 +40,8 @@ export const assetCoins: AssetCoins = {
|
|
|
36
40
|
apt: 'apt',
|
|
37
41
|
sol: 'sol',
|
|
38
42
|
cetus: 'cetus',
|
|
43
|
+
afsui: 'afsui',
|
|
44
|
+
hasui: 'hasui',
|
|
39
45
|
};
|
|
40
46
|
|
|
41
47
|
export const marketCoins: MarketCoins = {
|
|
@@ -47,6 +53,8 @@ export const marketCoins: MarketCoins = {
|
|
|
47
53
|
sapt: 'sapt',
|
|
48
54
|
ssol: 'ssol',
|
|
49
55
|
scetus: 'scetus',
|
|
56
|
+
safsui: 'safsui',
|
|
57
|
+
shasui: 'shasui',
|
|
50
58
|
};
|
|
51
59
|
|
|
52
60
|
export const stakeMarketCoins: StakeMarketCoins = {
|
|
@@ -70,6 +78,8 @@ export const coinIds: AssetCoinIds = {
|
|
|
70
78
|
apt: '0x3a5143bb1196e3bcdfab6203d1683ae29edd26294fc8bfeafe4aaa9d2704df37',
|
|
71
79
|
sol: '0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8',
|
|
72
80
|
cetus: '0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b',
|
|
81
|
+
afsui: '0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc',
|
|
82
|
+
hasui: '0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d',
|
|
73
83
|
};
|
|
74
84
|
|
|
75
85
|
export const wormholeCoinIds: WormholeCoinIds = {
|