@scallop-io/sui-scallop-sdk 2.3.0-lst-x-oracle-alpha.9 → 2.3.0

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 (73) hide show
  1. package/dist/index.d.mts +1811 -1783
  2. package/dist/index.d.ts +1811 -1783
  3. package/dist/index.js +49 -2
  4. package/dist/index.mjs +15 -2
  5. package/package.json +8 -7
  6. package/src/builders/borrowIncentiveBuilder.ts +4 -4
  7. package/src/builders/coreBuilder.ts +86 -59
  8. package/src/builders/index.ts +2 -2
  9. package/src/builders/loyaltyProgramBuilder.ts +2 -2
  10. package/src/builders/oracles/index.ts +365 -114
  11. package/src/builders/oracles/pyth.ts +135 -0
  12. package/src/builders/referralBuilder.ts +4 -10
  13. package/src/builders/sCoinBuilder.ts +2 -2
  14. package/src/builders/spoolBuilder.ts +2 -2
  15. package/src/builders/vescaBuilder.ts +5 -5
  16. package/src/constants/common.ts +3 -0
  17. package/src/constants/index.ts +1 -1
  18. package/src/constants/queryKeys.ts +1 -1
  19. package/src/constants/testAddress.ts +99 -271
  20. package/src/constants/xoracle.ts +2 -8
  21. package/src/index.ts +1 -1
  22. package/src/models/index.ts +1 -2
  23. package/src/models/interface.ts +6 -6
  24. package/src/models/rateLimiter.ts +55 -0
  25. package/src/models/scallop.ts +1 -1
  26. package/src/models/scallopAddress.ts +5 -33
  27. package/src/models/scallopBuilder.ts +14 -11
  28. package/src/models/scallopClient.ts +31 -14
  29. package/src/models/scallopConstants.ts +3 -3
  30. package/src/models/scallopIndexer.ts +3 -4
  31. package/src/models/scallopQuery.ts +112 -56
  32. package/src/models/scallopQueryClient.ts +1 -1
  33. package/src/models/scallopSuiKit.ts +1 -1
  34. package/src/models/scallopUtils.ts +12 -7
  35. package/src/queries/borrowIncentiveQuery.ts +4 -3
  36. package/src/queries/coreQuery.ts +114 -186
  37. package/src/queries/index.ts +3 -4
  38. package/src/queries/loyaltyProgramQuery.ts +2 -2
  39. package/src/queries/ownerQuery.ts +32 -0
  40. package/src/queries/poolAddressesQuery.ts +1 -3
  41. package/src/queries/portfolioQuery.ts +68 -16
  42. package/src/queries/priceQuery.ts +2 -3
  43. package/src/queries/sCoinQuery.ts +2 -2
  44. package/src/queries/spoolQuery.ts +57 -74
  45. package/src/queries/vescaQuery.ts +3 -3
  46. package/src/queries/xOracleQuery.ts +4 -21
  47. package/src/types/address.ts +47 -98
  48. package/src/types/builder/core.ts +40 -15
  49. package/src/types/builder/index.ts +17 -1
  50. package/src/types/constant/enum.ts +64 -0
  51. package/src/types/constant/index.ts +1 -2
  52. package/src/types/constant/xOracle.ts +7 -10
  53. package/src/types/index.ts +1 -1
  54. package/src/types/query/core.ts +3 -0
  55. package/src/types/query/index.ts +1 -0
  56. package/src/types/query/sCoin.ts +1 -0
  57. package/src/{builders/utils.ts → utils/builder.ts} +1 -1
  58. package/src/utils/core.ts +18 -0
  59. package/src/utils/index.ts +5 -0
  60. package/src/utils/indexer.ts +47 -0
  61. package/src/{queries/utils.ts → utils/query.ts} +7 -25
  62. package/src/utils/util.ts +42 -0
  63. package/src/builders/oracles/error.ts +0 -18
  64. package/src/builders/oracles/oraclePackageRegistry.ts +0 -336
  65. package/src/builders/oracles/priceFeedUpdater.ts +0 -112
  66. package/src/builders/oracles/priceUpdateRequester.ts +0 -50
  67. package/src/builders/oracles/xOracleUpdateStrategy.ts +0 -214
  68. package/src/builders/oracles/xOracleUpdater.ts +0 -153
  69. package/src/constants/api.ts +0 -2
  70. package/src/models/utils.ts +0 -97
  71. package/src/types/builder/type.ts +0 -25
  72. package/src/types/constant/package.ts +0 -16
  73. /package/src/types/{util.ts → utils.ts} +0 -0
