@scallop-io/sui-scallop-sdk 2.0.13-merge-split-ve-sca-alpha.4 → 2.1.0-alpha.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/index.d.mts +622 -697
- package/dist/index.d.ts +622 -697
- package/dist/index.js +32 -33
- package/dist/index.mjs +10 -10
- package/package.json +8 -18
- package/src/builders/borrowIncentiveBuilder.ts +8 -18
- package/src/builders/coreBuilder.ts +2 -2
- package/src/builders/index.ts +2 -2
- package/src/builders/oracles/index.ts +2 -3
- package/src/builders/oracles/pyth.ts +2 -2
- package/src/builders/spoolBuilder.ts +2 -2
- package/src/builders/vescaBuilder.ts +14 -132
- package/src/constants/queryKeys.ts +29 -54
- package/src/constants/testAddress.ts +6 -12
- package/src/index.ts +11 -1
- package/src/models/index.ts +11 -9
- package/src/models/interface.ts +36 -0
- package/src/models/scallop.ts +38 -133
- package/src/models/scallopAddress.ts +127 -142
- package/src/models/scallopAxios.ts +185 -0
- package/src/models/scallopBuilder.ts +45 -75
- package/src/models/scallopClient.ts +124 -154
- package/src/models/scallopConstants.ts +248 -323
- package/src/models/scallopIndexer.ts +54 -98
- package/src/models/scallopQuery.ts +145 -190
- package/src/models/scallopQueryClient.ts +29 -0
- package/src/models/scallopSuiKit.ts +432 -0
- package/src/models/scallopUtils.ts +260 -164
- package/src/queries/borrowIncentiveQuery.ts +28 -16
- package/src/queries/borrowLimitQuery.ts +1 -1
- package/src/queries/coreQuery.ts +148 -107
- package/src/queries/flashloanFeeQuery.ts +12 -6
- package/src/queries/index.ts +0 -1
- package/src/queries/isolatedAssetQuery.ts +3 -3
- package/src/queries/loyaltyProgramQuery.ts +10 -8
- package/src/queries/ownerQuery.ts +32 -0
- package/src/queries/portfolioQuery.ts +4 -5
- package/src/queries/priceQuery.ts +14 -8
- package/src/queries/referralQuery.ts +9 -3
- package/src/queries/sCoinQuery.ts +4 -4
- package/src/queries/spoolQuery.ts +11 -11
- package/src/queries/supplyLimitQuery.ts +1 -1
- package/src/queries/switchboardQuery.ts +1 -1
- package/src/queries/vescaQuery.ts +31 -27
- package/src/queries/xOracleQuery.ts +13 -8
- package/src/types/address.ts +0 -3
- package/src/types/builder/core.ts +1 -1
- package/src/types/builder/vesca.ts +10 -20
- package/src/types/constant/queryKeys.ts +48 -0
- package/src/types/index.ts +0 -1
- package/src/utils/builder.ts +1 -1
- package/src/utils/util.ts +1 -33
- package/src/models/scallopCache.ts +0 -428
- package/src/queries/objectsQuery.ts +0 -18
- package/src/types/model.ts +0 -117
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import { normalizeSuiAddress } from '@mysten/sui/utils';
|
|
2
|
-
import { SuiKit } from '@scallop-io/sui-kit';
|
|
3
1
|
import { newScallopTxBlock } from '../builders';
|
|
4
|
-
import {
|
|
5
|
-
import { ScallopQuery } from './scallopQuery';
|
|
6
|
-
import { ScallopUtils } from './scallopUtils';
|
|
2
|
+
import ScallopQuery, { ScallopQueryParams } from './scallopQuery';
|
|
7
3
|
import type { SuiTransactionBlockResponse } from '@mysten/sui/client';
|
|
8
4
|
import type {
|
|
9
5
|
Transaction,
|
|
@@ -16,15 +12,14 @@ import type {
|
|
|
16
12
|
SuiTxArg,
|
|
17
13
|
SuiVecTxArg,
|
|
18
14
|
} from '@scallop-io/sui-kit';
|
|
19
|
-
import type {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
import { ScallopConstants } from './scallopConstants';
|
|
15
|
+
import type { ScallopTxBlock, SelectCoinReturnType } from '../types';
|
|
16
|
+
import { ScallopBuilderInterface } from './interface';
|
|
17
|
+
|
|
18
|
+
export type ScallopBuilderParams = {
|
|
19
|
+
query?: ScallopQuery;
|
|
20
|
+
usePythPullModel?: boolean;
|
|
21
|
+
useOnChainXOracleList?: boolean;
|
|
22
|
+
} & ScallopQueryParams;
|
|
28
23
|
|
|
29
24
|
/**
|
|
30
25
|
* @description
|
|
@@ -37,74 +32,47 @@ import { ScallopConstants } from './scallopConstants';
|
|
|
37
32
|
* const txBlock = scallopBuilder.<builder functions>();
|
|
38
33
|
* ```
|
|
39
34
|
*/
|
|
40
|
-
|
|
41
|
-
public readonly
|
|
42
|
-
public readonly
|
|
35
|
+
class ScallopBuilder implements ScallopBuilderInterface {
|
|
36
|
+
public readonly query: ScallopQuery;
|
|
37
|
+
public readonly usePythPullModel: boolean;
|
|
38
|
+
public readonly useOnChainXOracleList: boolean;
|
|
43
39
|
|
|
44
|
-
public
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
public walletAddress: string;
|
|
50
|
-
public cache: ScallopCache;
|
|
51
|
-
|
|
52
|
-
public constructor(
|
|
53
|
-
params: ScallopBuilderParams,
|
|
54
|
-
instance?: ScallopBuilderInstanceParams
|
|
55
|
-
) {
|
|
56
|
-
this.suiKit = instance?.suiKit ?? newSuiKit(params);
|
|
57
|
-
|
|
58
|
-
this.params = params;
|
|
59
|
-
this.walletAddress = normalizeSuiAddress(
|
|
60
|
-
params?.walletAddress ?? this.suiKit.currentAddress()
|
|
61
|
-
);
|
|
40
|
+
public constructor(params: ScallopBuilderParams) {
|
|
41
|
+
this.query = params.query ?? new ScallopQuery(params);
|
|
42
|
+
this.usePythPullModel = params.usePythPullModel ?? true;
|
|
43
|
+
this.useOnChainXOracleList = params.useOnChainXOracleList ?? true;
|
|
44
|
+
}
|
|
62
45
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
suiKit: this.suiKit,
|
|
67
|
-
});
|
|
46
|
+
get utils() {
|
|
47
|
+
return this.query.utils;
|
|
48
|
+
}
|
|
68
49
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
cache: this.cache,
|
|
73
|
-
});
|
|
50
|
+
get constants() {
|
|
51
|
+
return this.utils.constants;
|
|
52
|
+
}
|
|
74
53
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
address: this.address,
|
|
79
|
-
});
|
|
54
|
+
get walletAddress() {
|
|
55
|
+
return this.utils.walletAddress;
|
|
56
|
+
}
|
|
80
57
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
constants: this.constants,
|
|
85
|
-
});
|
|
58
|
+
get scallopSuiKit() {
|
|
59
|
+
return this.utils.scallopSuiKit;
|
|
60
|
+
}
|
|
86
61
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
utils: this.utils,
|
|
91
|
-
});
|
|
62
|
+
get suiKit() {
|
|
63
|
+
return this.scallopSuiKit.suiKit;
|
|
64
|
+
}
|
|
92
65
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
: false;
|
|
66
|
+
get address() {
|
|
67
|
+
return this.utils.address;
|
|
96
68
|
}
|
|
97
69
|
|
|
98
70
|
/**
|
|
99
71
|
* Request the scallop API to initialize data.
|
|
100
72
|
*
|
|
101
73
|
* @param force - Whether to force initialization.
|
|
102
|
-
* @param address - ScallopAddress instance.
|
|
103
74
|
*/
|
|
104
|
-
|
|
105
|
-
if (force || !this.constants.isInitialized) {
|
|
106
|
-
await this.constants.init();
|
|
107
|
-
}
|
|
75
|
+
async init(force: boolean = false) {
|
|
108
76
|
await this.query.init(force);
|
|
109
77
|
}
|
|
110
78
|
|
|
@@ -114,7 +82,7 @@ export class ScallopBuilder {
|
|
|
114
82
|
* @param txBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
|
|
115
83
|
* @return Scallop txBlock.
|
|
116
84
|
*/
|
|
117
|
-
|
|
85
|
+
createTxBlock(txBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction) {
|
|
118
86
|
return newScallopTxBlock(this, txBlock);
|
|
119
87
|
}
|
|
120
88
|
|
|
@@ -127,7 +95,7 @@ export class ScallopBuilder {
|
|
|
127
95
|
* @param sender - Sender address.
|
|
128
96
|
* @return Take coin and left coin.
|
|
129
97
|
*/
|
|
130
|
-
|
|
98
|
+
async selectCoin<T extends string>(
|
|
131
99
|
txBlock: ScallopTxBlock | SuiKitTxBlock,
|
|
132
100
|
assetCoinName: T,
|
|
133
101
|
amount: number,
|
|
@@ -153,7 +121,7 @@ export class ScallopBuilder {
|
|
|
153
121
|
* @param sender - Sender address.
|
|
154
122
|
* @return Take coin and left coin.
|
|
155
123
|
*/
|
|
156
|
-
|
|
124
|
+
async selectMarketCoin(
|
|
157
125
|
txBlock: ScallopTxBlock | SuiKitTxBlock,
|
|
158
126
|
marketCoinName: string,
|
|
159
127
|
amount: number,
|
|
@@ -181,7 +149,7 @@ export class ScallopBuilder {
|
|
|
181
149
|
* @param sender - Sender address.
|
|
182
150
|
* @return Take coin and left coin.
|
|
183
151
|
*/
|
|
184
|
-
|
|
152
|
+
async selectSCoin(
|
|
185
153
|
txBlock: ScallopTxBlock | SuiKitTxBlock,
|
|
186
154
|
sCoinName: string,
|
|
187
155
|
amount: number,
|
|
@@ -207,7 +175,7 @@ export class ScallopBuilder {
|
|
|
207
175
|
/**
|
|
208
176
|
* Select sCoin or market coin automatically. Prioritize sCoin first
|
|
209
177
|
*/
|
|
210
|
-
|
|
178
|
+
async selectSCoinOrMarketCoin(
|
|
211
179
|
txBlock: ScallopTxBlock | SuiKitTxBlock,
|
|
212
180
|
sCoinName: string,
|
|
213
181
|
amount: number,
|
|
@@ -282,10 +250,10 @@ export class ScallopBuilder {
|
|
|
282
250
|
*
|
|
283
251
|
* @param txBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
|
|
284
252
|
*/
|
|
285
|
-
|
|
253
|
+
async signAndSendTxBlock(
|
|
286
254
|
txBlock: ScallopTxBlock | SuiKitTxBlock | Transaction
|
|
287
255
|
) {
|
|
288
|
-
return (await this.suiKit.signAndSendTxn(
|
|
256
|
+
return (await this.scallopSuiKit.suiKit.signAndSendTxn(
|
|
289
257
|
txBlock
|
|
290
258
|
)) as SuiTransactionBlockResponse;
|
|
291
259
|
}
|
|
@@ -299,3 +267,5 @@ export class ScallopBuilder {
|
|
|
299
267
|
return txb.moveCall(target, args, typeArgs);
|
|
300
268
|
}
|
|
301
269
|
}
|
|
270
|
+
|
|
271
|
+
export default ScallopBuilder;
|