@scallop-io/sui-scallop-sdk 1.3.4-alpha.6 → 1.3.4-hotfix

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.
Files changed (107) hide show
  1. package/dist/builders/borrowIncentiveBuilder.d.ts +12 -0
  2. package/dist/builders/coreBuilder.d.ts +12 -0
  3. package/dist/builders/index.d.ts +12 -0
  4. package/dist/builders/loyaltyProgramBuilder.d.ts +12 -0
  5. package/dist/builders/oracle.d.ts +14 -0
  6. package/dist/builders/referralBuilder.d.ts +12 -0
  7. package/dist/builders/sCoinBuilder.d.ts +4 -0
  8. package/dist/builders/spoolBuilder.d.ts +12 -0
  9. package/dist/builders/vescaBuilder.d.ts +25 -0
  10. package/dist/constants/cache.d.ts +14 -0
  11. package/dist/constants/common.d.ts +20 -0
  12. package/dist/constants/enum.d.ts +13 -0
  13. package/dist/constants/flashloan.d.ts +2 -0
  14. package/dist/constants/index.d.ts +5 -0
  15. package/dist/constants/pyth.d.ts +3 -0
  16. package/dist/constants/queryKeys.d.ts +58 -0
  17. package/dist/constants/testAddress.d.ts +2 -0
  18. package/dist/constants/tokenBucket.d.ts +2 -0
  19. package/dist/constants/vesca.d.ts +5 -0
  20. package/dist/index.d.ts +3 -0
  21. package/dist/index.js +2317 -2481
  22. package/dist/index.js.map +1 -1
  23. package/dist/index.mjs +2316 -2470
  24. package/dist/index.mjs.map +1 -1
  25. package/dist/models/index.d.ts +8 -0
  26. package/dist/models/scallop.d.ts +74 -0
  27. package/dist/models/scallopAddress.d.ts +150 -0
  28. package/dist/models/scallopBuilder.d.ts +89 -0
  29. package/dist/models/scallopCache.d.ts +74 -0
  30. package/dist/models/scallopClient.d.ts +321 -0
  31. package/dist/models/scallopIndexer.d.ts +89 -0
  32. package/dist/models/scallopPrice.d.ts +0 -0
  33. package/dist/models/scallopQuery.d.ts +474 -0
  34. package/dist/models/scallopUtils.d.ts +217 -0
  35. package/dist/queries/borrowIncentiveQuery.d.ts +61 -0
  36. package/dist/queries/coreQuery.d.ts +167 -0
  37. package/dist/queries/index.d.ts +8 -0
  38. package/dist/queries/isolatedAsset.d.ts +14 -0
  39. package/dist/queries/loyaltyProgramQuery.d.ts +10 -0
  40. package/dist/queries/portfolioQuery.d.ts +73 -0
  41. package/dist/queries/priceQuery.d.ts +16 -0
  42. package/dist/queries/referralQuery.d.ts +7 -0
  43. package/dist/queries/sCoinQuery.d.ts +41 -0
  44. package/dist/queries/spoolQuery.d.ts +70 -0
  45. package/dist/queries/supplyLimit.d.ts +9 -0
  46. package/dist/queries/vescaQuery.d.ts +36 -0
  47. package/dist/types/address.d.ts +107 -0
  48. package/dist/types/builder/borrowIncentive.d.ts +35 -0
  49. package/dist/types/builder/core.d.ts +56 -0
  50. package/dist/types/builder/index.d.ts +24 -0
  51. package/dist/types/builder/loyaltyProgram.d.ts +23 -0
  52. package/dist/types/builder/referral.d.ts +30 -0
  53. package/dist/types/builder/sCoin.d.ts +37 -0
  54. package/dist/types/builder/spool.d.ts +29 -0
  55. package/dist/types/builder/vesca.d.ts +51 -0
  56. package/dist/types/constant/common.d.ts +24 -0
  57. package/dist/types/constant/enum.d.ts +48 -0
  58. package/dist/types/constant/index.d.ts +2 -0
  59. package/dist/types/index.d.ts +6 -0
  60. package/dist/types/model.d.ts +54 -0
  61. package/dist/types/query/borrowIncentive.d.ts +124 -0
  62. package/dist/types/query/core.d.ts +361 -0
  63. package/dist/types/query/index.d.ts +7 -0
  64. package/dist/types/query/loyaltyProgram.d.ts +5 -0
  65. package/dist/types/query/portfolio.d.ts +115 -0
  66. package/dist/types/query/sCoin.d.ts +1 -0
  67. package/dist/types/query/spool.d.ts +122 -0
  68. package/dist/types/query/vesca.d.ts +26 -0
  69. package/dist/types/utils.d.ts +9 -0
  70. package/dist/utils/builder.d.ts +15 -0
  71. package/dist/utils/index.d.ts +5 -0
  72. package/dist/utils/indexer.d.ts +17 -0
  73. package/dist/utils/query.d.ts +62 -0
  74. package/dist/utils/tokenBucket.d.ts +11 -0
  75. package/dist/utils/util.d.ts +26 -0
  76. package/package.json +2 -2
  77. package/src/builders/loyaltyProgramBuilder.ts +1 -1
  78. package/src/constants/common.ts +2 -1
  79. package/src/constants/enum.ts +0 -8
  80. package/src/constants/index.ts +0 -7
  81. package/src/constants/pyth.ts +0 -19
  82. package/src/constants/queryKeys.ts +5 -1
  83. package/src/constants/tokenBucket.ts +1 -1
  84. package/src/models/scallop.ts +2 -3
  85. package/src/models/scallopAddress.ts +2 -2
  86. package/src/models/scallopBuilder.ts +3 -4
  87. package/src/models/scallopCache.ts +1 -1
  88. package/src/models/scallopClient.ts +26 -27
  89. package/src/models/scallopPrice.ts +0 -0
  90. package/src/models/scallopQuery.ts +17 -63
  91. package/src/models/scallopUtils.ts +96 -96
  92. package/src/queries/borrowIncentiveQuery.ts +13 -6
  93. package/src/queries/coreQuery.ts +23 -38
  94. package/src/queries/index.ts +5 -8
  95. package/src/queries/{isolatedAssetQuery.ts → isolatedAsset.ts} +2 -2
  96. package/src/queries/loyaltyProgramQuery.ts +1 -1
  97. package/src/queries/portfolioQuery.ts +34 -55
  98. package/src/queries/spoolQuery.ts +17 -17
  99. package/src/queries/{supplyLimitQuery.ts → supplyLimit.ts} +2 -2
  100. package/src/types/query/index.ts +4 -4
  101. package/src/types/utils.ts +0 -13
  102. package/src/utils/tokenBucket.ts +1 -2
  103. package/src/utils/util.ts +1 -2
  104. package/src/constants/coinGecko.ts +0 -18
  105. package/src/constants/poolAddress.ts +0 -94
  106. package/src/constants/rpc.ts +0 -16
  107. package/src/models/suiKit.ts +0 -11