@@ -1,24 +1,24 @@
1
1
  import BigNumber from 'bignumber.js';
2
- import { minBigNumber, estimatedFactor } from './utils';
2
+ import { minBigNumber, estimatedFactor } from 'src/utils';
3
3
  import type { ScallopQuery } from 'src/models';
4
- import { SuiObjectRef } from '@mysten/sui/client';
5
- import { normalizeStructTag, SUI_TYPE_ARG } from '@scallop-io/sui-kit';
6
- import {
7
- CoinAmounts,
8
- Lending,
9
- Lendings,
4
+ import type {
10
5
  Market,
11
- MarketCollaterals,
12
6
  MarketPool,
13
- MarketPools,
14
- ObligationAccount,
15
- ObligationAccounts,
16
- ObligationBorrowIncentiveReward,
17
7
  Spool,
18
8
  StakeAccount,
9
+ Lendings,
10
+ Lending,
11
+ ObligationAccounts,
12
+ ObligationAccount,
13
+ CoinAmounts,
14
+ CoinPrices,
19
15
  TotalValueLocked,
20
- } from 'src/types/query';
21
- import { CoinPrices } from 'src/types/util';
16
+ ObligationBorrowIncentiveReward,
17
+ MarketPools,
18
+ MarketCollaterals,
19
+ } from 'src/types';
20
+ import { SuiObjectRef } from '@mysten/sui/client';
21
+ import { normalizeStructTag, SUI_TYPE_ARG } from '@scallop-io/sui-kit';
22
22
 
23
23
  /**
24
24
  * Get user lending infomation for specific pools.
@@ -293,6 +293,8 @@ export const getLending = async (
293
293
  *
294
294
  * @param query - The Scallop query instance.
295
295
  * @param ownerAddress - The owner address.
296
+ * @param market - The market data.
297
+ * @param coinPrices - The coin prices data.
296
298
  * @param indexer - Whether to use indexer.
297
299
  * @return All obligation accounts data.
298
300
  */
@@ -338,12 +340,62 @@ export const getObligationAccounts = async (
338
340
  return obligationAccounts;
339
341
  };
340
342
 
343
+ /**
344
+ * Get all obligation accounts data by ids.
345
+ *
346
+ * @param query - The Scallop query instance.
347
+ * @param obligationIds - Obligation account ids.
348
+ * @param market - The market data.
349
+ * @param coinPrices - The coin prices data.
350
+ * @param indexer - Whether to use indexer.
351
+ * @return All obligation accounts data.
352
+ */
353
+ export const getObligationAccountsByIds = async (
354
+ query: ScallopQuery,
355
+ obligationIds: string[],
356
+ market?: {
357
+ pools: MarketPools;
358
+ collaterals: MarketCollaterals;
359
+ },
360
+ coinPrices?: CoinPrices,
361
+ indexer: boolean = false
362
+ ) => {
363
+ market = market ?? (await query.getMarketPools(undefined, { indexer }));
364
+ coinPrices =
365
+ coinPrices ??
366
+ (await query.getAllCoinPrices({
367
+ marketPools: market.pools,
368
+ }));
369
+
370
+ const obligationAccounts: ObligationAccount[] = [];
371
+ await Promise.allSettled(
372
+ obligationIds.map(async (obligationId) => {
373
+ const obligationAccount = await getObligationAccount(
374
+ query,
375
+ obligationId,
376
+ '',
377
+ indexer,
378
+ market,
379
+ coinPrices,
380
+ {}
381
+ );
382
+ if (obligationAccount) obligationAccounts.push(obligationAccount);
383
+ })
384
+ );
385
+
386
+ return obligationAccounts;
387
+ };
388
+
341
389
  /**
342
390
  * Get obligation account data.
343
391
  *
344
392
  * @param query - The Scallop query instance.
345
393
  * @param obligation - The obligation id.
394
+ * @param ownerAddress - The owner address of the obligation.
346
395
  * @param indexer - Whether to use indexer.
396
+ * @param market - The market data.
397
+ * @param coinPrices - The coin prices data.
398
+ * @param coinAmounts - The coin amounts data.
347
399
  * @return Obligation account data.
348
400
  */
