@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.
Files changed (66) hide show
  1. package/dist/index.d.mts +509 -602
  2. package/dist/index.d.ts +509 -602
  3. package/dist/index.js +28 -59
  4. package/dist/index.mjs +7 -7
  5. package/package.json +1 -1
  6. package/src/builders/coreBuilder.ts +33 -33
  7. package/src/builders/loyaltyProgramBuilder.ts +5 -3
  8. package/src/builders/{oracle.ts → oracles/index.ts} +48 -60
  9. package/src/builders/oracles/pyth.ts +44 -0
  10. package/src/builders/oracles/switchboard.ts +270 -0
  11. package/src/builders/referralBuilder.ts +5 -9
  12. package/src/builders/sCoinBuilder.ts +9 -8
  13. package/src/builders/spoolBuilder.ts +4 -6
  14. package/src/constants/common.ts +114 -126
  15. package/src/constants/index.ts +0 -5
  16. package/src/constants/pyth.ts +25 -34
  17. package/src/constants/queryKeys.ts +2 -0
  18. package/src/constants/testAddress.ts +36 -487
  19. package/src/models/index.ts +1 -0
  20. package/src/models/scallop.ts +23 -19
  21. package/src/models/scallopAddress.ts +17 -5
  22. package/src/models/scallopBuilder.ts +36 -41
  23. package/src/models/scallopCache.ts +3 -3
  24. package/src/models/scallopClient.ts +93 -98
  25. package/src/models/scallopConstants.ts +399 -0
  26. package/src/models/scallopIndexer.ts +11 -24
  27. package/src/models/scallopQuery.ts +76 -79
  28. package/src/models/scallopUtils.ts +126 -250
  29. package/src/queries/borrowIncentiveQuery.ts +25 -58
  30. package/src/queries/borrowLimitQuery.ts +3 -6
  31. package/src/queries/coreQuery.ts +98 -114
  32. package/src/queries/flashloanFeeQuery.ts +86 -0
  33. package/src/queries/index.ts +1 -0
  34. package/src/queries/isolatedAssetQuery.ts +12 -11
  35. package/src/queries/poolAddressesQuery.ts +211 -117
  36. package/src/queries/portfolioQuery.ts +60 -70
  37. package/src/queries/priceQuery.ts +16 -22
  38. package/src/queries/sCoinQuery.ts +15 -16
  39. package/src/queries/spoolQuery.ts +49 -59
  40. package/src/queries/supplyLimitQuery.ts +2 -6
  41. package/src/queries/switchboardQuery.ts +64 -0
  42. package/src/queries/xOracleQuery.ts +29 -32
  43. package/src/types/address.ts +21 -19
  44. package/src/types/builder/borrowIncentive.ts +2 -3
  45. package/src/types/builder/core.ts +20 -27
  46. package/src/types/builder/index.ts +1 -2
  47. package/src/types/builder/referral.ts +4 -8
  48. package/src/types/builder/sCoin.ts +4 -8
  49. package/src/types/builder/spool.ts +7 -10
  50. package/src/types/constant/common.ts +44 -49
  51. package/src/types/constant/enum.ts +15 -27
  52. package/src/types/constant/xOracle.ts +3 -2
  53. package/src/types/model.ts +49 -28
  54. package/src/types/query/borrowIncentive.ts +7 -24
  55. package/src/types/query/core.ts +8 -18
  56. package/src/types/query/portfolio.ts +9 -17
  57. package/src/types/query/spool.ts +5 -11
  58. package/src/types/utils.ts +1 -21
  59. package/src/utils/core.ts +1 -1
  60. package/src/utils/query.ts +15 -23
  61. package/src/utils/util.ts +6 -84
  62. package/src/constants/coinGecko.ts +0 -34
  63. package/src/constants/enum.ts +0 -268
  64. package/src/constants/flashloan.ts +0 -18
  65. package/src/constants/poolAddress.ts +0 -898
  66. package/src/models/scallopPrice.ts +0 -0
@@ -1,11 +1,9 @@
1
1
  import { normalizeStructTag } from '@mysten/sui/utils';