@@ -47,9 +47,6 @@ import {
47
47
  SupportBorrowIncentiveCoins,
48
48
  SupportSCoin,
49
49
  ScallopQueryInstanceParams,
50
- MarketPool,
51
- CoinPrices,
52
- MarketPools,
53
50
  } from '../types';
54
51
  import { ScallopAddress } from './scallopAddress';
55
52
  import { ScallopUtils } from './scallopUtils';
@@ -64,13 +61,9 @@ import {
64
61
  getSCoinTotalSupply,
65
62
  } from 'src/queries/sCoinQuery';
66
63
  import { normalizeSuiAddress } from '@mysten/sui/utils';
67
- import {
68
- getSupplyLimit,
69
- getIsolatedAssets,
70
- isIsolatedAsset,
71
- } from 'src/queries';
64
+ import { getSupplyLimit } from 'src/queries/supplyLimit';
72
65
  import { withIndexerFallback } from 'src/utils/indexer';
73
- import { newSuiKit } from './suiKit';
66
+ import { getIsolatedAssets, isIsolatedAsset } from 'src/queries/isolatedAsset';
74
67
 
75
68
  /**
76
69
  * @description
@@ -100,10 +93,10 @@ export class ScallopQuery {
100
93
  ) {
101
94
  this.params = params;
102
95
  this.suiKit =
103
- instance?.suiKit ?? instance?.utils?.suiKit ?? newSuiKit(params);
96
+ instance?.suiKit ?? instance?.utils?.suiKit ?? new SuiKit(params);
104
97
 
105
98
  this.walletAddress = normalizeSuiAddress(
106
- params.walletAddress ?? this.suiKit.currentAddress()
99
+ params.walletAddress || this.suiKit.currentAddress()
107
100
  );
108
101
 
109
102
  if (instance?.utils) {
@@ -118,7 +111,7 @@ export class ScallopQuery {
118
111
  );
119
112
  this.address = new ScallopAddress(
120
113
  {
121
- id: params?.addressesId ?? ADDRESSES_ID,
114
+ id: params?.addressesId || ADDRESSES_ID,
122
115
  network: params?.networkType,
123
116
  forceInterface: params?.forceAddressesInterface,
124
117
  },
@@ -190,11 +183,8 @@ export class ScallopQuery {
190
183
  * @param indexer - Whether to use indexer.
191
184
  * @return Market data.
192
185
  */