349
401
  export const getObligationAccount = async (
@@ -787,8 +839,6 @@ export const getTotalValueLocked = async (
787
839
  query: ScallopQuery,
788
840
  indexer: boolean = false
789
841
  ) => {
790
- const market = await query.getMarketPools(undefined, { indexer });
791
-
792
842
  let supplyLendingValue = BigNumber(0);
793
843
  let supplyCollateralValue = BigNumber(0);
794
844
  let borrowValue = BigNumber(0);
@@ -811,6 +861,8 @@ export const getTotalValueLocked = async (
811
861
  return tvl;
812
862
  }
813
863
 
864
+ const market = await query.getMarketPools(undefined, { indexer });
865
+
814
866
  for (const pool of Object.values(market.pools)) {
815
867
  if (!pool) continue;
816
868
  supplyLendingValue = supplyLendingValue.plus(
@@ -1,7 +1,6 @@
1
1
  import { SuiObjectData } from '@mysten/sui/client';
2
2
  import type { ScallopAddress, ScallopQuery, ScallopSuiKit } from 'src/models';
3
- import type { MarketPools } from 'src/types/query';
4
- import type { CoinPrices } from 'src/types/util';
3
+ import type { CoinPrices, MarketPools, OptionalKeys } from '../types';
5
4
  import BigNumber from 'bignumber.js';
6
5
 
7
6
  /**
@@ -151,7 +150,7 @@ export const getAllCoinPrices = async (
151
150
  throw new Error(`Failed to fetch market pool for getAllCoinPrices`);
152
151
  }
153
152
 
154
- const sCoinPrices: CoinPrices = {};
153
+ const sCoinPrices: OptionalKeys<Record<string, number>> = {};
155
154
  query.constants.whitelist.scoin.forEach((sCoinName) => {
156
155
  const coinName = query.utils.parseCoinName(sCoinName);
157
156
  sCoinPrices[sCoinName] = BigNumber(coinPrices[coinName] ?? 0)
@@ -2,7 +2,7 @@ import { bcs } from '@mysten/sui/bcs';
2
2
  import assert from 'assert';
3
3
  import BigNumber from 'bignumber.js';
4
4
  import { ScallopQuery, ScallopUtils } from 'src/models';
5
- import { OptionalKeys } from 'src/types/util';
5
+ import { OptionalKeys, sCoinBalance } from 'src/types';
6
6
 
7
7
  /**
8
8
  * Get total supply of sCoin
@@ -17,7 +17,7 @@ export const getSCoinTotalSupply = async (
17
17
  utils: ScallopUtils;
18
18
  },
19
19
  sCoinName: string
20
- ): Promise<number> => {
20
+ ): Promise<sCoinBalance> => {
21
21
  const sCoinPkgId = utils.address.get('scoin.id');
22
22
  // get treasury
23
23
  const args = [utils.getSCoinTreasury(sCoinName)];
@@ -5,100 +5,83 @@ import {
5
5
  parseOriginSpoolRewardPoolData,
6
6
  calculateSpoolRewardPoolData,
7
7
  parseObjectAs,
8
- } from './utils';
8
+ partitionArray,
9
+ } from 'src/utils';
9
10
  import type { SuiObjectData, SuiObjectResponse } from '@mysten/sui/client';
10
11
  import type { ScallopQuery, ScallopUtils } from 'src/models';
11
- import {
12
- OriginSpoolData,
13
- OriginSpoolRewardPoolData,
14
- SpoolData,
15
- MarketPools,
12
+ import type {
16
13
  Spools,
17
14
  Spool,
18
- StakeAccounts,
19
15
  StakePool,
20
16
  StakeRewardPool,
21
- } from 'src/types/query';
22
- import { CoinPrices } from 'src/types/util';
17
+ StakeAccounts,
18
+ CoinPrices,
19
+ MarketPools,
20
+ OriginSpoolRewardPoolData,
21
+ SpoolData,
22
+ OriginSpoolData,
23
+ } from '../types';
23
24
 
24
25
  const queryRequiredSpoolObjects = async (
25
26
  query: ScallopQuery,
26
27
  stakePoolCoinNames: string[]
27
28
  ) => {
28
- // Phase 1: Single-pass data preparation
29
- type KeyType = {
30
- spool?: string;
31
- spoolReward?: string;
32
- sCoinTreasury?: string;
33
- };
29
+ const keyTypes = ['spool', 'spoolReward', 'sCoinTreasury'] as const;
34
30
 
35
- const keyCollections: Record<keyof KeyType, string[]> = {
36
- spool: [],
37
- spoolReward: [],
38
- sCoinTreasury: [],
39
- };
40
-
41
- const taskMap = new Map<string, KeyType>();
31
+ const allObjectIds: string[] = [];
42
32
 
43
- // Single iteration to collect all keys
44
33
  for (const poolCoinName of stakePoolCoinNames) {
45
34
  const poolData = query.constants.poolAddresses[poolCoinName];
46
- const task: KeyType = {
47
- spool: poolData?.spool,
48
- spoolReward: poolData?.spoolReward,
49
- sCoinTreasury: poolData?.sCoinTreasury,
50
- };
51
-
52
- // Add to key collections
53
- (Object.entries(task) as [keyof KeyType, string | undefined][]).forEach(
54
- ([key, value]) => {
55
- if (value) keyCollections[key].push(value);
35
+ for (const keyType of keyTypes) {
36
+ if (poolData?.[keyType] && poolData[keyType] !== '') {
37
+ allObjectIds.push(poolData[keyType]);
56
38
  }
57
- );
58
-
59
- taskMap.set(poolCoinName, task);
39
+ }
60
40
  }
61
41
 
62
- // Phase 2: Parallel queries with pre-collected keys
63
- const [spoolObjects, spoolRewardObjects, sCoinTreasuryObjects] =
64
- await Promise.all([
65
- query.scallopSuiKit.queryGetObjects(keyCollections.spool),
66
- query.scallopSuiKit.queryGetObjects(keyCollections.spoolReward),
67
- query.scallopSuiKit.queryGetObjects(keyCollections.sCoinTreasury),
68
- ]);
69
-
70
- // Phase 3: Create lookup maps
71
- const createObjectMap = (objects: SuiObjectData[]) =>
72
- new Map(objects.map((obj) => [obj.objectId, obj]));
73
-
74
- const objectMaps = {
75
- spool: createObjectMap(spoolObjects),
76
- spoolReward: createObjectMap(spoolRewardObjects),
77
- sCoinTreasury: createObjectMap(sCoinTreasuryObjects),
78
- };
42
+ const objectDatas: SuiObjectData[] = [];
43
+ const batches = partitionArray(allObjectIds, 50);
79
44
 
80
- // Phase 4: Build result in single pass
81
- const result: Record<string, any> = {};
82
- for (const [poolCoinName, task] of taskMap) {
83
- result[poolCoinName] = {
84
- spool: task.spool ? objectMaps.spool.get(task.spool) : undefined,
85
- spoolReward: task.spoolReward
86
- ? objectMaps.spoolReward.get(task.spoolReward)
87
- : undefined,
88
- sCoinTreasury: task.sCoinTreasury
89
- ? objectMaps.sCoinTreasury.get(task.sCoinTreasury)
90
- : undefined,
91
- };
45
+ console.log('Fetching spool objects in batches:', batches.length);
46
+
47
+ for (const batch of batches) {
48
+ const responses = await query.scallopSuiKit.queryGetObjects(batch);
49
+ if (responses.length > 0) {
50
+ objectDatas.push(...responses);
51
+ }
92
52
  }
93
53
 
94
- return result as Record<
54
+ // Transform into map
55
+ const objectDataMap = objectDatas.reduce(
56
+ (acc, obj) => {
57
+ acc[obj.objectId] = obj;
58
+ return acc;
59
+ },
60
+ {} as Record<string, SuiObjectData>
61
+ );
62
+
63
+ const results: Record<
95
64
  string,
96
- {
97
- spool?: SuiObjectData;
98
- spoolReward?: SuiObjectData;
99
- sCoinTreasury?: SuiObjectData;
65
+ Record<(typeof keyTypes)[number], SuiObjectData>
66
+ > = {};
67
+
68
+ for (const poolCoinName of stakePoolCoinNames) {
69
+ const poolData = query.constants.poolAddresses[poolCoinName];
70
+ for (const keyType of keyTypes) {
71
+ const objectId = poolData?.[keyType];
72
+ if (objectId && objectId !== '') {
73
+ if (!results[poolCoinName]) {
74
+ results[poolCoinName] = {} as Record<
75
+ (typeof keyTypes)[number],
76
+ SuiObjectData
77
+ >;
78
+ }
79
+ results[poolCoinName][keyType] = objectDataMap[objectId];
80
+ }
100
81
  }
101
- >;
82
+ }
83
+
84
+ return results;
102
85
  };
103
86
 
104
87
  const parseSpoolObjects = ({
@@ -164,11 +147,11 @@ export const getSpools = async (
164
147
  if (!stakeMarketCoinNames.includes(spool.marketCoinName)) return;
165
148
  const coinName = query.utils.parseCoinName(spool.marketCoinName);
166
149
  const rewardCoinName = query.utils.getSpoolRewardCoinName();
167
- spool.coinPrice = coinPrices?.[coinName] ?? spool.coinPrice;
150
+ spool.coinPrice = coinPrices[coinName] ?? spool.coinPrice;
168
151
  spool.marketCoinPrice =
169
- coinPrices?.[spool.marketCoinName] ?? spool.marketCoinPrice;
152
+ coinPrices[spool.marketCoinName] ?? spool.marketCoinPrice;
170
153
  spool.rewardCoinPrice =
171
- coinPrices?.[rewardCoinName] ?? spool.rewardCoinPrice;
154
+ coinPrices[rewardCoinName] ?? spool.rewardCoinPrice;
172
155
  spools[spool.marketCoinName] = spool;
173
156
  };
174
157
  Object.values(spoolsIndexer)
@@ -1,16 +1,16 @@
1
1
  import BigNumber from 'bignumber.js';
2
- import { VeScaTreasuryFields, VeScaTreasuryInfo, Vesca } from 'src/types/query';
2
+ import { VeScaTreasuryFields, VeScaTreasuryInfo, Vesca } from 'src/types';
3
3
  import {
4
4
  type SuiObjectResponse,
5
5
  type SuiObjectData,
6
6
  DevInspectResults,
7
7
  } from '@mysten/sui/client';
8
8
  import type { ScallopUtils } from 'src/models';
9
- import { MAX_LOCK_DURATION } from 'src/constants/vesca';
9
+ import { MAX_LOCK_DURATION } from 'src/constants';
10
10
  import { SUI_CLOCK_OBJECT_ID, SuiTxBlock } from '@scallop-io/sui-kit';
11
11
  import { bcs } from '@mysten/sui/bcs';
12
12
  import { z as zod } from 'zod';
13
- import { queryKeys } from 'src/constants/queryKeys';
13
+ import { queryKeys } from 'src/constants';
14
14
  import assert from 'assert';
15
15
  /**
16
16
  * Query all owned veSca key.
@@ -1,6 +1,6 @@
1
1
  import { SuiObjectResponse } from '@mysten/sui/client';
2
2
  import { ScallopAddress, ScallopSuiKit, ScallopUtils } from 'src/models';
3
- import { SupportOracleType, xOracleRuleType } from 'src/types/constant';
3
+ import { SupportOracleType, xOracleRuleType } from 'src/types';
4
4
 
5
5
  /**
6
6
  * Query the price update policy table ids. Usually the value for these table will be constant.
@@ -61,28 +61,11 @@ export const getAssetOracles = async (
61
61
  return null;
62
62
  }
63
63
 
64
- const createRuleType = (objectId: string): string => {
65
- return `${objectId}::rule::Rule`;
66
- };
67
-
68
- const pythLstRuleTypeNameToOracleType: Record<string, SupportOracleType> =
69
- Object.values<{
70
- object: string;
71
- }>(utils.address.get('core.packages.pyth.lst') ?? {}).reduce(
72
- (acc, curr) => {
73
- acc[createRuleType(curr.object)] = 'pyth';
74
- return acc;
75
- },
76
- {} as Record<string, SupportOracleType>
77
- );
78
-
79
64
  const ruleTypeNameToOracleType: Record<string, SupportOracleType> = {
80
- [createRuleType(utils.address.get('core.packages.pyth.object'))]: 'pyth',
81
- // include the pyth lst type
82
- [createRuleType(utils.address.get('core.packages.supra.object'))]: 'supra',
83
- [createRuleType(utils.address.get('core.packages.switchboard.object'))]:
65
+ [`${utils.address.get('core.packages.pyth.object')}::rule::Rule`]: 'pyth',
66
+ [`${utils.address.get('core.packages.supra.object')}::rule::Rule`]: 'supra',
67
+ [`${utils.address.get('core.packages.switchboard.object')}::rule::Rule`]:
84
68
  'switchboard',
85
- ...pythLstRuleTypeNameToOracleType,
86
69
  };
87
70
 
88
71
  const assetOracles = {} as Record<string, SupportOracleType[]>;
@@ -1,67 +1,5 @@
1
- import { SUPPORT_ORACLE_LST, SUPPORT_ORACLES } from 'src/constants/xoracle';
2
- import { SupportOracleType, SupportedOracleSuiLst } from './constant/xOracle';
3
- import { PackageName } from './constant/package';
1
+ import { _SUPPORT_ORACLES, SupportOracleType } from './constant/xOracle';
4
2
 
5
- export type BasePackage = {
6
- id: string;
7
- object?: string;
8
- upgradeCap?: string;
9
- };
10
-
11
- export type OracleLstPackage = {
12
- [K in SupportedOracleSuiLst]: BasePackage;
13
- };
14
-
15
- type OraclePackage<T> = BasePackage & T extends SupportOracleLst
16
- ? BasePackage & {
17
- lst: OracleLstPackage;
18
- }
19
- : BasePackage;
20
-
21
- type Packages<
22
- T extends SupportOracleType | PackageName = SupportOracleType | PackageName,
23
- > = T extends SupportOracleType
24
- ? Record<T, OraclePackage<T>>
25
- : T extends PackageName
26
- ? Record<T, BasePackage>
27
- : never;
28
-
29
- export type SupportOracleLst = (typeof SUPPORT_ORACLE_LST)[number];
30
-
31
- type PythOracleLstConfigItem<T extends SupportedOracleSuiLst, U> = Record<
32
- T,
33
- { configId: string } & U
34
- >;
35
-
36
- export type PythOracleLstConfig<
37
- T extends SupportedOracleSuiLst = SupportedOracleSuiLst,
38
- > = T extends 'afsui'
39
- ? PythOracleLstConfigItem<
40
- 'afsui',
41
- {
42
- stakedSuiVaultId: string;
43
- safeId: string;
44
- configId: string;
45
- }
46
- >
47
- : T extends 'hasui'
48
- ? PythOracleLstConfigItem<
49
- 'hasui',
50
- {
51
- staking: string;
52
- }
53
- >
54
- : never;
55
-
56
- export type OracleLst<T extends SupportOracleLst> = T extends 'pyth'
57
- ? PythOracleLstConfig
58
- : never;
59
-
60
- type MaybeWithOracleLst<T, U> = T extends SupportOracleLst
61
- ? U & {
62
- lst: OracleLst<T>;
63
- }
64
- : U;
65
3
  export interface AddressesInterface {
66
4
  id?: string;
67
5
  core: {
@@ -83,11 +21,11 @@ export interface AddressesInterface {
83
21
  symbol: string;
84
22
  decimals: number;
85
23
  oracle: {
86
- [K in SupportOracleType]: K extends (typeof SUPPORT_ORACLES)[0]
24
+ [K in SupportOracleType]: K extends (typeof _SUPPORT_ORACLES)[0]
87
25
  ? string
88
- : K extends (typeof SUPPORT_ORACLES)[1]
26
+ : K extends (typeof _SUPPORT_ORACLES)[1]
89
27
  ? string
90
- : K extends (typeof SUPPORT_ORACLES)[2]
28
+ : K extends (typeof _SUPPORT_ORACLES)[2]
91
29
  ? {
92
30
  feed: string;
93
31
  feedObject: string;
@@ -98,36 +36,27 @@ export interface AddressesInterface {
98
36
  >
99
37
  >;
100
38
  oracles: {
101
- [K in SupportOracleType]: K extends (typeof SUPPORT_ORACLES)[0]
102
- ? MaybeWithOracleLst<
103
- K,
104
- {
39
+ [K in SupportOracleType]: K extends (typeof _SUPPORT_ORACLES)[0]
40
+ ? {
41
+ registry: string;
42
+ registryCap: string;
43
+ holder: string;
44
+ }
45
+ : K extends (typeof _SUPPORT_ORACLES)[1]
46
+ ? {
105
47
  registry: string;
106
48
  registryCap: string;
107
- holder: string;
49
+ registryTableId: string;
50
+ state: string;
108
51
  }
109
- >
110
- : K extends (typeof SUPPORT_ORACLES)[1]
111
- ? MaybeWithOracleLst<
112
- K,
113
- {
52
+ : K extends (typeof _SUPPORT_ORACLES)[2]
53
+ ? {
114
54
  registry: string;
115
55
  registryCap: string;
116
- registryTableId: string;
117
56
  state: string;
57
+ wormhole: string;
58
+ wormholeState: string;
118
59
  }
119
- >
120
- : K extends (typeof SUPPORT_ORACLES)[2]
121
- ? MaybeWithOracleLst<
122
- K,
123
- {
124
- registry: string;
125
- registryCap: string;
126
- state: string;
127
- wormhole: string;
128
- wormholeState: string;
129
- }
130
- >
131
60
  : never;
132
61
  } & {
133
62
  xOracle: string;
@@ -137,7 +66,16 @@ export interface AddressesInterface {
137
66
  primaryPriceUpdatePolicyVecsetId: string;
138
67
  secondaryPriceUpdatePolicyVecsetId: string;
139
68
  };
140
- packages: Packages;
69
+ packages: Partial<
70
+ Record<
71
+ string,
72
+ {
73
+ id: string;
74
+ object?: string;
75
+ upgradeCap: string;
76
+ }
77
+ >
78
+ >;
141
79
  };
142
80
  spool: {
143
81
  id: string;
@@ -218,12 +156,23 @@ export interface AddressesInterface {
218
156
  };
219
157
  }
220
158
 
221
- type Paths<T> = T extends object
222
- ? {
223
- [K in Extract<keyof T, string>]: T[K] extends object // if T[K] is itself an object, emit K *and* K.<deep>
224
- ? K | `${K}.${Paths<T[K]>}`
225
- : K;
226
- }[Extract<keyof T, string>]
227
- : never;
159
+ type AddressPathsProps<T> = T extends string
160
+ ? []
161
+ : {
162
+ [K in Extract<keyof T, string>]: [K, ...AddressPathsProps<T[K]>];
163
+ }[Extract<keyof T, string>];
228
164
 
229
- export type AddressStringPath = Paths<AddressesInterface>;
165
+ type Join<T extends string[], D extends string> = T extends []
166
+ ? never
167
+ : T extends [infer F]
168
+ ? F
169
+ : T extends [infer F, ...infer R]
170
+ ? F extends string
171
+ ? `${F}${D}${Join<Extract<R, string[]>, D>}`
172
+ : never
173
+ : string;
174
+
175
+ export type AddressStringPath = Join<
176
+ AddressPathsProps<AddressesInterface>,
177
+ '.'
178
+ >;
@@ -16,16 +16,12 @@ export type CoreIds = {
16
16
  };
17
17
 
18
18
  export type NestedResult = Extract<Argument, { $kind: 'NestedResult' }>;
19
- type ResultAsObligation = NestedResult;
20
- type ResultAsObligationKey = NestedResult;
21
- type ResultAsObligationHotPotato = NestedResult;
19
+ type Obligation = NestedResult;
20
+ type ObligationKey = NestedResult;
21
+ type ObligationHotPotato = NestedResult;
22
22
 
23
23
  export type CoreNormalMethods = {
24
- openObligation: () => [
25
- ResultAsObligation,
26
- ResultAsObligationKey,
27
- ResultAsObligationHotPotato,
28
- ];
24
+ openObligation: () => [Obligation, ObligationKey, ObligationHotPotato];
29
25
  returnObligation: (
30
26
  obligation: SuiObjectArg,
31
27
  obligationHotPotato: SuiObjectArg
@@ -91,31 +87,51 @@ export type CoreQuickMethods = {
91
87
  addCollateralQuick: (
92
88
  amount: number,
93
89
  collateralCoinName: string,
94
- obligationId?: SuiObjectArg
90
+ obligationId?: SuiObjectArg,
91
+ isSponsoredTx?: boolean
95
92
  ) => Promise<void>;
96
93
  takeCollateralQuick: (
97
94
  amount: number,
98
95
  collateralCoinName: string,
99
96
  obligationId?: SuiObjectArg,
100
- obligationKey?: SuiObjectArg
97
+ obligationKey?: SuiObjectArg,
98
+ updateOracleOptions?: {
99
+ usePythPullModel?: boolean;
100
+ useOnChainXOracleList?: boolean;
101
+ sponsoredFeeds?: string[];
102
+ isSponsoredTx?: boolean;
103
+ }
101
104
  ) => Promise<TransactionResult>;
102
105
  borrowQuick: (
103
106
  amount: number,
104
107
  poolCoinName: string,
105
108
  obligationId?: SuiObjectArg,
106
- obligationKey?: SuiObjectArg
109
+ obligationKey?: SuiObjectArg,
110
+ updateOracleOptions?: {
111
+ usePythPullModel?: boolean;
112
+ useOnChainXOracleList?: boolean;
113
+ sponsoredFeeds?: string[];
114
+ isSponsoredTx?: boolean;
115
+ }
107
116
  ) => Promise<TransactionResult>;
108
117
  borrowWithReferralQuick: (
109
118
  amount: number,
110
119
  poolCoinName: string,
111
120
  borrowReferral: SuiObjectArg,
112
121
  obligationId?: SuiObjectArg,
113
- obligationKey?: SuiObjectArg
122
+ obligationKey?: SuiObjectArg,
123
+ updateOracleOptions?: {
124
+ usePythPullModel?: boolean;
125
+ useOnChainXOracleList?: boolean;
126
+ sponsoredFeeds?: string[];
127
+ isSponsoredTx?: boolean;
128
+ }
114
129
  ) => Promise<TransactionResult>;
115
130
  depositQuick: (
116
131
  amount: number,
117
132
  poolCoinName: string,
118
- returnSCoin?: boolean
133
+ returnSCoin?: boolean,
134
+ isSponsoredTx?: boolean
119
135
  ) => Promise<TransactionResult>;
120
136
  withdrawQuick: (
121
137
  amount: number,
@@ -124,9 +140,18 @@ export type CoreQuickMethods = {
124
140
  repayQuick: (
125
141
  amount: number,
126
142
  poolCoinName: string,
127
- obligationId?: SuiObjectArg
143
+ obligationId?: SuiObjectArg,
144
+ isSponsoredTx?: boolean
145
+ ) => Promise<void>;
146
+ updateAssetPricesQuick: (
147
+ assetCoinNames?: string[],
148
+ updateOracleOptions?: {
149
+ usePythPullModel?: boolean;
150
+ useOnChainXOracleList?: boolean;
151
+ sponsoredFeeds?: string[];
152
+ isSponsoredTx?: boolean;
153
+ }
128
154
  ) => Promise<void>;
129
- updateAssetPricesQuick: (assetCoinNames?: string[]) => Promise<void>;
130
155
  };
131
156
 
132
157
  export type SuiTxBlockWithCoreNormalMethods = SuiKitTxBlock &