2
- import { POOL_ADDRESSES, SUPPORT_SPOOLS } from '../constants';
3
2
  import {
4
3
  parseOriginSpoolData,
5
4
  calculateSpoolData,
6
5
  parseOriginSpoolRewardPoolData,
7
6
  calculateSpoolRewardPoolData,
8
- isMarketCoin,
9
7
  parseObjectAs,
10
8
  } from '../utils';
11
9
  import type { SuiObjectData, SuiObjectResponse } from '@mysten/sui/client';
@@ -16,8 +14,6 @@ import type {
16
14
  StakePool,
17
15
  StakeRewardPool,
18
16
  StakeAccounts,
19
- SupportStakeMarketCoins,
20
- SupportStakeCoins,
21
17
  CoinPrices,
22
18
  MarketPools,
23
19
  OriginSpoolRewardPoolData,
@@ -28,14 +24,14 @@ import { queryMultipleObjects } from './objectsQuery';
28
24
 
29
25
  const queryRequiredSpoolObjects = async (
30
26
  query: ScallopQuery,
31
- stakePoolCoinNames: SupportStakeCoins[]
27
+ stakePoolCoinNames: string[]
32
28
  ) => {
33
29
  // Prepare all tasks for querying each object type
34
30
  const tasks = stakePoolCoinNames.map((t, idx) => ({
35
31
  poolCoinName: stakePoolCoinNames[idx],
36
- spool: POOL_ADDRESSES[t]?.spool,
37
- spoolReward: POOL_ADDRESSES[t]?.spoolReward,
38
- sCoinTreasury: POOL_ADDRESSES[t]?.sCoinTreasury,
32
+ spool: query.constants.poolAddresses[t]?.spool,
33
+ spoolReward: query.constants.poolAddresses[t]?.spoolReward,
34
+ sCoinTreasury: query.constants.poolAddresses[t]?.sCoinTreasury,
39
35
  }));
40
36
 
41
37
  // Query all objects for each key in parallel
@@ -97,7 +93,7 @@ const queryRequiredSpoolObjects = async (
97
93
  return acc;
98
94
  },
99
95
  {} as Record<
100
- SupportStakeCoins,
96
+ string,
101
97
  {
102
98
  spool: SuiObjectData;
103
99
  spoolReward: SuiObjectData;
@@ -141,13 +137,13 @@ const parseSpoolObjects = ({
141
137
  */
142
138
  export const getSpools = async (
143
139
  query: ScallopQuery,
144
- stakeMarketCoinNames: SupportStakeMarketCoins[] = [...SUPPORT_SPOOLS],
140
+ stakeMarketCoinNames: string[] = [...query.constants.whitelist.spool],
145
141
  indexer: boolean = false,
146
142
  marketPools?: MarketPools,
147
143
  coinPrices?: CoinPrices
148
144
  ) => {
149
145
  const stakeCoinNames = stakeMarketCoinNames.map((stakeMarketCoinName) =>
150
- query.utils.parseCoinName<SupportStakeCoins>(stakeMarketCoinName)
146
+ query.utils.parseCoinName(stakeMarketCoinName)
151
147
  );
152
148
  marketPools =
153
149
  marketPools ??
@@ -165,12 +161,8 @@ export const getSpools = async (
165
161
  const spoolsIndexer = await query.indexer.getSpools();
166
162
  const updateSpools = (spool: Spool) => {
167
163
  if (!stakeMarketCoinNames.includes(spool.marketCoinName)) return;
168
- const coinName = query.utils.parseCoinName<SupportStakeCoins>(
169
- spool.marketCoinName
170
- );
171
- const rewardCoinName = query.utils.getSpoolRewardCoinName(
172
- spool.marketCoinName
173
- );
164
+ const coinName = query.utils.parseCoinName(spool.marketCoinName);
165
+ const rewardCoinName = query.utils.getSpoolRewardCoinName();
174
166
  spool.coinPrice = coinPrices[coinName] ?? spool.coinPrice;
175
167
  spool.marketCoinPrice =
176
168
  coinPrices[spool.marketCoinName] ?? spool.marketCoinPrice;
@@ -178,7 +170,9 @@ export const getSpools = async (
178
170
  coinPrices[rewardCoinName] ?? spool.rewardCoinPrice;
179
171
  spools[spool.marketCoinName] = spool;
180
172
  };
181
- Object.values(spoolsIndexer).forEach(updateSpools);
173
+ Object.values(spoolsIndexer)
174
+ .filter((t) => !!t)
175
+ .forEach(updateSpools);
182
176
 
183
177
  return spools;
184
178
  }
@@ -224,7 +218,7 @@ export const getSpools = async (
224
218
  */
225
219
  export const getSpool = async (
226
220
  query: ScallopQuery,
227
- marketCoinName: SupportStakeMarketCoins,
221
+ marketCoinName: string,
228
222
  indexer: boolean = false,
229
223
  coinPrices?: CoinPrices,
230
224
  requiredObjects?: {
@@ -232,14 +226,13 @@ export const getSpool = async (
232
226
  spoolReward: SuiObjectData;
233
227
  }
234
228
  ) => {
235
- const coinName = query.utils.parseCoinName<SupportStakeCoins>(marketCoinName);
229
+ const coinName = query.utils.parseCoinName<string>(marketCoinName);
236
230
  coinPrices = coinPrices || (await query.getAllCoinPrices());
237
231
 
238
232
  if (indexer) {
239
233
  const spoolIndexer = await query.indexer.getSpool(marketCoinName);
240
- const coinName =
241
- query.utils.parseCoinName<SupportStakeCoins>(marketCoinName);
242
- const rewardCoinName = query.utils.getSpoolRewardCoinName(marketCoinName);
234
+ const coinName = query.utils.parseCoinName<string>(marketCoinName);
235
+ const rewardCoinName = query.utils.getSpoolRewardCoinName();
243
236
  spoolIndexer.coinPrice = coinPrices?.[coinName] ?? spoolIndexer.coinPrice;
244
237
  spoolIndexer.marketCoinPrice =
245
238
  coinPrices?.[marketCoinName] ?? spoolIndexer.marketCoinPrice;
@@ -253,7 +246,7 @@ export const getSpool = async (
253
246
  coinName
254
247
  ];
255
248
 
256
- const rewardCoinName = query.utils.getSpoolRewardCoinName(marketCoinName);
249
+ const rewardCoinName = query.utils.getSpoolRewardCoinName();
257
250
  coinPrices = coinPrices || (await query.utils.getCoinPrices());
258
251
 
259
252
  const parsedSpoolObjects = parseSpoolObjects(requiredObjects);
@@ -286,10 +279,10 @@ export const getSpool = async (
286
279
  symbol: query.utils.parseSymbol(marketCoinName),
287
280
  coinType: query.utils.parseCoinType(coinName),
288
281
  marketCoinType: query.utils.parseMarketCoinType(coinName),
289
- rewardCoinType: isMarketCoin(rewardCoinName)
282
+ rewardCoinType: query.utils.isMarketCoin(rewardCoinName)
290
283
  ? query.utils.parseMarketCoinType(rewardCoinName)
291
284
  : query.utils.parseCoinType(rewardCoinName),
292
- sCoinType: query.utils.parseSCoinType(marketCoinName),
285
+ sCoinType: query.utils.parseSCoinType(marketCoinName) ?? '',
293
286
  coinDecimal: query.utils.getCoinDecimal(coinName),
294
287
  rewardCoinDecimal: query.utils.getCoinDecimal(rewardCoinName),
295
288
  coinPrice: coinPrices?.[coinName] ?? 0,
@@ -352,37 +345,37 @@ export const getStakeAccounts = async (
352
345
  }
353
346
  } while (hasNextPage);
354
347
 
355
- const stakeAccounts: StakeAccounts = SUPPORT_SPOOLS.reduce(
356
- (acc, stakeName) => {
357
- acc[stakeName] = [];
358
- return acc;
348
+ const stakeAccounts: StakeAccounts = [
349
+ ...utils.constants.whitelist.spool,
350
+ ].reduce((acc, stakeName) => {
351
+ acc[stakeName] = [];
352
+ return acc;
353
+ }, {} as StakeAccounts);
354
+
355
+ const stakeMarketCoinTypes: Record<string, string> = Object.keys(
356
+ stakeAccounts
357
+ ).reduce(
358
+ (types, stakeMarketCoinName) => {
359
+ const stakeCoinName = utils.parseCoinName<string>(stakeMarketCoinName);
360
+ const marketCoinType = utils.parseMarketCoinType(stakeCoinName);
361
+
362
+ types[stakeMarketCoinName as string] =
363
+ `${spoolObjectId}::spool_account::SpoolAccount<${marketCoinType}>`;
364
+ return types;
359
365
  },
360
- {} as StakeAccounts
366
+ {} as Record<string, string>
361
367
  );
362
368
 
363
- const stakeMarketCoinTypes: Record<SupportStakeMarketCoins, string> =
364
- Object.keys(stakeAccounts).reduce(
365
- (types, stakeMarketCoinName) => {
366
- const stakeCoinName =
367
- utils.parseCoinName<SupportStakeCoins>(stakeMarketCoinName);
368
- const marketCoinType = utils.parseMarketCoinType(stakeCoinName);
369
-
370
- types[stakeMarketCoinName as SupportStakeMarketCoins] =
371
- `${spoolObjectId}::spool_account::SpoolAccount<${marketCoinType}>`;
372
- return types;
373
- },
374
- {} as Record<SupportStakeMarketCoins, string>
375
- );
376
-
377
369
  // Reverse the mapping
378
- const reversedStakeMarketCoinTypes: Record<string, SupportStakeMarketCoins> =
379
- Object.entries(stakeMarketCoinTypes).reduce(
380
- (reversedTypes, [key, value]) => {
381
- reversedTypes[value] = key as SupportStakeMarketCoins;
382
- return reversedTypes;
383
- },
384
- {} as Record<string, SupportStakeMarketCoins>
385
- );
370
+ const reversedStakeMarketCoinTypes: Record<string, string> = Object.entries(
371
+ stakeMarketCoinTypes
372
+ ).reduce(
373
+ (reversedTypes, [key, value]) => {
374
+ reversedTypes[value] = key as string;
375
+ return reversedTypes;
376
+ },
377
+ {} as Record<string, string>
378
+ );
386
379
 
387
380
  for (const stakeObject of stakeObjectsResponse.map((ref) => ref.data)) {
388
381
  const id = stakeObject?.objectId;
@@ -396,10 +389,7 @@ export const getStakeAccounts = async (
396
389
  const points = Number(fields.points);
397
390
  const totalPoints = Number(fields.total_points);
398
391
 
399
- const stakeMarketCoinTypeMap: Record<
400
- SupportStakeMarketCoins,
401
- StakeAccounts[SupportStakeMarketCoins]
402
- > = {
392
+ const stakeMarketCoinTypeMap: Record<string, StakeAccounts[string]> = {
403
393
  sweth: stakeAccounts.sweth,
404
394
  ssui: stakeAccounts.ssui,
405
395
  swusdc: stakeAccounts.swusdc,
@@ -449,7 +439,7 @@ export const getStakePool = async (
449
439
  }: {
450
440
  utils: ScallopUtils;
451
441
  },
452
- marketCoinName: SupportStakeMarketCoins
442
+ marketCoinName: string
453
443
  ) => {
454
444
  const poolId = utils.address.get(`spool.pools.${marketCoinName}.id`);
455
445
  let stakePool: StakePool | undefined = undefined;
@@ -506,7 +496,7 @@ export const getStakeRewardPool = async (
506
496
  }: {
507
497
  utils: ScallopUtils;
508
498
  },
509
- marketCoinName: SupportStakeMarketCoins
499
+ marketCoinName: string
510
500
  ) => {
511
501
  const poolId = utils.address.get(
512
502
  `spool.pools.${marketCoinName}.rewardPoolId`
@@ -1,5 +1,4 @@
1
1
  import { ScallopUtils } from 'src/models';
2
- import { SupportPoolCoins } from 'src/types';
3
2
  import { z as zod } from 'zod';
4
3
 
5
4
  const supplyLimitZod = zod.object({
@@ -25,10 +24,7 @@ const supplyLimitKeyType = `0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe874
25
24
  * @param poolName
26
25
  * @returns supply limit (decimals included)
27
26
  */
28
- export const getSupplyLimit = async (
29
- utils: ScallopUtils,
30
- poolName: SupportPoolCoins
31
- ) => {
27
+ export const getSupplyLimit = async (utils: ScallopUtils, poolName: string) => {
32
28
  try {
33
29
  const poolCoinType = utils.parseCoinType(poolName).slice(2);
34
30
  const marketObject = utils.address.get('core.market');
@@ -43,7 +39,7 @@ export const getSupplyLimit = async (
43
39
  });
44
40
 
45
41
  const parsedData = supplyLimitZod.safeParse(object?.data?.content);
46
- if (!parsedData.success) return null;
42
+ if (!parsedData.success) return '0';
47
43
  return parsedData.data.fields.value;
48
44
  } catch (e: any) {
49
45
  console.error(`Error in getSupplyLimit for ${poolName}: ${e.message}`);
@@ -0,0 +1,64 @@
1
+ import { ScallopQuery } from 'src/models';
2
+
3
+ export const getOnDemandAggObjectIds = async (
4
+ query: ScallopQuery,
5
+ coinNames: string[],
6
+ switchboardRegistryTableId: string = query.address.get(
7
+ 'core.oracles.switchboard.registryTableId'
8
+ )
9
+ ): Promise<string[]> => {
10
+ const missingAgg: Array<{
11
+ idx: number;
12
+ coinName: string;
13
+ }> = [];
14
+
15
+ // Check if Aggregator is already registered in Address API
16
+ const registeredAggs = coinNames.map((coinName, idx) => {
17
+ const registeredAgg = query.utils.address.get(
18
+ `core.coins.${coinName}.oracle.switchboard`
19
+ );
20
+ if (registeredAgg) {
21
+ return registeredAgg;
22
+ } else {
23
+ missingAgg.push({
24
+ idx,
25
+ coinName,
26
+ });
27
+ return null;
28
+ }
29
+ });
30
+
31
+ if (missingAgg.length === 0) return registeredAggs;
32
+
33
+ // If not, query from the registry table
34
+ const missingCoinNames = missingAgg.map((agg) => agg.coinName);
35
+ const coinTypes = missingCoinNames.map((coinName) => {
36
+ const coinType = query.utils.parseCoinType(coinName);
37
+ if (!coinType) throw new Error(`Invalid coin name: ${coinName}`);
38
+ return coinType;
39
+ });
40
+
41
+ await Promise.all(
42
+ coinTypes.map(async (coinType, idx) => {
43
+ const dfName = {
44
+ type: '0x1::type_name::TypeName',
45
+ value: {
46
+ name: coinType.slice(2),
47
+ },
48
+ };
49
+
50
+ const resp = await query.cache.queryGetDynamicFieldObject({
51
+ parentId: switchboardRegistryTableId,
52
+ name: dfName,
53
+ });
54
+
55
+ if (!resp?.data?.content || resp.data.content.dataType !== 'moveObject')
56
+ throw new Error(`No on-demand aggregator found for ${coinType}`);
57
+
58
+ const content = resp.data.content;
59
+ registeredAggs[idx] = (content.fields as any).value;
60
+ })
61
+ );
62
+
63
+ return registeredAggs;
64
+ };
@@ -1,15 +1,11 @@
1
1
  import { SuiObjectResponse } from '@mysten/sui/client';
2
2
  import { ScallopAddress, ScallopUtils } from 'src/models';
3
- import {
4
- SupportAssetCoins,
5
- SupportOracleType,
6
- xOracleRuleType,
7
- } from 'src/types';
3
+ import { SupportOracleType, xOracleRuleType } from 'src/types';
8
4
 
9
- const PRIMARY_PRICE_UPDATE_POLICY =
10
- '0x56e48a141f20a3a6a6d3fc43e58b01fc63f756c08224870e7890c80ec9d2afee';
11
- const SECONDARY_PRICE_UPDDATE_POLICY =
12
- '0xef4d9430ae42c1b24199ac55e87ddd7262622447ee3c7de8868efe839b3d8705';
5
+ // const PRIMARY_PRICE_UPDATE_POLICY =
6
+ // '0x56e48a141f20a3a6a6d3fc43e58b01fc63f756c08224870e7890c80ec9d2afee';
7
+ // const SECONDARY_PRICE_UPDDATE_POLICY =
8
+ // '0xef4d9430ae42c1b24199ac55e87ddd7262622447ee3c7de8868efe839b3d8705';
13
9
 
14
10
  /**
15
11
  * Query the price update policy table ids. Usually the value for these table will be constant.
@@ -26,14 +22,14 @@ export const getPriceUpdatePolicies = async (
26
22
  const [primaryPriceUpdatePolicyTable, secondaryPriceUpdatePolicyTable] =
27
23
  await Promise.all([
28
24
  address.cache.queryGetDynamicFieldObject({
29
- parentId: PRIMARY_PRICE_UPDATE_POLICY,
25
+ parentId: address.get('core.oracles.primaryPriceUpdatePolicyObject'),
30
26
  name: {
31
27
  type: priceUpdatePolicyRulesKeyType,
32
28
  value: { dummy_field: false },
33
29
  },
34
30
  }),
35
31
  address.cache.queryGetDynamicFieldObject({
36
- parentId: SECONDARY_PRICE_UPDDATE_POLICY,
32
+ parentId: address.get('core.oracles.secondaryPriceUpdatePolicyObject'),
37
33
  name: {
38
34
  type: priceUpdatePolicyRulesKeyType,
39
35
  value: { dummy_field: false },
@@ -47,24 +43,26 @@ export const getPriceUpdatePolicies = async (
47
43
  };
48
44
  };
49
45
 
50
- // const PRIMARY_PRICE_UPDATE_POLICY_KEY =
51
- // '0x856d0930acc36780eda9ea47019c979ca6ad34fd36f158b181eb7350195acc00';
52
- // const SECONDARY_PRICE_UPDATE_POLICY_KEY =
53
- // '0x304d226734fa5e376423c9ff0f1d49aeb1e2572d4b617d31e11e2f69865b73ed';
54
- const PRIMARY_PRICE_UPDATE_POLICY_VECSET_ID =
55
- '0xc22c9d691ee4c780de09db91d8b487d863211ebf08720772144bcf716318826c';
56
- const SECONDARY_PRICE_UPDATE_POLICY_VECSET_ID =
57
- '0x3b184ff859f5de30eeaf186898e5224925be6bb6d2baa74347ef471a8cd1c0d3';
46
+ // const PRIMARY_PRICE_UPDATE_POLICY_VECSET_ID =
47
+ // '0xc22c9d691ee4c780de09db91d8b487d863211ebf08720772144bcf716318826c';
48
+ // const SECONDARY_PRICE_UPDATE_POLICY_VECSET_ID =
49
+ // '0x3b184ff859f5de30eeaf186898e5224925be6bb6d2baa74347ef471a8cd1c0d3';
58
50
 
59
51
  export const getAssetOracles = async (
60
52
  utils: ScallopUtils,
61
53
  ruleType: xOracleRuleType
62
- ): Promise<Record<SupportAssetCoins, SupportOracleType[]> | null> => {
63
- if (ruleType === 'primary' && !PRIMARY_PRICE_UPDATE_POLICY_VECSET_ID) {
54
+ ): Promise<Record<string, string[]> | null> => {
55
+ if (
56
+ ruleType === 'primary' &&
57
+ !utils.address.get('core.oracles.primaryPriceUpdatePolicyVecsetId')
58
+ ) {
64
59
  console.error('Primary price update policy vecset id is not set');
65
60
  return null;
66
61
  }
67
- if (ruleType === 'secondary' && !SECONDARY_PRICE_UPDATE_POLICY_VECSET_ID) {
62
+ if (
63
+ ruleType === 'secondary' &&
64
+ !utils.address.get('core.oracles.secondaryPriceUpdatePolicyVecsetId')
65
+ ) {
68
66
  console.error('Secondary price update policy vecset id is not set');
69
67
  return null;
70
68
  }
@@ -76,17 +74,16 @@ export const getAssetOracles = async (
76
74
  'switchboard',
77
75
  };
78
76
 
79
- const assetPrimaryOracles = {} as Record<
80
- SupportAssetCoins,
81
- SupportOracleType[]
82
- >;
77
+ const assetOracles = {} as Record<string, SupportOracleType[]>;
83
78
  let cursor = null;
84
79
  do {
85
80
  const response = await utils.cache.queryGetDynamicFields({
86
81
  parentId:
87
82
  ruleType === 'primary'
88
- ? PRIMARY_PRICE_UPDATE_POLICY_VECSET_ID
89
- : SECONDARY_PRICE_UPDATE_POLICY_VECSET_ID,
83
+ ? utils.address.get('core.oracles.primaryPriceUpdatePolicyVecsetId')
84
+ : utils.address.get(
85
+ 'core.oracles.secondaryPriceUpdatePolicyVecsetId'
86
+ ),
90
87
  cursor,
91
88
  limit: 10,
92
89
  });
@@ -108,8 +105,8 @@ export const getAssetOracles = async (
108
105
 
109
106
  const assetName = utils.parseCoinNameFromType(`0x${typeName}`);
110
107
  if (!assetName) throw new Error(`Invalid asset name: ${assetName}`);
111
- if (!assetPrimaryOracles[assetName]) {
112
- assetPrimaryOracles[assetName] = [];
108
+ if (!assetOracles[assetName]) {
109
+ assetOracles[assetName] = [];
113
110
  }
114
111
 
115
112
  const value = fields.value as {
@@ -120,7 +117,7 @@ export const getAssetOracles = async (
120
117
  };
121
118
 
122
119
  value.fields.contents.forEach((content) => {
123
- assetPrimaryOracles[assetName].push(
120
+ assetOracles[assetName].push(
124
121
  ruleTypeNameToOracleType[`0x${content.fields.name}`]
125
122
  );
126
123
  });
@@ -128,5 +125,5 @@ export const getAssetOracles = async (
128
125
  if (!hasNextPage) break;
129
126
  } while (cursor);
130
127
 
131
- return assetPrimaryOracles;
128
+ return assetOracles;
132
129
  };
@@ -1,11 +1,4 @@
1
- import { SUPPORT_ORACLES } from '../constants';
2
- import type {
3
- SupportAssetCoins,
4
- SupportOracleType,
5
- SupportPackageType,
6
- SupportSCoin,
7
- SupportStakeMarketCoins,
8
- } from './constant';
1
+ import { _SUPPORT_ORACLES, SupportOracleType } from './constant/xOracle';
9
2
 
10
3
  export interface AddressesInterface {
11
4
  core: {
@@ -18,7 +11,7 @@ export interface AddressesInterface {
18
11
  obligationAccessStore: string;
19
12
  coins: Partial<
20
13
  Record<
21
- SupportAssetCoins,
14
+ string,
22
15
  {
23
16
  id: string;
24
17
  treasury: string;
@@ -27,11 +20,11 @@ export interface AddressesInterface {
27
20
  symbol: string;
28
21
  decimals: number;
29
22
  oracle: {
30
- [K in SupportOracleType]: K extends (typeof SUPPORT_ORACLES)[0]
23
+ [K in SupportOracleType]: K extends (typeof _SUPPORT_ORACLES)[0]
31
24
  ? string
32
- : K extends (typeof SUPPORT_ORACLES)[1]
25
+ : K extends (typeof _SUPPORT_ORACLES)[1]
33
26
  ? string
34
- : K extends (typeof SUPPORT_ORACLES)[2]
27
+ : K extends (typeof _SUPPORT_ORACLES)[2]
35
28
  ? {
36
29
  feed: string;
37
30
  feedObject: string;
@@ -42,18 +35,20 @@ export interface AddressesInterface {
42
35
  >
43
36
  >;
44
37
  oracles: {
45
- [K in SupportOracleType]: K extends (typeof SUPPORT_ORACLES)[0]
38
+ [K in SupportOracleType]: K extends (typeof _SUPPORT_ORACLES)[0]
46
39
  ? {
47
40
  registry: string;
48
41
  registryCap: string;
49
42
  holder: string;
50
43
  }
51
- : K extends (typeof SUPPORT_ORACLES)[1]
44
+ : K extends (typeof _SUPPORT_ORACLES)[1]
52
45
  ? {
53
46
  registry: string;
54
47
  registryCap: string;
48
+ registryTableId: string;
49
+ state: string;
55
50
  }
56
- : K extends (typeof SUPPORT_ORACLES)[2]
51
+ : K extends (typeof _SUPPORT_ORACLES)[2]
57
52
  ? {
58
53
  registry: string;
59
54
  registryCap: string;
@@ -62,10 +57,17 @@ export interface AddressesInterface {
62
57
  wormholeState: string;
63
58
  }
64
59
  : never;
65
- } & { xOracle: string; xOracleCap: string };
60
+ } & {
61
+ xOracle: string;
62
+ xOracleCap: string;
63
+ primaryPriceUpdatePolicyObject: string;
64
+ secondaryPriceUpdatePolicyObject: string;
65
+ primaryPriceUpdatePolicyVecsetId: string;
66
+ secondaryPriceUpdatePolicyVecsetId: string;
67
+ };
66
68
  packages: Partial<
67
69
  Record<
68
- SupportPackageType,
70
+ string,
69
71
  {
70
72
  id: string;
71
73
  object?: string;
@@ -81,7 +83,7 @@ export interface AddressesInterface {
81
83
  config: string;
82
84
  pools: Partial<
83
85
  Record<
84
- SupportStakeMarketCoins,
86
+ string,
85
87
  {
86
88
  id: string;
87
89
  rewardPoolId: string;
@@ -130,7 +132,7 @@ export interface AddressesInterface {
130
132
  id: string;
131
133
  coins: Partial<
132
134
  Record<
133
- SupportSCoin,
135
+ string,
134
136
  {
135
137
  coinType: string;
136
138
  symbol: string;
@@ -4,7 +4,6 @@ import type {
4
4
  } from '@scallop-io/sui-kit';
5
5
  import type { TransactionResult } from '@mysten/sui/transactions';
6
6
  import type { ScallopBuilder } from '../../models';
7
- import type { SupportBorrowIncentiveRewardCoins } from '../constant';
8
7
 
9
8
  export type BorrowIncentiveIds = {
10
9
  borrowIncentivePkg: string;
@@ -32,7 +31,7 @@ export type BorrowIncentiveNormalMethods = {
32
31
  claimBorrowIncentive: (
33
32
  obligation: SuiObjectArg,
34
33
  obligationKey: SuiObjectArg,
35
- rewardType: SupportBorrowIncentiveRewardCoins
34
+ rewardType: string
36
35
  ) => TransactionResult;
37
36
  deactivateBoost: (obligation: SuiObjectArg, veScaKey: SuiObjectArg) => void;
38
37
  };
@@ -52,7 +51,7 @@ export type BorrowIncentiveQuickMethods = {
52
51
  obligationKey?: string
53
52
  ): Promise<void>;
54
53
  claimBorrowIncentiveQuick(
55
- rewardType: SupportBorrowIncentiveRewardCoins,
54
+ rewardType: string,
56
55
  obligation?: string,
57
56
  obligationKey?: string
58
57
  ): Promise<TransactionResult>;