193
- public async queryMarket(
194
- indexer: boolean = false,
195
- args?: { coinPrices: CoinPrices }
196
- ) {
197
- return await queryMarket(this, indexer, args?.coinPrices);
186
+ public async queryMarket(indexer: boolean = false) {
187
+ return await queryMarket(this, indexer);
198
188
  }
199
189
 
200
190
  /**
@@ -210,12 +200,9 @@ export class ScallopQuery {
210
200
  */
211
201
  public async getMarketPools(
212
202
  poolCoinNames?: SupportPoolCoins[],
213
- indexer: boolean = false,
214
- args?: {
215
- coinPrices?: CoinPrices;
216
- }
203
+ indexer: boolean = false
217
204
  ) {
218
- return await getMarketPools(this, poolCoinNames, indexer, args?.coinPrices);
205
+ return await getMarketPools(this, poolCoinNames, indexer);
219
206
  }
220
207
 
221
208
  /**
@@ -227,19 +214,9 @@ export class ScallopQuery {
227
214
  */
228
215
  public async getMarketPool(
229
216
  poolCoinName: SupportPoolCoins,
230
- indexer: boolean = false,
231
- args?: {
232
- marketObject?: SuiObjectData | null;
233
- coinPrice?: number;
234
- }
217
+ indexer: boolean = false
235
218
  ) {
236
- return await getMarketPool(
237
- this,
238
- poolCoinName,
239
- indexer,
240
- args?.marketObject,
241
- args?.coinPrice
242
- );
219
+ return await getMarketPool(this, poolCoinName, indexer);
243
220
  }
244
221
 
245
222
  /**
@@ -381,19 +358,9 @@ export class ScallopQuery {
381
358
  */
382
359
  public async getSpools(
383
360
  stakeMarketCoinNames?: SupportStakeMarketCoins[],
384
- indexer: boolean = false,
385
- args?: {
386
- marketPools?: MarketPools;
387
- coinPrices?: CoinPrices;
388
- }
361
+ indexer: boolean = false
389
362
  ) {
390
- return await getSpools(
391
- this,
392
- stakeMarketCoinNames,
393
- indexer,
394
- args?.marketPools,
395
- args?.coinPrices
396
- );
363
+ return await getSpools(this, stakeMarketCoinNames, indexer);
397
364
  }
398
365
 
399
366
  /**
@@ -405,16 +372,9 @@ export class ScallopQuery {
405
372
  */
406
373
  public async getSpool(
407
374
  stakeMarketCoinName: SupportStakeMarketCoins,
408
- indexer: boolean = false,
409
- args?: { marketPool?: MarketPool; coinPrices?: CoinPrices }
375
+ indexer: boolean = false
410
376
  ) {
411
- return await getSpool(
412
- this,
413
- stakeMarketCoinName,
414
- indexer,
415
- args?.marketPool,
416
- args?.coinPrices
417
- );
377
+ return await getSpool(this, stakeMarketCoinName, indexer);
418
378
  }
419
379
 
420
380
  /**
@@ -535,15 +495,9 @@ export class ScallopQuery {
535
495
  */
536
496
  public async getBorrowIncentivePools(
537
497
  coinNames?: SupportBorrowIncentiveCoins[],
538
- indexer: boolean = false,
539
- args?: { coinPrices: CoinPrices }
498
+ indexer: boolean = false
540
499
  ) {
541
- return await getBorrowIncentivePools(
542
- this,
543
- coinNames,
544
- indexer,
545
- args?.coinPrices
546
- );
500
+ return await getBorrowIncentivePools(this, coinNames, indexer);
547
501
  }
548
502
 
549
503
  /**
@@ -18,11 +18,8 @@ import {
18
18
  SUPPORT_SCOIN,
19
19
  sCoinIds,
20
20
  suiBridgeCoins,
21
- COIN_GECKGO_IDS,
22
- POOL_ADDRESSES,
23
- sCoinTypeToName,
24
21
  } from '../constants';
25
- import { getPythPrices, queryObligation } from '../queries';
22
+ import { getPythPrice, queryObligation } from '../queries';
26
23
  import {
27
24
  parseDataFromPythPriceFeed,
28
25
  isMarketCoin,
@@ -31,7 +28,7 @@ import {
31
28
  isSuiBridgeAsset,
32
29
  isWormholeAsset,
33
30
  } from '../utils';
34
- import { PYTH_ENDPOINTS, PYTH_FEED_IDS } from 'src/constants/pyth';
31
+ import { PYTH_ENDPOINTS } from 'src/constants/pyth';
35
32
  import { ScallopCache } from './scallopCache';
36
33
  import { DEFAULT_CACHE_OPTIONS } from 'src/constants/cache';
37
34
  import type {
@@ -42,16 +39,15 @@ import type {
42
39
  SupportStakeMarketCoins,
43
40
  SupportBorrowIncentiveCoins,
44
41
  CoinPrices,
42
+ PriceMap,
45
43
  CoinWrappedType,
46
44
  SupportSCoin,
47
45
  ScallopUtilsInstanceParams,
48
46
  SupportSuiBridgeCoins,
49
47
  SupportWormholeCoins,
50
- PoolAddressInfo,
51
48
  } from '../types';
52
49
  import { queryKeys } from 'src/constants';
53
50
  import type { SuiObjectArg, SuiTxArg, SuiTxBlock } from '@scallop-io/sui-kit';
54
- import { newSuiKit } from './suiKit';
55
51
 
56
52
  /**
57
53
  * @description
@@ -73,6 +69,7 @@ export class ScallopUtils {
73
69
  public address: ScallopAddress;
74
70
  public cache: ScallopCache;
75
71
  public walletAddress: string;
72
+ private _priceMap: PriceMap = new Map();
76
73
 
77
74
  public constructor(
78
75
  params: ScallopUtilsParams,
@@ -83,7 +80,9 @@ export class ScallopUtils {
83
80
  ...params,
84
81
  };
85
82
  this.suiKit =
86
- instance?.suiKit ?? instance?.address?.cache._suiKit ?? newSuiKit(params);
83
+ instance?.suiKit ??
84
+ instance?.address?.cache._suiKit ??
85
+ new SuiKit(params);
87
86
 
88
87
  this.walletAddress = params.walletAddress ?? this.suiKit.currentAddress();
89
88
 
@@ -101,7 +100,7 @@ export class ScallopUtils {
101
100
  instance?.address ??
102
101
  new ScallopAddress(
103
102
  {
104
- id: params?.addressesId ?? ADDRESSES_ID,
103
+ id: params?.addressesId || ADDRESSES_ID,
105
104
  network: params?.networkType,
106
105
  forceInterface: params?.forceAddressesInterface,
107
106
  },
@@ -225,7 +224,6 @@ export class ScallopUtils {
225
224
  return undefined;
226
225
  }
227
226
  }
228
-
229
227
  /**
230
228
  * Convert sCoin name into sCoin type
231
229
  * @param sCoinName
@@ -235,15 +233,6 @@ export class ScallopUtils {
235
233
  return sCoinIds[sCoinName];
236
234
  }
237
235
 
238
- /**
239
- * Convert sCoinType into sCoin name
240
- * @param sCoinType
241
- * @returns sCoin name
242
- */
243
- public parseSCoinNameFromType(sCoinType: string) {
244
- return sCoinTypeToName[sCoinType];
245
- }
246
-
247
236
  /**
248
237
  * Convert sCoin name into its underlying coin type
249
238
  * @param sCoinName
@@ -272,7 +261,7 @@ export class ScallopUtils {
272
261
  */
273
262
  public parseMarketCoinType(coinName: SupportCoins) {
274
263
  const protocolObjectId =
275
- this.address.get('core.object') ?? PROTOCOL_OBJECT_ID;
264
+ this.address.get('core.object') || PROTOCOL_OBJECT_ID;
276
265
  const coinType = this.parseCoinType(coinName);
277
266
  return `${protocolObjectId}::reserve::MarketCoin<${coinType}>`;
278
267
  }
@@ -301,7 +290,7 @@ export class ScallopUtils {
301
290
  const coinTypeRegex = new RegExp(`((0x[^:]+::[^:]+::[^<>]+))(?![^<>]*<)`);
302
291
  const coinTypeMatch = coinType.match(coinTypeRegex);
303
292
  const isMarketCoinType = coinType.includes('reserve::MarketCoin');
304
- coinType = coinTypeMatch?.[1] ?? coinType;
293
+ coinType = coinTypeMatch?.[1] || coinType;
305
294
 
306
295
  const wormHoleCoinTypeMap: Record<string, SupportAssetCoins> = {
307
296
  [`${
@@ -439,7 +428,7 @@ export class ScallopUtils {
439
428
  coinType: string = SUI_TYPE_ARG,
440
429
  ownerAddress?: string
441
430
  ) {
442
- ownerAddress = ownerAddress ?? this.suiKit.currentAddress();
431
+ ownerAddress = ownerAddress || this.suiKit.currentAddress();
443
432
  const coins = await this.suiKit.suiInteractor.selectCoins(
444
433
  ownerAddress,
445
434
  amount,
@@ -519,68 +508,100 @@ export class ScallopUtils {
519
508
  * @return Asset coin price.
520
509
  */
521
510
  public async getCoinPrices(
522
- _: SupportAssetCoins[] = [
511
+ assetCoinNames: SupportAssetCoins[] = [
523
512
  ...new Set([...SUPPORT_POOLS, ...SUPPORT_COLLATERALS]),
524
513
  ] as SupportAssetCoins[]
525
514
  ) {
526
- let coinPrices: CoinPrices = {};
527
-
528
- const endpoints =
529
- this.params.pythEndpoints ??
530
- PYTH_ENDPOINTS[this.isTestnet ? 'testnet' : 'mainnet'];
531
-
532
- const failedRequests: Set<SupportAssetCoins> = new Set([
533
- ...SUPPORT_POOLS,
534
- ...SUPPORT_COLLATERALS,
535
- ]);
536
-
537
- for (const endpoint of endpoints) {
538
- const priceIdPairs = Array.from(failedRequests.values()).reduce(
539
- (acc, coinName) => {
540
- const priceId = this.address.get(
541
- `core.coins.${coinName}.oracle.pyth.feed`
542
- );
543
- acc.push([coinName, priceId]);
544
- return acc;
545
- },
546
- [] as [string, string][]
547
- );
515
+ const coinPrices: CoinPrices = {};
516
+ const existPricesCoinNames: SupportAssetCoins[] = [];
517
+ const lackPricesCoinNames: SupportAssetCoins[] = [];
518
+
519
+ assetCoinNames.forEach((assetCoinName) => {
520
+ if (
521
+ this._priceMap.has(assetCoinName) &&
522
+ Date.now() - this._priceMap.get(assetCoinName)!.publishTime < 1000 * 60
523
+ ) {
524
+ existPricesCoinNames.push(assetCoinName);
525
+ } else {
526
+ lackPricesCoinNames.push(assetCoinName);
527
+ this.cache.queryClient.invalidateQueries({
528
+ queryKey: queryKeys.oracle.getPythLatestPriceFeed(
529
+ this.address.get(`core.coins.${assetCoinName}.oracle.pyth.feed`)
530
+ ),
531
+ });
532
+ }
533
+ });
548
534
 
549
- const priceIds = priceIdPairs.map(([_, priceId]) => priceId);
535
+ if (existPricesCoinNames.length > 0) {
536
+ for (const coinName of existPricesCoinNames) {
537
+ coinPrices[coinName] = this._priceMap.get(coinName)!.price;
538
+ }
539
+ }
550
540
 
551
- const pythConnection = new SuiPriceServiceConnection(endpoint, {
552
- timeout: 2000,
553
- });
541
+ if (lackPricesCoinNames.length > 0) {
542
+ const endpoints =
543
+ this.params.pythEndpoints ??
544
+ PYTH_ENDPOINTS[this.isTestnet ? 'testnet' : 'mainnet'];
554
545
 
555
- try {
556
- const feeds = await this.cache.queryClient.fetchQuery({
557
- queryKey: queryKeys.oracle.getPythLatestPriceFeeds(),
558
- queryFn: async () => {
559
- return await pythConnection.getLatestPriceFeeds(priceIds);
546
+ const failedRequests: Set<SupportAssetCoins> = new Set(
547
+ lackPricesCoinNames
548
+ );
549
+
550
+ for (const endpoint of endpoints) {
551
+ const priceIds = Array.from(failedRequests.values()).reduce(
552
+ (acc, coinName) => {
553
+ const priceId = this.address.get(
554
+ `core.coins.${coinName}.oracle.pyth.feed`
555
+ );
556
+ acc[coinName] = priceId;
557
+ return acc;
560
558
  },
561
- staleTime: 30000,
562
- gcTime: 30000,
563
- });
564
- if (feeds) {
565
- feeds.forEach((feed, idx) => {
566
- const coinName = priceIdPairs[idx][0] as SupportAssetCoins;
567
- const data = parseDataFromPythPriceFeed(feed, this.address);
568
- coinPrices[coinName as SupportAssetCoins] = data.price;
569
- failedRequests.delete(coinName as SupportAssetCoins); // remove success price feed to prevent duplicate request on the next endpoint
570
- });
571
- }
572
- } catch (e: any) {
573
- console.error(e.message);
559
+ {} as Record<SupportAssetCoins, string>
560
+ );
561
+
562
+ await Promise.allSettled(
563
+ Object.entries(priceIds).map(async ([coinName, priceId]) => {
564
+ const pythConnection = new SuiPriceServiceConnection(endpoint);
565
+ try {
566
+ const feed = await this.cache.queryClient.fetchQuery({
567
+ queryKey: queryKeys.oracle.getPythLatestPriceFeed(priceId),
568
+ queryFn: async () => {
569
+ return (
570
+ (await pythConnection.getLatestPriceFeeds([priceId])) ?? []
571
+ );
572
+ },
573
+ });
574
+ if (feed[0]) {
575
+ const data = parseDataFromPythPriceFeed(feed[0], this.address);
576
+ this._priceMap.set(coinName as SupportAssetCoins, {
577
+ price: data.price,
578
+ publishTime: data.publishTime,
579
+ });
580
+ coinPrices[coinName as SupportAssetCoins] = data.price;
581
+ }
582
+ failedRequests.delete(coinName as SupportAssetCoins); // remove success price feed to prevent duplicate request on the next endpoint
583
+ } catch (e) {
584
+ console.warn(
585
+ `Failed to get price ${coinName} feeds with endpoint ${endpoint}: ${e}`
586
+ );
587
+ }
588
+ })
589
+ );
590
+ if (failedRequests.size === 0) break;
574
591
  }
575
- if (failedRequests.size === 0) break;
576
- }
577
592
 
578
- if (failedRequests.size > 0) {
579
- coinPrices = {
580
- ...coinPrices,
581
- ...(await getPythPrices(this, Array.from(failedRequests.values()))),
582
- };
583
- failedRequests.clear();
593
+ if (failedRequests.size > 0) {
594
+ await Promise.allSettled(
595
+ Array.from(failedRequests.values()).map(async (coinName) => {
596
+ const price = await getPythPrice(this, coinName);
597
+ this._priceMap.set(coinName, {
598
+ price: price,
599
+ publishTime: Date.now(),
600
+ });
601
+ coinPrices[coinName] = price;
602
+ })
603
+ );
604
+ }
584
605
  }
585
606
 
586
607
  return coinPrices;
@@ -649,25 +670,4 @@ export class ScallopUtils {
649
670
  }
650
671
  return findClosestUnlockRound(newUnlockAtInSecondTimestamp);
651
672
  }
652
-
653
- /**
654
- * Get detailed contract address and price id information for supported pool in Scallop
655
- * @returns Supported pool informations
656
- */
657
- public getSupportedPoolAddresses(): PoolAddressInfo[] {
658
- return SUPPORT_POOLS.map((poolName) => {
659
- const sCoinName = this.parseSCoinName(poolName)!;
660
- return {
661
- name: this.parseSymbol(poolName),
662
- coingeckoId: COIN_GECKGO_IDS[poolName],
663
- decimal: coinDecimals[poolName],
664
- pythFeedId: PYTH_FEED_IDS[poolName],
665
- ...POOL_ADDRESSES[poolName],
666
- sCoinAddress: sCoinIds[sCoinName],
667
- marketCoinAddress: this.parseMarketCoinType(poolName),
668
- coinAddress: this.parseCoinType(poolName),
669
- sCoinName: sCoinName ? this.parseSymbol(sCoinName) : undefined,
670
- };
671
- });
672
- }
673
673
  }
@@ -1,5 +1,8 @@
1
1
  import { normalizeStructTag } from '@mysten/sui/utils';
2
- import { SUPPORT_BORROW_INCENTIVE_POOLS } from '../constants';
2
+ import {
3
+ SUPPORT_BORROW_INCENTIVE_POOLS,
4
+ SUPPORT_BORROW_INCENTIVE_REWARDS,
5
+ } from '../constants';
3
6
  import {
4
7
  parseOriginBorrowIncentivePoolData,
5
8
  parseOriginBorrowIncentiveAccountData,
@@ -16,7 +19,6 @@ import type {
16
19
  BorrowIncentivePoolPoints,
17
20
  OptionalKeys,
18
21
  BorrowIncentivePool,
19
- CoinPrices,
20
22
  } from '../types';
21
23
  import BigNumber from 'bignumber.js';
22
24
 
@@ -54,12 +56,17 @@ export const getBorrowIncentivePools = async (
54
56
  borrowIncentiveCoinNames: SupportBorrowIncentiveCoins[] = [
55
57
  ...SUPPORT_BORROW_INCENTIVE_POOLS,
56
58
  ],
57
- indexer: boolean = false,
58
- coinPrices?: CoinPrices
59
+ indexer: boolean = false
59
60
  ) => {
60
61
  const borrowIncentivePools: BorrowIncentivePools = {};
61
62
 
62
- coinPrices = coinPrices ?? (await query.utils.getCoinPrices()) ?? {};
63
+ const coinPrices =
64
+ (await query.utils.getCoinPrices([
65
+ ...new Set([
66
+ ...borrowIncentiveCoinNames,
67
+ ...SUPPORT_BORROW_INCENTIVE_REWARDS,
68
+ ]),
69
+ ])) ?? {};
63
70
 
64
71
  if (indexer) {
65
72
  const borrowIncentivePoolsIndexer =
@@ -67,7 +74,7 @@ export const getBorrowIncentivePools = async (
67
74
 
68
75
  const updateBorrowIncentivePool = (pool: BorrowIncentivePool) => {
69
76
  if (!borrowIncentiveCoinNames.includes(pool.coinName)) return;
70
- pool.coinPrice = coinPrices[pool.coinName] ?? pool.coinPrice;
77
+ pool.coinPrice = coinPrices[pool.coinName] || pool.coinPrice;
71
78
  borrowIncentivePools[pool.coinName] = pool;
72
79
  };
73
80