@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,135 +1,88 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import ScallopUtils, { ScallopUtilsParams } from './scallopUtils';
|
|
2
|
+
import ScallopIndexer, { ScallopIndexerParams } from './scallopIndexer';
|
|
3
|
+
import { withIndexerFallback } from 'src/utils';
|
|
2
4
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
getCoinAmounts,
|
|
16
|
-
getCoinAmount,
|
|
17
|
-
getMarketCoinAmounts,
|
|
18
|
-
getMarketCoinAmount,
|
|
19
|
-
getLendings,
|
|
20
|
-
getLending,
|
|
21
|
-
getObligationAccounts,
|
|
22
|
-
getTotalValueLocked,
|
|
23
|
-
queryVeScaKeyIdFromReferralBindings,
|
|
5
|
+
CoinPrices,
|
|
6
|
+
MarketCollaterals,
|
|
7
|
+
MarketPool,
|
|
8
|
+
MarketPools,
|
|
9
|
+
StakePools,
|
|
10
|
+
StakeRewardPools,
|
|
11
|
+
SupportOracleType,
|
|
12
|
+
xOracleRules,
|
|
13
|
+
} from 'src/types';
|
|
14
|
+
import {
|
|
15
|
+
getAllCoinPrices,
|
|
16
|
+
getAssetOracles,
|
|
24
17
|
getBindedObligationId,
|
|
25
18
|
getBindedVeScaKey,
|
|
26
|
-
getVeScas,
|
|
27
|
-
getPythPrices,
|
|
28
|
-
getVeScaTreasuryInfo,
|
|
29
|
-
getLoyaltyProgramInformations,
|
|
30
|
-
getFlashLoanFees,
|
|
31
|
-
getVeSca,
|
|
32
19
|
getBorrowIncentivePools,
|
|
33
20
|
getBorrowLimit,
|
|
21
|
+
getCoinAmount,
|
|
22
|
+
getCoinAmounts,
|
|
23
|
+
getFlashLoanFees,
|
|
34
24
|
getIsolatedAssets,
|
|
35
|
-
|
|
25
|
+
getLending,
|
|
26
|
+
getLendings,
|
|
27
|
+
getLoyaltyProgramInformations,
|
|
28
|
+
getMarketCoinAmount,
|
|
29
|
+
getMarketCoinAmounts,
|
|
30
|
+
getMarketCollateral,
|
|
31
|
+
getMarketCollaterals,
|
|
32
|
+
getMarketPools,
|
|
33
|
+
getObligationAccounts,
|
|
34
|
+
getObligations,
|
|
35
|
+
getOnDemandAggObjectIds,
|
|
36
|
+
getPoolAddresses,
|
|
37
|
+
getPriceUpdatePolicies,
|
|
38
|
+
getPythPrice,
|
|
39
|
+
getPythPrices,
|
|
36
40
|
getSCoinAmount,
|
|
37
41
|
getSCoinAmounts,
|
|
38
42
|
getSCoinSwapRate,
|
|
39
43
|
getSCoinTotalSupply,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
getSpools,
|
|
45
|
+
getStakeAccounts,
|
|
46
|
+
getStakePool,
|
|
47
|
+
getStakeRewardPool,
|
|
48
|
+
getSupplyLimit,
|
|
49
|
+
getTotalValueLocked,
|
|
43
50
|
getUserPortfolio,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
import { ScallopConstants } from './scallopConstants';
|
|
70
|
-
/**
|
|
71
|
-
* @description
|
|
72
|
-
* It provides methods for getting on-chain data from the Scallop contract.
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```typescript
|
|
76
|
-
* const scallopQuery = new ScallopQuery(<parameters>);
|
|
77
|
-
* await scallopQuery.init();
|
|
78
|
-
* scallopQuery.<query functions>();
|
|
79
|
-
* await scallopQuery.<query functions>();
|
|
80
|
-
* ```
|
|
81
|
-
*/
|
|
82
|
-
export class ScallopQuery {
|
|
83
|
-
public readonly params: ScallopQueryParams;
|
|
84
|
-
|
|
85
|
-
public suiKit: SuiKit;
|
|
86
|
-
public address: ScallopAddress;
|
|
87
|
-
public utils: ScallopUtils;
|
|
88
|
-
public constants: ScallopConstants;
|
|
89
|
-
public indexer: ScallopIndexer;
|
|
90
|
-
public cache: ScallopCache;
|
|
91
|
-
public walletAddress: string;
|
|
92
|
-
|
|
93
|
-
public constructor(
|
|
94
|
-
params: ScallopQueryParams,
|
|
95
|
-
instance?: ScallopQueryInstanceParams
|
|
96
|
-
) {
|
|
97
|
-
this.params = params;
|
|
98
|
-
this.suiKit =
|
|
99
|
-
instance?.suiKit ?? instance?.utils?.suiKit ?? newSuiKit(params);
|
|
100
|
-
|
|
101
|
-
this.walletAddress = normalizeSuiAddress(
|
|
102
|
-
params.walletAddress ?? this.suiKit.currentAddress()
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
this.cache =
|
|
106
|
-
instance?.utils?.cache ??
|
|
107
|
-
instance?.cache ??
|
|
108
|
-
new ScallopCache(this.params, {
|
|
109
|
-
suiKit: this.suiKit,
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
this.address =
|
|
113
|
-
instance?.utils?.address ??
|
|
114
|
-
new ScallopAddress(this.params, {
|
|
115
|
-
cache: this.cache,
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
this.constants =
|
|
119
|
-
instance?.utils?.constants ??
|
|
120
|
-
new ScallopConstants(this.params, {
|
|
121
|
-
address: this.address,
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
this.utils =
|
|
125
|
-
instance?.utils ??
|
|
126
|
-
new ScallopUtils(this.params, {
|
|
127
|
-
constants: this.constants,
|
|
128
|
-
});
|
|
51
|
+
getVeSca,
|
|
52
|
+
getVeScas,
|
|
53
|
+
getVeScaTreasuryInfo,
|
|
54
|
+
isIsolatedAsset,
|
|
55
|
+
queryBorrowIncentiveAccounts,
|
|
56
|
+
queryMarket,
|
|
57
|
+
queryObligation,
|
|
58
|
+
queryVeScaKeyIdFromReferralBindings,
|
|
59
|
+
} from 'src/queries';
|
|
60
|
+
import { SuiObjectRef, SuiObjectData } from '@mysten/sui/dist/cjs/client';
|
|
61
|
+
import { SuiObjectArg } from '@scallop-io/sui-kit';
|
|
62
|
+
import { ScallopQueryInterface } from './interface';
|
|
63
|
+
|
|
64
|
+
export type ScallopQueryParams = {
|
|
65
|
+
indexer?: ScallopIndexer;
|
|
66
|
+
utils?: ScallopUtils;
|
|
67
|
+
} & ScallopUtilsParams &
|
|
68
|
+
ScallopIndexerParams;
|
|
69
|
+
|
|
70
|
+
class ScallopQuery implements ScallopQueryInterface {
|
|
71
|
+
public readonly indexer: ScallopIndexer;
|
|
72
|
+
public readonly utils: ScallopUtils;
|
|
73
|
+
|
|
74
|
+
constructor(params: ScallopQueryParams) {
|
|
75
|
+
this.utils = params.utils ?? new ScallopUtils(params);
|
|
129
76
|
this.indexer =
|
|
130
|
-
|
|
131
|
-
new ScallopIndexer(
|
|
77
|
+
params.indexer ??
|
|
78
|
+
new ScallopIndexer({
|
|
79
|
+
queryClient: this.utils.queryClient,
|
|
80
|
+
...params,
|
|
81
|
+
});
|
|
82
|
+
this.initIndexerFallback();
|
|
83
|
+
}
|
|
132
84
|
|
|
85
|
+
initIndexerFallback() {
|
|
133
86
|
// Wrap any method that has an indexer parameter as the last parameter
|
|
134
87
|
this.queryMarket = withIndexerFallback.call(this, this.queryMarket);
|
|
135
88
|
this.getMarketPools = withIndexerFallback.call(this, this.getMarketPools);
|
|
@@ -161,20 +114,29 @@ export class ScallopQuery {
|
|
|
161
114
|
this.getTvl = withIndexerFallback.call(this, this.getTvl);
|
|
162
115
|
}
|
|
163
116
|
|
|
164
|
-
/* ========================================================== */
|
|
165
|
-
|
|
166
117
|
/**
|
|
167
118
|
* Request the scallop API to initialize data.
|
|
168
119
|
*
|
|
169
120
|
* @param force - Whether to force initialization.
|
|
170
|
-
* @param address - ScallopAddress instance.
|
|
171
121
|
*/
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
122
|
+
async init(force: boolean = false) {
|
|
123
|
+
await this.utils.init({ force });
|
|
124
|
+
}
|
|
176
125
|
|
|
177
|
-
|
|
126
|
+
get constants() {
|
|
127
|
+
return this.utils.constants;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
get walletAddress() {
|
|
131
|
+
return this.utils.walletAddress;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
get scallopSuiKit() {
|
|
135
|
+
return this.utils.scallopSuiKit;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
get address() {
|
|
139
|
+
return this.utils.address;
|
|
178
140
|
}
|
|
179
141
|
|
|
180
142
|
/* ==================== Core Query Methods ==================== */
|
|
@@ -185,10 +147,7 @@ export class ScallopQuery {
|
|
|
185
147
|
* @param indexer - Whether to use indexer.
|
|
186
148
|
* @return Market data.
|
|
187
149
|
*/
|
|
188
|
-
|
|
189
|
-
coinPrices?: CoinPrices;
|
|
190
|
-
indexer?: boolean;
|
|
191
|
-
}) {
|
|
150
|
+
async queryMarket(args?: { coinPrices?: CoinPrices; indexer?: boolean }) {
|
|
192
151
|
return await queryMarket(this, args?.indexer, args?.coinPrices);
|
|
193
152
|
}
|
|
194
153
|
|
|
@@ -203,7 +162,7 @@ export class ScallopQuery {
|
|
|
203
162
|
* @param indexer - Whether to use indexer.
|
|
204
163
|
* @return Market pools data.
|
|
205
164
|
*/
|
|
206
|
-
|
|
165
|
+
async getMarketPools(
|
|
207
166
|
poolCoinNames: string[] = [...this.constants.whitelist.lending],
|
|
208
167
|
args?: {
|
|
209
168
|
coinPrices?: CoinPrices;
|
|
@@ -225,7 +184,7 @@ export class ScallopQuery {
|
|
|
225
184
|
* @param indexer - Whether to use indexer.
|
|
226
185
|
* @return Market pool data.
|
|
227
186
|
*/
|
|
228
|
-
|
|
187
|
+
async getMarketPool(
|
|
229
188
|
poolCoinName: string,
|
|
230
189
|
args?: {
|
|
231
190
|
coinPrice?: number;
|
|
@@ -247,7 +206,7 @@ export class ScallopQuery {
|
|
|
247
206
|
* @param indexer - Whether to use indexer.
|
|
248
207
|
* @return Market collaterals data.
|
|
249
208
|
*/
|
|
250
|
-
|
|
209
|
+
async getMarketCollaterals(
|
|
251
210
|
collateralCoinNames: string[] = [...this.constants.whitelist.collateral],
|
|
252
211
|
args?: { indexer?: boolean }
|
|
253
212
|
) {
|
|
@@ -261,7 +220,7 @@ export class ScallopQuery {
|
|
|
261
220
|
* @param indexer - Whether to use indexer.
|
|
262
221
|
* @return Market collateral data.
|
|
263
222
|
*/
|
|
264
|
-
|
|
223
|
+
async getMarketCollateral(
|
|
265
224
|
collateralCoinName: string,
|
|
266
225
|
args?: { indexer?: boolean }
|
|
267
226
|
) {
|
|
@@ -274,7 +233,7 @@ export class ScallopQuery {
|
|
|
274
233
|
* @param ownerAddress - The owner address.
|
|
275
234
|
* @return Obligations data.
|
|
276
235
|
*/
|
|
277
|
-
|
|
236
|
+
async getObligations(ownerAddress: string = this.walletAddress) {
|
|
278
237
|
return await getObligations(this, ownerAddress);
|
|
279
238
|
}
|
|
280
239
|
|
|
@@ -284,7 +243,7 @@ export class ScallopQuery {
|
|
|
284
243
|
* @param obligationId - The obligation id.
|
|
285
244
|
* @return Obligation data.
|
|
286
245
|
*/
|
|
287
|
-
|
|
246
|
+
async queryObligation(obligationId: SuiObjectArg) {
|
|
288
247
|
return queryObligation(this, obligationId);
|
|
289
248
|
}
|
|
290
249
|
|
|
@@ -295,7 +254,7 @@ export class ScallopQuery {
|
|
|
295
254
|
* @param ownerAddress - The owner address.
|
|
296
255
|
* @return All coin amounts.
|
|
297
256
|
*/
|
|
298
|
-
|
|
257
|
+
async getCoinAmounts(
|
|
299
258
|
assetCoinNames?: string[],
|
|
300
259
|
ownerAddress: string = this.walletAddress
|
|
301
260
|
) {
|
|
@@ -309,7 +268,7 @@ export class ScallopQuery {
|
|
|
309
268
|
* @param ownerAddress - The owner address.
|
|
310
269
|
* @return Coin amount.
|
|
311
270
|
*/
|
|
312
|
-
|
|
271
|
+
async getCoinAmount(
|
|
313
272
|
assetCoinName: string,
|
|
314
273
|
ownerAddress: string = this.walletAddress
|
|
315
274
|
) {
|
|
@@ -323,7 +282,7 @@ export class ScallopQuery {
|
|
|
323
282
|
* @param ownerAddress - The owner address.
|
|
324
283
|
* @return All market market coin amounts.
|
|
325
284
|
*/
|
|
326
|
-
|
|
285
|
+
async getMarketCoinAmounts(
|
|
327
286
|
marketCoinNames?: string[],
|
|
328
287
|
ownerAddress: string = this.walletAddress
|
|
329
288
|
) {
|
|
@@ -337,7 +296,7 @@ export class ScallopQuery {
|
|
|
337
296
|
* @param ownerAddress - The owner address.
|
|
338
297
|
* @return Market market coin amount.
|
|
339
298
|
*/
|
|
340
|
-
|
|
299
|
+
async getMarketCoinAmount(
|
|
341
300
|
marketCoinName: string,
|
|
342
301
|
ownerAddress: string = this.walletAddress
|
|
343
302
|
) {
|
|
@@ -350,7 +309,7 @@ export class ScallopQuery {
|
|
|
350
309
|
* @param assetCoinName - Specific support asset coin name.
|
|
351
310
|
* @return Asset coin price.
|
|
352
311
|
*/
|
|
353
|
-
|
|
312
|
+
async getPriceFromPyth(assetCoinName: string) {
|
|
354
313
|
return await getPythPrice(this, assetCoinName);
|
|
355
314
|
}
|
|
356
315
|
|
|
@@ -360,7 +319,7 @@ export class ScallopQuery {
|
|
|
360
319
|
* @param assetCoinNames - Array of supported asset coin names.
|
|
361
320
|
* @return Array of asset coin prices.
|
|
362
321
|
*/
|
|
363
|
-
|
|
322
|
+
async getPricesFromPyth(assetCoinNames: string[]) {
|
|
364
323
|
return await getPythPrices(this, assetCoinNames);
|
|
365
324
|
}
|
|
366
325
|
|
|
@@ -373,7 +332,7 @@ export class ScallopQuery {
|
|
|
373
332
|
* @param indexer - Whether to use indexer.
|
|
374
333
|
* @return Spools data.
|
|
375
334
|
*/
|
|
376
|
-
|
|
335
|
+
async getSpools(
|
|
377
336
|
stakeMarketCoinNames?: string[],
|
|
378
337
|
args?: {
|
|
379
338
|
marketPools?: MarketPools;
|
|
@@ -397,7 +356,7 @@ export class ScallopQuery {
|
|
|
397
356
|
* @param indexer - Whether to use indexer.
|
|
398
357
|
* @return Spool data.
|
|
399
358
|
*/
|
|
400
|
-
|
|
359
|
+
async getSpool(
|
|
401
360
|
stakeMarketCoinName: string,
|
|
402
361
|
args?: {
|
|
403
362
|
marketPool?: MarketPool;
|
|
@@ -415,7 +374,7 @@ export class ScallopQuery {
|
|
|
415
374
|
* @param ownerAddress - The owner address.
|
|
416
375
|
* @return All Stake accounts data.
|
|
417
376
|
*/
|
|
418
|
-
|
|
377
|
+
async getAllStakeAccounts(ownerAddress: string = this.walletAddress) {
|
|
419
378
|
return await getStakeAccounts(this, ownerAddress);
|
|
420
379
|
}
|
|
421
380
|
|
|
@@ -426,7 +385,7 @@ export class ScallopQuery {
|
|
|
426
385
|
* @param ownerAddress - The owner address.
|
|
427
386
|
* @return Stake accounts data.
|
|
428
387
|
*/
|
|
429
|
-
|
|
388
|
+
async getStakeAccounts(
|
|
430
389
|
stakeMarketCoinName: string,
|
|
431
390
|
ownerAddress: string = this.walletAddress
|
|
432
391
|
) {
|
|
@@ -444,7 +403,7 @@ export class ScallopQuery {
|
|
|
444
403
|
* @param stakeMarketCoinNames - Specific an array of support stake market coin name.
|
|
445
404
|
* @return Stake pools data.
|
|
446
405
|
*/
|
|
447
|
-
|
|
406
|
+
async getStakePools(
|
|
448
407
|
stakeMarketCoinNames: string[] = [...this.constants.whitelist.spool]
|
|
449
408
|
) {
|
|
450
409
|
const stakePools: StakePools = {};
|
|
@@ -469,7 +428,7 @@ export class ScallopQuery {
|
|
|
469
428
|
* @param stakeMarketCoinName - Specific support stake market coin name.
|
|
470
429
|
* @return Stake pool data.
|
|
471
430
|
*/
|
|
472
|
-
|
|
431
|
+
async getStakePool(stakeMarketCoinName: string) {
|
|
473
432
|
return await getStakePool(this, stakeMarketCoinName);
|
|
474
433
|
}
|
|
475
434
|
|
|
@@ -483,7 +442,7 @@ export class ScallopQuery {
|
|
|
483
442
|
* @param stakeMarketCoinNames - Specific an array of stake market coin name.
|
|
484
443
|
* @return Stake reward pools data.
|
|
485
444
|
*/
|
|
486
|
-
|
|
445
|
+
async getStakeRewardPools(
|
|
487
446
|
stakeMarketCoinNames: string[] = [...this.constants.whitelist.spool]
|
|
488
447
|
) {
|
|
489
448
|
const stakeRewardPools: StakeRewardPools = {};
|
|
@@ -512,7 +471,7 @@ export class ScallopQuery {
|
|
|
512
471
|
* @param marketCoinName - Specific support stake market coin name.
|
|
513
472
|
* @return Stake reward pool data.
|
|
514
473
|
*/
|
|
515
|
-
|
|
474
|
+
async getStakeRewardPool(stakeMarketCoinName: string) {
|
|
516
475
|
return await getStakeRewardPool(this, stakeMarketCoinName);
|
|
517
476
|
}
|
|
518
477
|
|
|
@@ -523,7 +482,7 @@ export class ScallopQuery {
|
|
|
523
482
|
* @param indexer - Whether to use indexer.
|
|
524
483
|
* @return Borrow incentive pools data.
|
|
525
484
|
*/
|
|
526
|
-
|
|
485
|
+
async getBorrowIncentivePools(
|
|
527
486
|
coinNames: string[] = [...this.constants.whitelist.lending],
|
|
528
487
|
args?: {
|
|
529
488
|
coinPrices?: CoinPrices;
|
|
@@ -547,7 +506,7 @@ export class ScallopQuery {
|
|
|
547
506
|
* @param ownerAddress - The owner address.
|
|
548
507
|
* @return Borrow incentive accounts data.
|
|
549
508
|
*/
|
|
550
|
-
|
|
509
|
+
async getBorrowIncentiveAccounts(
|
|
551
510
|
obligationId: string | SuiObjectRef,
|
|
552
511
|
coinNames?: string[]
|
|
553
512
|
) {
|
|
@@ -562,7 +521,7 @@ export class ScallopQuery {
|
|
|
562
521
|
* @param indexer - Whether to use indexer.
|
|
563
522
|
* @return All lending and spool infomation.
|
|
564
523
|
*/
|
|
565
|
-
|
|
524
|
+
async getLendings(
|
|
566
525
|
poolCoinNames?: string[],
|
|
567
526
|
ownerAddress: string = this.walletAddress,
|
|
568
527
|
args?: {
|
|
@@ -589,7 +548,7 @@ export class ScallopQuery {
|
|
|
589
548
|
* @param indexer - Whether to use indexer.
|
|
590
549
|
* @return Lending pool data.
|
|
591
550
|
*/
|
|
592
|
-
|
|
551
|
+
async getLending(
|
|
593
552
|
poolCoinName: string,
|
|
594
553
|
ownerAddress: string = this.walletAddress,
|
|
595
554
|
args?: { indexer?: boolean }
|
|
@@ -607,7 +566,7 @@ export class ScallopQuery {
|
|
|
607
566
|
* @param indexer - Whether to use indexer.
|
|
608
567
|
* @return All obligation accounts information.
|
|
609
568
|
*/
|
|
610
|
-
|
|
569
|
+
async getObligationAccounts(
|
|
611
570
|
ownerAddress: string = this.walletAddress,
|
|
612
571
|
args?: {
|
|
613
572
|
indexer?: boolean;
|
|
@@ -638,7 +597,7 @@ export class ScallopQuery {
|
|
|
638
597
|
* @param indexer - Whether to use indexer.
|
|
639
598
|
* @return Borrowing and collateral information.
|
|
640
599
|
*/
|
|
641
|
-
|
|
600
|
+
async getObligationAccount(
|
|
642
601
|
obligationId: string,
|
|
643
602
|
ownerAddress: string = this.walletAddress,
|
|
644
603
|
args?: { indexer?: boolean }
|
|
@@ -658,7 +617,7 @@ export class ScallopQuery {
|
|
|
658
617
|
*
|
|
659
618
|
* @return Total value locked.
|
|
660
619
|
*/
|
|
661
|
-
|
|
620
|
+
async getTvl(args?: { indexer?: boolean }) {
|
|
662
621
|
return await getTotalValueLocked(this, args?.indexer);
|
|
663
622
|
}
|
|
664
623
|
|
|
@@ -667,7 +626,7 @@ export class ScallopQuery {
|
|
|
667
626
|
* @param veScaKey
|
|
668
627
|
* @returns veSca
|
|
669
628
|
*/
|
|
670
|
-
|
|
629
|
+
async getVeSca(veScaKey: string | SuiObjectData) {
|
|
671
630
|
return await getVeSca(this.utils, veScaKey);
|
|
672
631
|
}
|
|
673
632
|
|
|
@@ -676,7 +635,7 @@ export class ScallopQuery {
|
|
|
676
635
|
* @param walletAddress
|
|
677
636
|
* @returns array of veSca
|
|
678
637
|
*/
|
|
679
|
-
|
|
638
|
+
async getVeScas({
|
|
680
639
|
walletAddress = this.walletAddress,
|
|
681
640
|
excludeEmpty = false,
|
|
682
641
|
}: {
|
|
@@ -690,7 +649,7 @@ export class ScallopQuery {
|
|
|
690
649
|
* Get total vesca treasury with movecall
|
|
691
650
|
* @returns Promise<string | undefined>
|
|
692
651
|
*/
|
|
693
|
-
|
|
652
|
+
async getVeScaTreasuryInfo() {
|
|
694
653
|
return await getVeScaTreasuryInfo(this.utils);
|
|
695
654
|
}
|
|
696
655
|
|
|
@@ -699,13 +658,10 @@ export class ScallopQuery {
|
|
|
699
658
|
* @param walletAddress
|
|
700
659
|
* @returns veScaKeyId
|
|
701
660
|
*/
|
|
702
|
-
|
|
661
|
+
async getVeScaKeyIdFromReferralBindings(
|
|
703
662
|
walletAddress: string = this.walletAddress
|
|
704
663
|
) {
|
|
705
|
-
return await queryVeScaKeyIdFromReferralBindings(
|
|
706
|
-
this.address,
|
|
707
|
-
walletAddress
|
|
708
|
-
);
|
|
664
|
+
return await queryVeScaKeyIdFromReferralBindings(this, walletAddress);
|
|
709
665
|
}
|
|
710
666
|
|
|
711
667
|
/**
|
|
@@ -713,7 +669,7 @@ export class ScallopQuery {
|
|
|
713
669
|
* @param veScaKey
|
|
714
670
|
* @returns obligationId
|
|
715
671
|
*/
|
|
716
|
-
|
|
672
|
+
async getBindedObligationId(veScaKey: string) {
|
|
717
673
|
return await getBindedObligationId(this, veScaKey);
|
|
718
674
|
}
|
|
719
675
|
|
|
@@ -722,7 +678,7 @@ export class ScallopQuery {
|
|
|
722
678
|
* @param obligationId
|
|
723
679
|
* @returns veScaKey
|
|
724
680
|
*/
|
|
725
|
-
|
|
681
|
+
async getBindedVeScaKey(obligationId: string) {
|
|
726
682
|
return await getBindedVeScaKey(this, obligationId);
|
|
727
683
|
}
|
|
728
684
|
|
|
@@ -731,7 +687,7 @@ export class ScallopQuery {
|
|
|
731
687
|
* @param walletAddress
|
|
732
688
|
* @returns Loyalty program information
|
|
733
689
|
*/
|
|
734
|
-
|
|
690
|
+
async getLoyaltyProgramInfos(veScaKey?: string | SuiObjectData) {
|
|
735
691
|
return await getLoyaltyProgramInformations(this, veScaKey);
|
|
736
692
|
}
|
|
737
693
|
|
|
@@ -740,7 +696,7 @@ export class ScallopQuery {
|
|
|
740
696
|
* @param sCoinName - Supported sCoin name
|
|
741
697
|
* @returns Total Supply
|
|
742
698
|
*/
|
|
743
|
-
|
|
699
|
+
async getSCoinTotalSupply(sCoinName: string) {
|
|
744
700
|
return await getSCoinTotalSupply(this, sCoinName);
|
|
745
701
|
}
|
|
746
702
|
|
|
@@ -751,7 +707,7 @@ export class ScallopQuery {
|
|
|
751
707
|
* @param ownerAddress - The owner address.
|
|
752
708
|
* @return All market sCoin amounts.
|
|
753
709
|
*/
|
|
754
|
-
|
|
710
|
+
async getSCoinAmounts(
|
|
755
711
|
sCoinNames?: string[],
|
|
756
712
|
ownerAddress: string = this.walletAddress
|
|
757
713
|
) {
|
|
@@ -765,7 +721,7 @@ export class ScallopQuery {
|
|
|
765
721
|
* @param ownerAddress - The owner address.
|
|
766
722
|
* @return sCoin amount.
|
|
767
723
|
*/
|
|
768
|
-
|
|
724
|
+
async getSCoinAmount(
|
|
769
725
|
sCoinName: string | string,
|
|
770
726
|
ownerAddress: string = this.walletAddress
|
|
771
727
|
) {
|
|
@@ -780,14 +736,14 @@ export class ScallopQuery {
|
|
|
780
736
|
* @param assetCoinNames
|
|
781
737
|
* @returns
|
|
782
738
|
*/
|
|
783
|
-
|
|
739
|
+
async getSCoinSwapRate(fromSCoin: string, toSCoin: string) {
|
|
784
740
|
return await getSCoinSwapRate(this, fromSCoin, toSCoin);
|
|
785
741
|
}
|
|
786
742
|
|
|
787
743
|
/*
|
|
788
744
|
* Get flashloan fee for specified assets
|
|
789
745
|
*/
|
|
790
|
-
|
|
746
|
+
async getFlashLoanFees(
|
|
791
747
|
assetCoinNames: string[] = [...this.constants.whitelist.lending]
|
|
792
748
|
) {
|
|
793
749
|
return await getFlashLoanFees(this, assetCoinNames);
|
|
@@ -796,28 +752,28 @@ export class ScallopQuery {
|
|
|
796
752
|
/**
|
|
797
753
|
* Get supply limit of lending pool
|
|
798
754
|
*/
|
|
799
|
-
|
|
755
|
+
async getPoolSupplyLimit(poolName: string) {
|
|
800
756
|
return await getSupplyLimit(this.utils, poolName);
|
|
801
757
|
}
|
|
802
758
|
|
|
803
759
|
/**
|
|
804
760
|
* Get borrow limit of borrow pool
|
|
805
761
|
*/
|
|
806
|
-
|
|
762
|
+
async getPoolBorrowLimit(poolName: string) {
|
|
807
763
|
return await getBorrowLimit(this.utils, poolName);
|
|
808
764
|
}
|
|
809
765
|
|
|
810
766
|
/**
|
|
811
767
|
* Get list of isolated assets
|
|
812
768
|
*/
|
|
813
|
-
|
|
769
|
+
async getIsolatedAssets() {
|
|
814
770
|
return await getIsolatedAssets(this);
|
|
815
771
|
}
|
|
816
772
|
|
|
817
773
|
/**
|
|
818
774
|
* Check if asset is an isolated asset
|
|
819
775
|
*/
|
|
820
|
-
|
|
776
|
+
async isIsolatedAsset(assetCoinName: string) {
|
|
821
777
|
return isIsolatedAsset(this.utils, assetCoinName);
|
|
822
778
|
}
|
|
823
779
|
|
|
@@ -826,7 +782,7 @@ export class ScallopQuery {
|
|
|
826
782
|
* @param coinName
|
|
827
783
|
* @returns price data
|
|
828
784
|
*/
|
|
829
|
-
|
|
785
|
+
async getCoinPriceByIndexer(poolName: string) {
|
|
830
786
|
return this.indexer.getCoinPrice(poolName);
|
|
831
787
|
}
|
|
832
788
|
|
|
@@ -834,7 +790,7 @@ export class ScallopQuery {
|
|
|
834
790
|
* Get all supported pool price from indexer
|
|
835
791
|
* @returns prices data
|
|
836
792
|
*/
|
|
837
|
-
|
|
793
|
+
async getCoinPricesByIndexer() {
|
|
838
794
|
return this.indexer.getCoinPrices();
|
|
839
795
|
}
|
|
840
796
|
|
|
@@ -842,7 +798,7 @@ export class ScallopQuery {
|
|
|
842
798
|
* Get all coin prices, including sCoin
|
|
843
799
|
* @returns prices data
|
|
844
800
|
*/
|
|
845
|
-
|
|
801
|
+
async getAllCoinPrices(args?: {
|
|
846
802
|
marketPools?: MarketPools;
|
|
847
803
|
coinPrices?: CoinPrices;
|
|
848
804
|
indexer?: boolean;
|
|
@@ -859,7 +815,7 @@ export class ScallopQuery {
|
|
|
859
815
|
* Query all address (lending pool, collateral pool, borrow dynamics, interest models, etc.) of all pool
|
|
860
816
|
* @returns
|
|
861
817
|
*/
|
|
862
|
-
|
|
818
|
+
async getPoolAddresses(apiAddressId = this.address.getId()) {
|
|
863
819
|
if (!apiAddressId) throw new Error('apiAddressId is required');
|
|
864
820
|
return getPoolAddresses(apiAddressId);
|
|
865
821
|
}
|
|
@@ -867,10 +823,7 @@ export class ScallopQuery {
|
|
|
867
823
|
/**
|
|
868
824
|
* Get user portfolio
|
|
869
825
|
*/
|
|
870
|
-
|
|
871
|
-
walletAddress?: string;
|
|
872
|
-
indexer?: boolean;
|
|
873
|
-
}) {
|
|
826
|
+
async getUserPortfolio(args?: { walletAddress?: string; indexer?: boolean }) {
|
|
874
827
|
return getUserPortfolio(
|
|
875
828
|
this,
|
|
876
829
|
args?.walletAddress ?? this.walletAddress,
|
|
@@ -882,15 +835,15 @@ export class ScallopQuery {
|
|
|
882
835
|
* Get both primary and secondary price update policy objects
|
|
883
836
|
* @returns price update policies
|
|
884
837
|
*/
|
|
885
|
-
|
|
886
|
-
return await getPriceUpdatePolicies(this
|
|
838
|
+
async getPriceUpdatePolicies() {
|
|
839
|
+
return await getPriceUpdatePolicies(this);
|
|
887
840
|
}
|
|
888
841
|
|
|
889
842
|
/**
|
|
890
843
|
* Return the supported primary and secondary oracles for all supported pool assets
|
|
891
844
|
* @returns
|
|
892
845
|
*/
|
|
893
|
-
|
|
846
|
+
async getAssetOracles() {
|
|
894
847
|
const [primary, secondary] = await Promise.all([
|
|
895
848
|
getAssetOracles(this.utils, 'primary'),
|
|
896
849
|
getAssetOracles(this.utils, 'secondary'),
|
|
@@ -913,7 +866,9 @@ export class ScallopQuery {
|
|
|
913
866
|
* @param coinType
|
|
914
867
|
* @returns
|
|
915
868
|
*/
|
|
916
|
-
|
|
869
|
+
async getSwitchboardOnDemandAggregatorObjectIds(coinName: string[]) {
|
|
917
870
|
return await getOnDemandAggObjectIds(this, coinName);
|
|
918
871
|
}
|
|
919
872
|
}
|
|
873
|
+
|
|
874
|
+
export default ScallopQuery;
|