@scallop-io/sui-scallop-sdk 1.4.15-rc.3 → 1.4.17

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 (71) hide show
  1. package/dist/constants/common.d.ts +6 -6
  2. package/dist/constants/enum.d.ts +2 -2
  3. package/dist/constants/index.d.ts +0 -1
  4. package/dist/constants/poolAddress.d.ts +2 -1
  5. package/dist/constants/queryKeys.d.ts +3 -4
  6. package/dist/index.d.ts +0 -1
  7. package/dist/index.js +2019 -1634
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.mjs +2087 -1697
  10. package/dist/index.mjs.map +1 -1
  11. package/dist/models/scallop.d.ts +1 -2
  12. package/dist/models/scallopBuilder.d.ts +3 -2
  13. package/dist/models/scallopCache.d.ts +18 -12
  14. package/dist/models/scallopClient.d.ts +1 -1
  15. package/dist/models/scallopIndexer.d.ts +1 -1
  16. package/dist/models/scallopQuery.d.ts +96 -11
  17. package/dist/models/scallopUtils.d.ts +4 -4
  18. package/dist/queries/borrowIncentiveQuery.d.ts +6 -1
  19. package/dist/queries/coreQuery.d.ts +2 -0
  20. package/dist/queries/objectsQuery.d.ts +1 -2
  21. package/dist/queries/poolAddressesQuery.d.ts +4 -2
  22. package/dist/queries/portfolioQuery.d.ts +71 -5
  23. package/dist/queries/priceQuery.d.ts +4 -0
  24. package/dist/queries/sCoinQuery.d.ts +1 -1
  25. package/dist/types/builder/core.d.ts +3 -3
  26. package/dist/types/model.d.ts +8 -2
  27. package/dist/utils/index.d.ts +0 -2
  28. package/package.json +7 -7
  29. package/src/builders/borrowIncentiveBuilder.ts +11 -5
  30. package/src/builders/coreBuilder.ts +61 -32
  31. package/src/builders/loyaltyProgramBuilder.ts +3 -2
  32. package/src/builders/referralBuilder.ts +16 -6
  33. package/src/builders/sCoinBuilder.ts +6 -4
  34. package/src/builders/spoolBuilder.ts +14 -7
  35. package/src/builders/vescaBuilder.ts +13 -7
  36. package/src/constants/coinGecko.ts +2 -0
  37. package/src/constants/common.ts +7 -1
  38. package/src/constants/enum.ts +46 -20
  39. package/src/constants/index.ts +0 -1
  40. package/src/constants/poolAddress.ts +163 -41
  41. package/src/constants/pyth.ts +2 -0
  42. package/src/constants/queryKeys.ts +7 -9
  43. package/src/constants/testAddress.ts +24 -0
  44. package/src/index.ts +0 -1
  45. package/src/models/scallop.ts +9 -13
  46. package/src/models/scallopAddress.ts +2 -9
  47. package/src/models/scallopBuilder.ts +63 -9
  48. package/src/models/scallopCache.ts +220 -114
  49. package/src/models/scallopClient.ts +4 -7
  50. package/src/models/scallopIndexer.ts +2 -6
  51. package/src/models/scallopQuery.ts +54 -20
  52. package/src/models/scallopUtils.ts +9 -13
  53. package/src/queries/borrowIncentiveQuery.ts +6 -13
  54. package/src/queries/coreQuery.ts +62 -48
  55. package/src/queries/loyaltyProgramQuery.ts +1 -3
  56. package/src/queries/objectsQuery.ts +3 -5
  57. package/src/queries/poolAddressesQuery.ts +13 -10
  58. package/src/queries/portfolioQuery.ts +256 -21
  59. package/src/queries/priceQuery.ts +2 -7
  60. package/src/queries/sCoinQuery.ts +2 -2
  61. package/src/queries/spoolQuery.ts +21 -20
  62. package/src/queries/vescaQuery.ts +3 -7
  63. package/src/types/builder/core.ts +21 -3
  64. package/src/types/model.ts +13 -2
  65. package/src/utils/index.ts +0 -2
  66. package/src/utils/indexer.ts +3 -1
  67. package/src/utils/query.ts +2 -2
  68. package/dist/constants/tokenBucket.d.ts +0 -2
  69. package/dist/utils/tokenBucket.d.ts +0 -11
  70. package/src/constants/tokenBucket.ts +0 -2
  71. package/src/utils/tokenBucket.ts +0 -68
