@scallop-io/sui-scallop-sdk 1.5.3 → 2.0.0-alpha.10
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 +509 -602
- package/dist/index.d.ts +509 -602
- package/dist/index.js +28 -59
- package/dist/index.mjs +7 -7
- package/package.json +1 -1
- package/src/builders/coreBuilder.ts +33 -33
- package/src/builders/loyaltyProgramBuilder.ts +5 -3
- package/src/builders/{oracle.ts → oracles/index.ts} +48 -60
- package/src/builders/oracles/pyth.ts +44 -0
- package/src/builders/oracles/switchboard.ts +270 -0
- package/src/builders/referralBuilder.ts +5 -9
- package/src/builders/sCoinBuilder.ts +9 -8
- package/src/builders/spoolBuilder.ts +4 -6
- package/src/constants/common.ts +114 -126
- package/src/constants/index.ts +0 -5
- package/src/constants/pyth.ts +25 -34
- package/src/constants/queryKeys.ts +2 -0
- package/src/constants/testAddress.ts +36 -487
- package/src/models/index.ts +1 -0
- package/src/models/scallop.ts +23 -19
- package/src/models/scallopAddress.ts +17 -5
- package/src/models/scallopBuilder.ts +36 -41
- package/src/models/scallopCache.ts +3 -3
- package/src/models/scallopClient.ts +93 -98
- package/src/models/scallopConstants.ts +399 -0
- package/src/models/scallopIndexer.ts +11 -24
- package/src/models/scallopQuery.ts +76 -79
- package/src/models/scallopUtils.ts +126 -250
- package/src/queries/borrowIncentiveQuery.ts +25 -58
- package/src/queries/borrowLimitQuery.ts +3 -6
- package/src/queries/coreQuery.ts +98 -114
- package/src/queries/flashloanFeeQuery.ts +86 -0
- package/src/queries/index.ts +1 -0
- package/src/queries/isolatedAssetQuery.ts +12 -11
- package/src/queries/poolAddressesQuery.ts +211 -117
- package/src/queries/portfolioQuery.ts +60 -70
- package/src/queries/priceQuery.ts +16 -22
- package/src/queries/sCoinQuery.ts +15 -16
- package/src/queries/spoolQuery.ts +49 -59
- package/src/queries/supplyLimitQuery.ts +2 -6
- package/src/queries/switchboardQuery.ts +64 -0
- package/src/queries/xOracleQuery.ts +29 -32
- package/src/types/address.ts +21 -19
- package/src/types/builder/borrowIncentive.ts +2 -3
- package/src/types/builder/core.ts +20 -27
- package/src/types/builder/index.ts +1 -2
- package/src/types/builder/referral.ts +4 -8
- package/src/types/builder/sCoin.ts +4 -8
- package/src/types/builder/spool.ts +7 -10
- package/src/types/constant/common.ts +44 -49
- package/src/types/constant/enum.ts +15 -27
- package/src/types/constant/xOracle.ts +3 -2
- package/src/types/model.ts +49 -28
- package/src/types/query/borrowIncentive.ts +7 -24
- package/src/types/query/core.ts +8 -18
- package/src/types/query/portfolio.ts +9 -17
- package/src/types/query/spool.ts +5 -11
- package/src/types/utils.ts +1 -21
- package/src/utils/core.ts +1 -1
- package/src/utils/query.ts +15 -23
- package/src/utils/util.ts +6 -84
- package/src/constants/coinGecko.ts +0 -34
- package/src/constants/enum.ts +0 -268
- package/src/constants/flashloan.ts +0 -18
- package/src/constants/poolAddress.ts +0 -898
- package/src/models/scallopPrice.ts +0 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { SuiKit, SuiObjectArg } from '@scallop-io/sui-kit';
|
|
2
|
-
import { ADDRESS_ID, SUPPORT_POOLS, SUPPORT_SPOOLS } from '../constants';
|
|
3
2
|
import {
|
|
4
3
|
queryMarket,
|
|
5
4
|
getObligations,
|
|
@@ -33,36 +32,30 @@ import {
|
|
|
33
32
|
getBorrowIncentivePools,
|
|
34
33
|
getBorrowLimit,
|
|
35
34
|
getIsolatedAssets,
|
|
36
|
-
// isIsolatedAsset,
|
|
37
35
|
getSupplyLimit,
|
|
38
36
|
getSCoinAmount,
|
|
39
37
|
getSCoinAmounts,
|
|
40
38
|
getSCoinSwapRate,
|
|
41
39
|
getSCoinTotalSupply,
|
|
42
40
|
getAllCoinPrices,
|
|
43
|
-
|
|
41
|
+
getPoolAddresses,
|
|
44
42
|
isIsolatedAsset,
|
|
45
43
|
getUserPortfolio,
|
|
46
44
|
getPriceUpdatePolicies,
|
|
47
45
|
getAssetOracles,
|
|
46
|
+
getOnDemandAggObjectIds,
|
|
48
47
|
} from '../queries';
|
|
49
48
|
import {
|
|
50
49
|
ScallopQueryParams,
|
|
51
|
-
SupportStakeMarketCoins,
|
|
52
|
-
SupportAssetCoins,
|
|
53
|
-
SupportPoolCoins,
|
|
54
|
-
SupportCollateralCoins,
|
|
55
|
-
SupportMarketCoins,
|
|
56
50
|
StakePools,
|
|
57
51
|
StakeRewardPools,
|
|
58
|
-
SupportBorrowIncentiveCoins,
|
|
59
|
-
SupportSCoin,
|
|
60
52
|
ScallopQueryInstanceParams,
|
|
61
53
|
MarketPool,
|
|
62
54
|
CoinPrices,
|
|
63
55
|
MarketPools,
|
|
64
56
|
MarketCollaterals,
|
|
65
57
|
xOracleRules,
|
|
58
|
+
SupportOracleType,
|
|
66
59
|
} from '../types';
|
|
67
60
|
import { ScallopAddress } from './scallopAddress';
|
|
68
61
|
import { ScallopUtils } from './scallopUtils';
|
|
@@ -73,6 +66,7 @@ import { normalizeSuiAddress } from '@mysten/sui/utils';
|
|
|
73
66
|
import { withIndexerFallback } from 'src/utils/indexer';
|
|
74
67
|
import { newSuiKit } from './suiKit';
|
|
75
68
|
import { SuiObjectRef } from '@mysten/sui/client';
|
|
69
|
+
import { ScallopConstants } from './scallopConstants';
|
|
76
70
|
/**
|
|
77
71
|
* @description
|
|
78
72
|
* It provides methods for getting on-chain data from the Scallop contract.
|
|
@@ -91,12 +85,13 @@ export class ScallopQuery {
|
|
|
91
85
|
public suiKit: SuiKit;
|
|
92
86
|
public address: ScallopAddress;
|
|
93
87
|
public utils: ScallopUtils;
|
|
88
|
+
public constants: ScallopConstants;
|
|
94
89
|
public indexer: ScallopIndexer;
|
|
95
90
|
public cache: ScallopCache;
|
|
96
91
|
public walletAddress: string;
|
|
97
92
|
|
|
98
93
|
public constructor(
|
|
99
|
-
params: ScallopQueryParams
|
|
94
|
+
params: ScallopQueryParams,
|
|
100
95
|
instance?: ScallopQueryInstanceParams
|
|
101
96
|
) {
|
|
102
97
|
this.params = params;
|
|
@@ -107,28 +102,30 @@ export class ScallopQuery {
|
|
|
107
102
|
params.walletAddress ?? this.suiKit.currentAddress()
|
|
108
103
|
);
|
|
109
104
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
this.
|
|
114
|
-
} else {
|
|
115
|
-
this.cache = new ScallopCache(this.params, {
|
|
105
|
+
this.cache =
|
|
106
|
+
instance?.utils?.cache ??
|
|
107
|
+
instance?.cache ??
|
|
108
|
+
new ScallopCache(this.params, {
|
|
116
109
|
suiKit: this.suiKit,
|
|
117
110
|
});
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
this.utils = new ScallopUtils(this.params, {
|
|
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, {
|
|
129
121
|
address: this.address,
|
|
130
122
|
});
|
|
131
|
-
|
|
123
|
+
|
|
124
|
+
this.utils =
|
|
125
|
+
instance?.utils ??
|
|
126
|
+
new ScallopUtils(this.params, {
|
|
127
|
+
constants: this.constants,
|
|
128
|
+
});
|
|
132
129
|
this.indexer =
|
|
133
130
|
instance?.indexer ??
|
|
134
131
|
new ScallopIndexer(this.params, { cache: this.cache });
|
|
@@ -172,15 +169,12 @@ export class ScallopQuery {
|
|
|
172
169
|
* @param force - Whether to force initialization.
|
|
173
170
|
* @param address - ScallopAddress instance.
|
|
174
171
|
*/
|
|
175
|
-
public async init(force: boolean = false
|
|
176
|
-
if (
|
|
177
|
-
this.
|
|
178
|
-
}
|
|
179
|
-
if (force || !this.address.getAddresses()) {
|
|
180
|
-
await this.address.read();
|
|
172
|
+
public async init(force: boolean = false) {
|
|
173
|
+
if (force || !this.constants.isInitialized) {
|
|
174
|
+
await this.constants.init();
|
|
181
175
|
}
|
|
182
176
|
|
|
183
|
-
await this.utils.init(force
|
|
177
|
+
await this.utils.init(force);
|
|
184
178
|
}
|
|
185
179
|
|
|
186
180
|
/* ==================== Core Query Methods ==================== */
|
|
@@ -210,7 +204,7 @@ export class ScallopQuery {
|
|
|
210
204
|
* @return Market pools data.
|
|
211
205
|
*/
|
|
212
206
|
public async getMarketPools(
|
|
213
|
-
poolCoinNames:
|
|
207
|
+
poolCoinNames: string[] = [...this.constants.whitelist.lending],
|
|
214
208
|
args?: {
|
|
215
209
|
coinPrices?: CoinPrices;
|
|
216
210
|
indexer?: boolean;
|
|
@@ -232,7 +226,7 @@ export class ScallopQuery {
|
|
|
232
226
|
* @return Market pool data.
|
|
233
227
|
*/
|
|
234
228
|
public async getMarketPool(
|
|
235
|
-
poolCoinName:
|
|
229
|
+
poolCoinName: string,
|
|
236
230
|
args?: {
|
|
237
231
|
coinPrice?: number;
|
|
238
232
|
indexer?: boolean;
|
|
@@ -261,7 +255,7 @@ export class ScallopQuery {
|
|
|
261
255
|
* @return Market collaterals data.
|
|
262
256
|
*/
|
|
263
257
|
public async getMarketCollaterals(
|
|
264
|
-
collateralCoinNames
|
|
258
|
+
collateralCoinNames: string[] = [...this.constants.whitelist.collateral],
|
|
265
259
|
args?: { indexer?: boolean }
|
|
266
260
|
) {
|
|
267
261
|
return await getMarketCollaterals(this, collateralCoinNames, args?.indexer);
|
|
@@ -275,7 +269,7 @@ export class ScallopQuery {
|
|
|
275
269
|
* @return Market collateral data.
|
|
276
270
|
*/
|
|
277
271
|
public async getMarketCollateral(
|
|
278
|
-
collateralCoinName:
|
|
272
|
+
collateralCoinName: string,
|
|
279
273
|
args?: { indexer?: boolean }
|
|
280
274
|
) {
|
|
281
275
|
return await getMarketCollateral(this, collateralCoinName, args?.indexer);
|
|
@@ -309,7 +303,7 @@ export class ScallopQuery {
|
|
|
309
303
|
* @return All coin amounts.
|
|
310
304
|
*/
|
|
311
305
|
public async getCoinAmounts(
|
|
312
|
-
assetCoinNames?:
|
|
306
|
+
assetCoinNames?: string[],
|
|
313
307
|
ownerAddress: string = this.walletAddress
|
|
314
308
|
) {
|
|
315
309
|
return await getCoinAmounts(this, assetCoinNames, ownerAddress);
|
|
@@ -323,7 +317,7 @@ export class ScallopQuery {
|
|
|
323
317
|
* @return Coin amount.
|
|
324
318
|
*/
|
|
325
319
|
public async getCoinAmount(
|
|
326
|
-
assetCoinName:
|
|
320
|
+
assetCoinName: string,
|
|
327
321
|
ownerAddress: string = this.walletAddress
|
|
328
322
|
) {
|
|
329
323
|
return await getCoinAmount(this, assetCoinName, ownerAddress);
|
|
@@ -337,7 +331,7 @@ export class ScallopQuery {
|
|
|
337
331
|
* @return All market market coin amounts.
|
|
338
332
|
*/
|
|
339
333
|
public async getMarketCoinAmounts(
|
|
340
|
-
marketCoinNames?:
|
|
334
|
+
marketCoinNames?: string[],
|
|
341
335
|
ownerAddress: string = this.walletAddress
|
|
342
336
|
) {
|
|
343
337
|
return await getMarketCoinAmounts(this, marketCoinNames, ownerAddress);
|
|
@@ -351,7 +345,7 @@ export class ScallopQuery {
|
|
|
351
345
|
* @return Market market coin amount.
|
|
352
346
|
*/
|
|
353
347
|
public async getMarketCoinAmount(
|
|
354
|
-
marketCoinName:
|
|
348
|
+
marketCoinName: string,
|
|
355
349
|
ownerAddress: string = this.walletAddress
|
|
356
350
|
) {
|
|
357
351
|
return await getMarketCoinAmount(this, marketCoinName, ownerAddress);
|
|
@@ -363,7 +357,7 @@ export class ScallopQuery {
|
|
|
363
357
|
* @param assetCoinName - Specific support asset coin name.
|
|
364
358
|
* @return Asset coin price.
|
|
365
359
|
*/
|
|
366
|
-
public async getPriceFromPyth(assetCoinName:
|
|
360
|
+
public async getPriceFromPyth(assetCoinName: string) {
|
|
367
361
|
return await getPythPrice(this, assetCoinName);
|
|
368
362
|
}
|
|
369
363
|
|
|
@@ -373,7 +367,7 @@ export class ScallopQuery {
|
|
|
373
367
|
* @param assetCoinNames - Array of supported asset coin names.
|
|
374
368
|
* @return Array of asset coin prices.
|
|
375
369
|
*/
|
|
376
|
-
public async getPricesFromPyth(assetCoinNames:
|
|
370
|
+
public async getPricesFromPyth(assetCoinNames: string[]) {
|
|
377
371
|
return await getPythPrices(this, assetCoinNames);
|
|
378
372
|
}
|
|
379
373
|
|
|
@@ -387,7 +381,7 @@ export class ScallopQuery {
|
|
|
387
381
|
* @return Spools data.
|
|
388
382
|
*/
|
|
389
383
|
public async getSpools(
|
|
390
|
-
stakeMarketCoinNames?:
|
|
384
|
+
stakeMarketCoinNames?: string[],
|
|
391
385
|
args?: {
|
|
392
386
|
marketPools?: MarketPools;
|
|
393
387
|
coinPrices?: CoinPrices;
|
|
@@ -411,7 +405,7 @@ export class ScallopQuery {
|
|
|
411
405
|
* @return Spool data.
|
|
412
406
|
*/
|
|
413
407
|
public async getSpool(
|
|
414
|
-
stakeMarketCoinName:
|
|
408
|
+
stakeMarketCoinName: string,
|
|
415
409
|
args?: {
|
|
416
410
|
marketPool?: MarketPool;
|
|
417
411
|
coinPrices?: CoinPrices;
|
|
@@ -440,7 +434,7 @@ export class ScallopQuery {
|
|
|
440
434
|
* @return Stake accounts data.
|
|
441
435
|
*/
|
|
442
436
|
public async getStakeAccounts(
|
|
443
|
-
stakeMarketCoinName:
|
|
437
|
+
stakeMarketCoinName: string,
|
|
444
438
|
ownerAddress: string = this.walletAddress
|
|
445
439
|
) {
|
|
446
440
|
const allStakeAccount = await this.getAllStakeAccounts(ownerAddress);
|
|
@@ -458,7 +452,7 @@ export class ScallopQuery {
|
|
|
458
452
|
* @return Stake pools data.
|
|
459
453
|
*/
|
|
460
454
|
public async getStakePools(
|
|
461
|
-
stakeMarketCoinNames:
|
|
455
|
+
stakeMarketCoinNames: string[] = [...this.constants.whitelist.spool]
|
|
462
456
|
) {
|
|
463
457
|
const stakePools: StakePools = {};
|
|
464
458
|
for (const stakeMarketCoinName of stakeMarketCoinNames) {
|
|
@@ -482,7 +476,7 @@ export class ScallopQuery {
|
|
|
482
476
|
* @param stakeMarketCoinName - Specific support stake market coin name.
|
|
483
477
|
* @return Stake pool data.
|
|
484
478
|
*/
|
|
485
|
-
public async getStakePool(stakeMarketCoinName:
|
|
479
|
+
public async getStakePool(stakeMarketCoinName: string) {
|
|
486
480
|
return await getStakePool(this, stakeMarketCoinName);
|
|
487
481
|
}
|
|
488
482
|
|
|
@@ -497,7 +491,7 @@ export class ScallopQuery {
|
|
|
497
491
|
* @return Stake reward pools data.
|
|
498
492
|
*/
|
|
499
493
|
public async getStakeRewardPools(
|
|
500
|
-
stakeMarketCoinNames:
|
|
494
|
+
stakeMarketCoinNames: string[] = [...this.constants.whitelist.spool]
|
|
501
495
|
) {
|
|
502
496
|
const stakeRewardPools: StakeRewardPools = {};
|
|
503
497
|
await Promise.allSettled(
|
|
@@ -525,9 +519,7 @@ export class ScallopQuery {
|
|
|
525
519
|
* @param marketCoinName - Specific support stake market coin name.
|
|
526
520
|
* @return Stake reward pool data.
|
|
527
521
|
*/
|
|
528
|
-
public async getStakeRewardPool(
|
|
529
|
-
stakeMarketCoinName: SupportStakeMarketCoins
|
|
530
|
-
) {
|
|
522
|
+
public async getStakeRewardPool(stakeMarketCoinName: string) {
|
|
531
523
|
return await getStakeRewardPool(this, stakeMarketCoinName);
|
|
532
524
|
}
|
|
533
525
|
|
|
@@ -539,7 +531,7 @@ export class ScallopQuery {
|
|
|
539
531
|
* @return Borrow incentive pools data.
|
|
540
532
|
*/
|
|
541
533
|
public async getBorrowIncentivePools(
|
|
542
|
-
coinNames
|
|
534
|
+
coinNames: string[] = [...this.constants.whitelist.lending],
|
|
543
535
|
args?: {
|
|
544
536
|
coinPrices?: CoinPrices;
|
|
545
537
|
indexer?: boolean;
|
|
@@ -564,7 +556,7 @@ export class ScallopQuery {
|
|
|
564
556
|
*/
|
|
565
557
|
public async getBorrowIncentiveAccounts(
|
|
566
558
|
obligationId: string | SuiObjectRef,
|
|
567
|
-
coinNames?:
|
|
559
|
+
coinNames?: string[]
|
|
568
560
|
) {
|
|
569
561
|
return await queryBorrowIncentiveAccounts(this, obligationId, coinNames);
|
|
570
562
|
}
|
|
@@ -578,7 +570,7 @@ export class ScallopQuery {
|
|
|
578
570
|
* @return All lending and spool infomation.
|
|
579
571
|
*/
|
|
580
572
|
public async getLendings(
|
|
581
|
-
poolCoinNames?:
|
|
573
|
+
poolCoinNames?: string[],
|
|
582
574
|
ownerAddress: string = this.walletAddress,
|
|
583
575
|
args?: {
|
|
584
576
|
indexer?: boolean;
|
|
@@ -605,7 +597,7 @@ export class ScallopQuery {
|
|
|
605
597
|
* @return Lending pool data.
|
|
606
598
|
*/
|
|
607
599
|
public async getLending(
|
|
608
|
-
poolCoinName:
|
|
600
|
+
poolCoinName: string,
|
|
609
601
|
ownerAddress: string = this.walletAddress,
|
|
610
602
|
args?: { indexer?: boolean }
|
|
611
603
|
) {
|
|
@@ -755,7 +747,7 @@ export class ScallopQuery {
|
|
|
755
747
|
* @param sCoinName - Supported sCoin name
|
|
756
748
|
* @returns Total Supply
|
|
757
749
|
*/
|
|
758
|
-
public async getSCoinTotalSupply(sCoinName:
|
|
750
|
+
public async getSCoinTotalSupply(sCoinName: string) {
|
|
759
751
|
return await getSCoinTotalSupply(this, sCoinName);
|
|
760
752
|
}
|
|
761
753
|
|
|
@@ -767,7 +759,7 @@ export class ScallopQuery {
|
|
|
767
759
|
* @return All market sCoin amounts.
|
|
768
760
|
*/
|
|
769
761
|
public async getSCoinAmounts(
|
|
770
|
-
sCoinNames?:
|
|
762
|
+
sCoinNames?: string[],
|
|
771
763
|
ownerAddress: string = this.walletAddress
|
|
772
764
|
) {
|
|
773
765
|
return await getSCoinAmounts(this, sCoinNames, ownerAddress);
|
|
@@ -781,7 +773,7 @@ export class ScallopQuery {
|
|
|
781
773
|
* @return sCoin amount.
|
|
782
774
|
*/
|
|
783
775
|
public async getSCoinAmount(
|
|
784
|
-
sCoinName:
|
|
776
|
+
sCoinName: string | string,
|
|
785
777
|
ownerAddress: string = this.walletAddress
|
|
786
778
|
) {
|
|
787
779
|
const parsedSCoinName = this.utils.parseSCoinName(sCoinName);
|
|
@@ -795,10 +787,7 @@ export class ScallopQuery {
|
|
|
795
787
|
* @param assetCoinNames
|
|
796
788
|
* @returns
|
|
797
789
|
*/
|
|
798
|
-
public async getSCoinSwapRate(
|
|
799
|
-
fromSCoin: SupportSCoin,
|
|
800
|
-
toSCoin: SupportSCoin
|
|
801
|
-
) {
|
|
790
|
+
public async getSCoinSwapRate(fromSCoin: string, toSCoin: string) {
|
|
802
791
|
return await getSCoinSwapRate(this, fromSCoin, toSCoin);
|
|
803
792
|
}
|
|
804
793
|
|
|
@@ -806,7 +795,7 @@ export class ScallopQuery {
|
|
|
806
795
|
* Get flashloan fee for specified assets
|
|
807
796
|
*/
|
|
808
797
|
public async getFlashLoanFees(
|
|
809
|
-
assetCoinNames:
|
|
798
|
+
assetCoinNames: string[] = [...this.constants.whitelist.lending]
|
|
810
799
|
) {
|
|
811
800
|
return await getFlashLoanFees(this, assetCoinNames);
|
|
812
801
|
}
|
|
@@ -814,14 +803,14 @@ export class ScallopQuery {
|
|
|
814
803
|
/**
|
|
815
804
|
* Get supply limit of lending pool
|
|
816
805
|
*/
|
|
817
|
-
public async getPoolSupplyLimit(poolName:
|
|
806
|
+
public async getPoolSupplyLimit(poolName: string) {
|
|
818
807
|
return await getSupplyLimit(this.utils, poolName);
|
|
819
808
|
}
|
|
820
809
|
|
|
821
810
|
/**
|
|
822
811
|
* Get borrow limit of borrow pool
|
|
823
812
|
*/
|
|
824
|
-
public async getPoolBorrowLimit(poolName:
|
|
813
|
+
public async getPoolBorrowLimit(poolName: string) {
|
|
825
814
|
return await getBorrowLimit(this.utils, poolName);
|
|
826
815
|
}
|
|
827
816
|
|
|
@@ -835,7 +824,7 @@ export class ScallopQuery {
|
|
|
835
824
|
/**
|
|
836
825
|
* Check if asset is an isolated asset
|
|
837
826
|
*/
|
|
838
|
-
public async isIsolatedAsset(assetCoinName:
|
|
827
|
+
public async isIsolatedAsset(assetCoinName: string) {
|
|
839
828
|
return isIsolatedAsset(this.utils, assetCoinName);
|
|
840
829
|
}
|
|
841
830
|
|
|
@@ -844,7 +833,7 @@ export class ScallopQuery {
|
|
|
844
833
|
* @param coinName
|
|
845
834
|
* @returns price data
|
|
846
835
|
*/
|
|
847
|
-
public async getCoinPriceByIndexer(poolName:
|
|
836
|
+
public async getCoinPriceByIndexer(poolName: string) {
|
|
848
837
|
return this.indexer.getCoinPrice(poolName);
|
|
849
838
|
}
|
|
850
839
|
|
|
@@ -877,10 +866,9 @@ export class ScallopQuery {
|
|
|
877
866
|
* Query all address (lending pool, collateral pool, borrow dynamics, interest models, etc.) of all pool
|
|
878
867
|
* @returns
|
|
879
868
|
*/
|
|
880
|
-
public async getPoolAddresses(
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
return getAllAddresses(this, pools);
|
|
869
|
+
public async getPoolAddresses(apiAddressId = this.address.getId()) {
|
|
870
|
+
if (!apiAddressId) throw new Error('apiAddressId is required');
|
|
871
|
+
return getPoolAddresses(apiAddressId);
|
|
884
872
|
}
|
|
885
873
|
|
|
886
874
|
/**
|
|
@@ -915,15 +903,24 @@ export class ScallopQuery {
|
|
|
915
903
|
getAssetOracles(this.utils, 'secondary'),
|
|
916
904
|
]);
|
|
917
905
|
|
|
918
|
-
return
|
|
906
|
+
return [...this.constants.whitelist.lending].reduce(
|
|
919
907
|
(acc, pool) => {
|
|
920
908
|
acc[pool] = {
|
|
921
|
-
primary: primary?.[pool] ?? [],
|
|
922
|
-
secondary: secondary?.[pool] ?? [],
|
|
909
|
+
primary: (primary?.[pool] ?? []) as SupportOracleType[],
|
|
910
|
+
secondary: (secondary?.[pool] ?? []) as SupportOracleType[],
|
|
923
911
|
};
|
|
924
912
|
return acc;
|
|
925
913
|
},
|
|
926
|
-
{} as Record<
|
|
914
|
+
{} as Record<string, xOracleRules>
|
|
927
915
|
);
|
|
928
916
|
}
|
|
917
|
+
|
|
918
|
+
/**
|
|
919
|
+
* Get switchboard on-demand aggregator object id based on coinType
|
|
920
|
+
* @param coinType
|
|
921
|
+
* @returns
|
|
922
|
+
*/
|
|
923
|
+
public async getSwitchboardOnDemandAggregatorObjectIds(coinName: string[]) {
|
|
924
|
+
return await getOnDemandAggObjectIds(this, coinName);
|
|
925
|
+
}
|
|
929
926
|
}
|