@@ -1,10 +1,5 @@
1
- import { SuiKit } from '@scallop-io/sui-kit';
2
- import {
3
- ADDRESSES_ID,
4
- SUPPORT_POOLS,
5
- SUPPORT_SPOOLS,
6
- DEFAULT_CACHE_OPTIONS,
7
- } from '../constants';
1
+ import { SuiKit, SuiObjectArg } from '@scallop-io/sui-kit';
2
+ import { ADDRESSES_ID, SUPPORT_POOLS, SUPPORT_SPOOLS } from '../constants';
8
3
  import {
9
4
  queryMarket,
10
5
  getObligations,
@@ -47,6 +42,7 @@ import {
47
42
  getAllCoinPrices,
48
43
  getAllAddresses,
49
44
  isIsolatedAsset,
45
+ getUserPortfolio,
50
46
  } from '../queries';
51
47
  import {
52
48
  ScallopQueryParams,
@@ -63,6 +59,7 @@ import {
63
59
  MarketPool,
64
60
  CoinPrices,
65
61
  MarketPools,
62
+ MarketCollaterals,
66
63
  } from '../types';
67
64
  import { ScallopAddress } from './scallopAddress';
68
65
  import { ScallopUtils } from './scallopUtils';
@@ -72,6 +69,7 @@ import { SuiObjectData } from '@mysten/sui/client';
72
69
  import { normalizeSuiAddress } from '@mysten/sui/utils';
73
70
  import { withIndexerFallback } from 'src/utils/indexer';
74
71
  import { newSuiKit } from './suiKit';
72
+ import { SuiObjectRef } from '@mysten/sui/client';
75
73
  /**
76
74
  * @description
77
75
  * It provides methods for getting on-chain data from the Scallop contract.
@@ -95,7 +93,7 @@ export class ScallopQuery {
95
93
  public walletAddress: string;
96
94
 
97
95
  public constructor(
98
- params: ScallopQueryParams,
96
+ params: ScallopQueryParams = {},
99
97
  instance?: ScallopQueryInstanceParams
100
98
  ) {
101
99
  this.params = params;
@@ -111,11 +109,9 @@ export class ScallopQuery {
111
109
  this.address = instance.utils.address;
112
110
  this.cache = this.address.cache;
113
111
  } else {
114
- this.cache = new ScallopCache(
115
- this.suiKit,
116
- this.walletAddress,
117
- DEFAULT_CACHE_OPTIONS
118
- );
112
+ this.cache = new ScallopCache(this.params, {
113
+ suiKit: this.suiKit,
114
+ });
119
115
  this.address = new ScallopAddress(
120
116
  {
121
117
  id: params?.addressesId ?? ADDRESSES_ID,
@@ -298,7 +294,7 @@ export class ScallopQuery {
298
294
  * @param obligationId - The obligation id.
299
295
  * @return Obligation data.
300
296
  */
301
- public async queryObligation(obligationId: string) {
297
+ public async queryObligation(obligationId: string | SuiObjectArg) {
302
298
  return queryObligation(this, obligationId);
303
299
  }
304
300
 
@@ -564,7 +560,7 @@ export class ScallopQuery {
564
560
  * @return Borrow incentive accounts data.
565
561
  */
566
562
  public async getBorrowIncentiveAccounts(
567
- obligationId: string,
563
+ obligationId: string | SuiObjectRef,
568
564
  coinNames?: SupportBorrowIncentiveCoins[]
569
565
  ) {
570
566
  return await queryBorrowIncentiveAccounts(this, obligationId, coinNames);
@@ -581,9 +577,20 @@ export class ScallopQuery {
581
577
  public async getLendings(
582
578
  poolCoinNames?: SupportPoolCoins[],
583
579
  ownerAddress: string = this.walletAddress,
584
- args?: { indexer?: boolean }
580
+ args?: {
581
+ indexer?: boolean;
582
+ marketPools?: MarketPools;
583
+ coinPrices?: CoinPrices;
584
+ }
585
585
  ) {
586
- return await getLendings(this, poolCoinNames, ownerAddress, args?.indexer);
586
+ return await getLendings(
587
+ this,
588
+ poolCoinNames,
589
+ ownerAddress,
590
+ args?.marketPools,
591
+ args?.coinPrices,
592
+ args?.indexer
593
+ );
587
594
  }
588
595
 
589
596
  /**
@@ -614,9 +621,22 @@ export class ScallopQuery {
614
621
  */
615
622
  public async getObligationAccounts(
616
623
  ownerAddress: string = this.walletAddress,
617
- args?: { indexer?: boolean }
624
+ args?: {
625
+ indexer?: boolean;
626
+ market?: {
627
+ collaterals: MarketCollaterals;
628
+ pools: MarketPools;
629
+ };
630
+ coinPrices?: CoinPrices;
631
+ }
618
632
  ) {
619
- return await getObligationAccounts(this, ownerAddress, args?.indexer);
633
+ return await getObligationAccounts(
634
+ this,
635
+ ownerAddress,
636
+ args?.market,
637
+ args?.coinPrices,
638
+ args?.indexer
639
+ );
620
640
  }
621
641
 
622
642
  /**
@@ -843,10 +863,24 @@ export class ScallopQuery {
843
863
  }
844
864
 
845
865
  /**
846
- * Query all address (lending pool, collateral pool, borrow dynamics, interest models) of all pool
866
+ * Query all address (lending pool, collateral pool, borrow dynamics, interest models, etc.) of all pool
847
867
  * @returns
848
868
  */
849
869
  public async getPoolAddresses() {
850
870
  return getAllAddresses(this);
851
871
  }
872
+
873
+ /**
874
+ * Get user portfolio
875
+ */
876
+ public async getUserPortfolio(args?: {
877
+ walletAddress?: string;
878
+ indexer?: boolean;
879
+ }) {
880
+ return getUserPortfolio(
881
+ this,
882
+ args?.walletAddress ?? this.walletAddress,
883
+ args?.indexer ?? false
884
+ );
885
+ }
852
886
  }
@@ -33,7 +33,6 @@ import {
33
33
  } from '../utils';
34
34
  import { PYTH_ENDPOINTS, PYTH_FEED_IDS } from 'src/constants/pyth';
35
35
  import { ScallopCache } from './scallopCache';
36
- import { DEFAULT_CACHE_OPTIONS } from 'src/constants/cache';
37
36
  import type {
38
37
  ScallopUtilsParams,
39
38
  SupportCoins,
@@ -49,7 +48,7 @@ import type {
49
48
  PoolAddressInfo,
50
49
  } from '../types';
51
50
  import { queryKeys } from 'src/constants';
52
- import type { SuiObjectArg, SuiTxArg, SuiTxBlock } from '@scallop-io/sui-kit';
51
+ import type { SuiObjectArg, SuiTxBlock } from '@scallop-io/sui-kit';
53
52
  import { newSuiKit } from './suiKit';
54
53
 
55
54
  /**
@@ -81,21 +80,18 @@ export class ScallopUtils {
81
80
  pythEndpoints: params.pythEndpoints ?? PYTH_ENDPOINTS['mainnet'],
82
81
  ...params,
83
82
  };
83
+ this.walletAddress =
84
+ params.walletAddress ?? instance?.suiKit?.currentAddress() ?? '';
84
85
  this.suiKit =
85
- instance?.suiKit ?? instance?.address?.cache._suiKit ?? newSuiKit(params);
86
-
87
- this.walletAddress = params.walletAddress ?? this.suiKit.currentAddress();
86
+ instance?.suiKit ?? instance?.address?.cache.suiKit ?? newSuiKit(params);
88
87
 
89
88
  if (instance?.address) {
90
89
  this.address = instance.address;
91
90
  this.cache = this.address.cache;
92
- this.suiKit = this.address.cache._suiKit;
93
91
  } else {
94
- this.cache = new ScallopCache(
95
- this.suiKit,
96
- this.walletAddress,
97
- DEFAULT_CACHE_OPTIONS
98
- );
92
+ this.cache = new ScallopCache(this.params, {
93
+ suiKit: this.suiKit,
94
+ });
99
95
  this.address =
100
96
  instance?.address ??
101
97
  new ScallopAddress(
@@ -450,7 +446,7 @@ export class ScallopUtils {
450
446
  coinType: string = SUI_TYPE_ARG,
451
447
  ownerAddress?: string
452
448
  ) {
453
- ownerAddress = ownerAddress ?? this.suiKit.currentAddress();
449
+ ownerAddress = ownerAddress ?? this.walletAddress;
454
450
  const coins = await this.suiKit.suiInteractor.selectCoins(
455
451
  ownerAddress,
456
452
  amount,
@@ -468,7 +464,7 @@ export class ScallopUtils {
468
464
  */
469
465
  public async mergeSimilarCoins(
470
466
  txBlock: SuiTxBlock,
471
- dest: SuiTxArg,
467
+ dest: SuiObjectArg,
472
468
  coinType: string,
473
469
  sender: string = this.walletAddress
474
470
  ): Promise<void> {
@@ -23,6 +23,7 @@ import type {
23
23
  MarketPools,
24
24
  } from '../types';
25
25
  import BigNumber from 'bignumber.js';
26
+ import { SuiObjectRef } from '@mysten/sui/client';
26
27
 
27
28
  /**
28
29
  * Query borrow incentive pools data using moveCall
@@ -188,7 +189,7 @@ export const queryBorrowIncentiveAccounts = async (
188
189
  }: {
189
190
  utils: ScallopUtils;
190
191
  },
191
- obligationId: string,
192
+ obligationId: string | SuiObjectRef,
192
193
  borrowIncentiveCoinNames: SupportBorrowIncentiveCoins[] = [
193
194
  ...SUPPORT_BORROW_INCENTIVE_POOLS,
194
195
  ]
@@ -245,12 +246,8 @@ export const getBindedObligationId = async (
245
246
  const veScaObjId = address.get('vesca.object');
246
247
 
247
248
  // get incentive pools
248
- const incentivePoolsResponse = await address.cache.queryGetObject(
249
- incentivePoolsId,
250
- {
251
- showContent: true,
252
- }
253
- );
249
+ const incentivePoolsResponse =
250
+ await address.cache.queryGetObject(incentivePoolsId);
254
251
 
255
252
  if (incentivePoolsResponse?.data?.content?.dataType !== 'moveObject')
256
253
  return null;
@@ -293,12 +290,8 @@ export const getBindedVeScaKey = async (
293
290
  const corePkg = address.get('core.object');
294
291
 
295
292
  // get IncentiveAccounts object
296
- const incentiveAccountsObject = await address.cache.queryGetObject(
297
- incentiveAccountsId,
298
- {
299
- showContent: true,
300
- }
301
- );
293
+ const incentiveAccountsObject =
294
+ await address.cache.queryGetObject(incentiveAccountsId);
302
295
  if (incentiveAccountsObject?.data?.content?.dataType !== 'moveObject')
303
296
  return null;
304
297
  const incentiveAccountsTableId = (
@@ -292,33 +292,65 @@ const queryRequiredMarketObjects = async (
292
292
  // Map the results back to poolCoinNames
293
293
  const mapObjects = (
294
294
  tasks: { poolCoinName: string; [key: string]: string | undefined }[],
295
- fetchedObjects: SuiObjectData[]
295
+ fetchedObjects: SuiObjectData[],
296
+ keyValue: string
296
297
  ) => {
297
298
  const resultMap: Record<string, SuiObjectData> = {};
298
- let fetchedIndex = 0;
299
+ const fetchedObjectMap = fetchedObjects.reduce(
300
+ (acc, obj) => {
301
+ acc[obj.objectId] = obj;
302
+ return acc;
303
+ },
304
+ {} as Record<string, SuiObjectData>
305
+ );
299
306
 
300
307
  for (const task of tasks) {
301
- const key = task[Object.keys(task)[1]]; // current object key being queried
302
- if (key) {
303
- resultMap[task.poolCoinName] = fetchedObjects[fetchedIndex];
304
- fetchedIndex++;
308
+ if (task[keyValue]) {
309
+ resultMap[task.poolCoinName] = fetchedObjectMap[task[keyValue]];
305
310
  }
306
311
  }
307
312
  return resultMap;
308
313
  };
309
314
 
310
- const balanceSheetMap = mapObjects(tasks, balanceSheetObjects);
311
- const collateralStatMap = mapObjects(tasks, collateralStatObjects);
312
- const borrowDynamicMap = mapObjects(tasks, borrowDynamicObjects);
313
- const interestModelMap = mapObjects(tasks, interestModelObjects);
314
- const riskModelMap = mapObjects(tasks, riskModelObjects);
315
- const borrowFeeMap = mapObjects(tasks, borrowFeeObjects);
316
- const supplyLimitMap = mapObjects(tasks, supplyLimitObjects);
317
- const borrowLimitMap = mapObjects(tasks, borrowLimitObjects);
318
- const isolatedAssetMap = mapObjects(tasks, isolatedAssetObjects);
319
-
315
+ const balanceSheetMap = mapObjects(
316
+ tasks,
317
+ balanceSheetObjects,
318
+ 'balanceSheet'
319
+ );
320
+ const collateralStatMap = mapObjects(
321
+ tasks,
322
+ collateralStatObjects,
323
+ 'collateralStat'
324
+ );
325
+ const borrowDynamicMap = mapObjects(
326
+ tasks,
327
+ borrowDynamicObjects,
328
+ 'borrowDynamic'
329
+ );
330
+ const interestModelMap = mapObjects(
331
+ tasks,
332
+ interestModelObjects,
333
+ 'interestModel'
334
+ );
335
+ const riskModelMap = mapObjects(tasks, riskModelObjects, 'riskModel');
336
+ const borrowFeeMap = mapObjects(tasks, borrowFeeObjects, 'borrowFeeKey');
337
+ const supplyLimitMap = mapObjects(
338
+ tasks,
339
+ supplyLimitObjects,
340
+ 'supplyLimitKey'
341
+ );
342
+ const borrowLimitMap = mapObjects(
343
+ tasks,
344
+ borrowLimitObjects,
345
+ 'borrowLimitKey'
346
+ );
347
+ const isolatedAssetMap = mapObjects(
348
+ tasks,
349
+ isolatedAssetObjects,
350
+ 'isolatedAssetKey'
351
+ );
320
352
  // Construct the final requiredObjects result
321
- return poolCoinNames.reduce(
353
+ const result = poolCoinNames.reduce(
322
354
  (acc, name) => {
323
355
  acc[name] = {
324
356
  balanceSheet: balanceSheetMap[name],
@@ -348,6 +380,8 @@ const queryRequiredMarketObjects = async (
348
380
  }
349
381
  >
350
382
  );
383
+
384
+ return result;
351
385
  };
352
386
 
353
387
  /**
@@ -687,9 +721,7 @@ export const getMarketCollaterals = async (
687
721
  return marketCollaterals;
688
722
  }
689
723
 
690
- const marketObjectResponse = await query.cache.queryGetObject(marketId, {
691
- showContent: true,
692
- });
724
+ const marketObjectResponse = await query.cache.queryGetObject(marketId);
693
725
  await Promise.allSettled(
694
726
  collateralCoinNames.map(async (collateralCoinName) => {
695
727
  const marketCollateral = await getMarketCollateral(
@@ -747,12 +779,7 @@ export const getMarketCollateral = async (
747
779
 
748
780
  const marketId = query.address.get('core.market');
749
781
  marketObject =
750
- marketObject ||
751
- (
752
- await query.cache.queryGetObject(marketId, {
753
- showContent: true,
754
- })
755
- )?.data;
782
+ marketObject || (await query.cache.queryGetObject(marketId))?.data;
756
783
 
757
784
  if (!(marketObject && marketObject.content?.dataType === 'moveObject'))
758
785
  throw new Error(`Failed to fetch marketObject`);
@@ -915,10 +942,7 @@ export const getObligations = async (
915
942
  (content): content is SuiParsedData & { dataType: 'moveObject' } =>
916
943
  content?.dataType === 'moveObject'
917
944
  )
918
- .map((content) => (content.fields as any).ownership.fields.of),
919
- {
920
- showContent: true,
921
- }
945
+ .map((content) => (content.fields as any).ownership.fields.of)
922
946
  );
923
947
 
924
948
  await Promise.allSettled(
@@ -953,11 +977,7 @@ export const getObligationLocked = async (
953
977
  ) => {
954
978
  const obligationObjectData =
955
979
  typeof obligation === 'string'
956
- ? (
957
- await cache.queryGetObject(obligation, {
958
- showContent: true,
959
- })
960
- )?.data
980
+ ? (await cache.queryGetObject(obligation))?.data
961
981
  : obligation;
962
982
  let obligationLocked = false;
963
983
  if (
@@ -1045,11 +1065,11 @@ export const getCoinAmount = async (
1045
1065
  ) => {
1046
1066
  const owner = ownerAddress ?? query.suiKit.currentAddress();
1047
1067
  const coinType = query.utils.parseCoinType(assetCoinName);
1048
- const amount = await query.cache.queryGetCoinBalance({
1068
+ const coinBalance = await query.cache.queryGetCoinBalance({
1049
1069
  owner,
1050
1070
  coinType: coinType,
1051
1071
  });
1052
- return BigNumber(amount).toNumber();
1072
+ return BigNumber(coinBalance?.totalBalance ?? '0').toNumber();
1053
1073
  };
1054
1074
 
1055
1075
  /**
@@ -1102,11 +1122,11 @@ export const getMarketCoinAmount = async (
1102
1122
  ) => {
1103
1123
  const owner = ownerAddress ?? query.suiKit.currentAddress();
1104
1124
  const marketCoinType = query.utils.parseMarketCoinType(marketCoinName);
1105
- const amount = await query.cache.queryGetCoinBalance({
1125
+ const coinBalance = await query.cache.queryGetCoinBalance({
1106
1126
  owner,
1107
1127
  coinType: marketCoinType,
1108
1128
  });
1109
- return BigNumber(amount).toNumber();
1129
+ return BigNumber(coinBalance?.totalBalance ?? '0').toNumber();
1110
1130
  };
1111
1131
 
1112
1132
  /**
@@ -1145,16 +1165,12 @@ export const getFlashLoanFees = async (
1145
1165
  })
1146
1166
  .filter((t) => !!t) as string[];
1147
1167
 
1148
- const flashloanFeeObjects = await query.cache.queryGetObjects(objIds, {
1149
- showContent: true,
1150
- });
1168
+ const flashloanFeeObjects = await query.cache.queryGetObjects(objIds);
1151
1169
 
1152
1170
  if (missingAssets.length > 0) {
1153
1171
  // get market object
1154
1172
  const marketObjectId = query.address.get('core.market');
1155
- const marketObjectRes = await query.cache.queryGetObject(marketObjectId, {
1156
- showContent: true,
1157
- });
1173
+ const marketObjectRes = await query.cache.queryGetObject(marketObjectId);
1158
1174
  if (marketObjectRes?.data?.content?.dataType !== 'moveObject')
1159
1175
  throw new Error('Failed to get market object');
1160
1176
 
@@ -1181,9 +1197,7 @@ export const getFlashLoanFees = async (
1181
1197
  .map((field) => field.objectId) ?? [];
1182
1198
 
1183
1199
  flashloanFeeObjects.push(
1184
- ...(await query.cache.queryGetObjects(dynamicFieldObjectIds, {
1185
- showContent: true,
1186
- }))
1200
+ ...(await query.cache.queryGetObjects(dynamicFieldObjectIds))
1187
1201
  );
1188
1202
  }
1189
1203
 
@@ -36,9 +36,7 @@ export const getLoyaltyProgramInformations = async (
36
36
  const rewardPool = query.address.get('loyaltyProgram.rewardPool');
37
37
 
38
38
  // get fields from rewardPool object
39
- const rewardPoolObject = await query.cache.queryGetObject(rewardPool, {
40
- showContent: true,
41
- });
39
+ const rewardPoolObject = await query.cache.queryGetObject(rewardPool);
42
40
 
43
41
  if (rewardPoolObject?.data?.content?.dataType !== 'moveObject') return null;
44
42
  const rewardPoolFields = rewardPoolObject.data.content.fields;
@@ -1,18 +1,16 @@
1
- import { SuiObjectDataOptions } from '@mysten/sui/dist/cjs/client';
2
1
  import { ScallopCache } from 'src/models/scallopCache';
3
2
  import { partitionArray } from 'src/utils';
4
3
 
5
4
  export const queryMultipleObjects = async (
6
5
  cache: ScallopCache,
7
- objectIds: string[],
8
- options?: SuiObjectDataOptions,
6
+ rawObjectIds: string[],
9
7
  partitionSize = 50
10
8
  ) => {
11
- const objectIdsPartition = partitionArray(objectIds, partitionSize);
9
+ const objectIdsPartition = partitionArray(rawObjectIds, partitionSize);
12
10
 
13
11
  const objects = [];
14
12
  for (const objectIds of objectIdsPartition) {
15
- const result = await cache.queryGetObjects(objectIds, options);
13
+ const result = await cache.queryGetObjects(objectIds);
16
14
  objects.push(...result);
17
15
  }
18
16
 
@@ -12,6 +12,7 @@ export const getAllAddresses = async (query: ScallopQuery) => {
12
12
  borrowDynamic?: string;
13
13
  spoolReward?: string;
14
14
  spool?: string;
15
+ sCoinType?: string;
15
16
  sCoinTreasury?: string;
16
17
  interestModel?: string;
17
18
  riskModel?: string;
@@ -19,18 +20,15 @@ export const getAllAddresses = async (query: ScallopQuery) => {
19
20
  supplyLimitKey?: string;
20
21
  borrowLimitKey?: string;
21
22
  isolatedAssetKey?: string;
22
- coinDecimalId?: string;
23
+ coinMetadataId?: string;
23
24
  borrowIncentivePoolId?: string;
25
+ coinType?: string;
24
26
  }
25
27
  >
26
28
  > = {};
27
29
 
28
30
  const marketId = query.address.get('core.market');
29
- const marketObject = (
30
- await query.cache.queryGetObject(marketId, {
31
- showContent: true,
32
- })
33
- )?.data;
31
+ const marketObject = (await query.cache.queryGetObject(marketId))?.data;
34
32
 
35
33
  if (!(marketObject && marketObject.content?.dataType === 'moveObject'))
36
34
  throw new Error(`Failed to fetch marketObject`);
@@ -78,7 +76,8 @@ export const getAllAddresses = async (query: ScallopQuery) => {
78
76
  },
79
77
  })
80
78
  )?.data?.objectId;
81
- } catch (_e) {
79
+ } catch (e: any) {
80
+ console.error(e.message);
82
81
  return undefined;
83
82
  }
84
83
  };
@@ -115,11 +114,13 @@ export const getAllAddresses = async (query: ScallopQuery) => {
115
114
  // @ts-ignore
116
115
  `spool.pools.s${coinName}.rewardPoolId`
117
116
  );
117
+ // @ts-ignore
118
+ const sCoinType = query.address.get(`scoin.coins.s${coinName}.coinType`);
118
119
  const sCoinTreasury = query.address.get(
119
120
  // @ts-ignore
120
121
  `scoin.coins.s${coinName}.treasury`
121
122
  );
122
- const coinDecimalId = query.address.get(
123
+ const coinMetadataId = query.address.get(
123
124
  `core.coins.${coinName}.metaData`
124
125
  );
125
126
  results[coinName as SupportPoolCoins] = {
@@ -135,10 +136,12 @@ export const getAllAddresses = async (query: ScallopQuery) => {
135
136
  spool,
136
137
  spoolReward: rewardPool,
137
138
  sCoinTreasury,
138
- coinDecimalId,
139
+ sCoinType,
140
+ coinMetadataId,
141
+ coinType: `0x${coinType}`,
139
142
  };
140
143
 
141
- await new Promise((resolve) => setTimeout(resolve, 200));
144
+ await new Promise((resolve) => setTimeout(resolve, 500));
142
145
  })
143
146
  );
144
147