@scallop-io/sui-scallop-sdk 2.2.3-pyth-sponsored-transaction-alpha.1 → 2.3.0-lst-x-oracle-alpha.2

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 (74) hide show
  1. package/dist/address-CW2IpaLn.d.ts +165 -0
  2. package/dist/chunk-E3URAUAC.js +25 -0
  3. package/dist/chunk-YA77R5GT.mjs +5 -0
  4. package/dist/constants/index.d.mts +262 -0
  5. package/dist/constants/index.d.ts +262 -0
  6. package/dist/constants/index.js +86 -0
  7. package/dist/constants/index.mjs +5 -0
  8. package/dist/index.d.mts +11 -3242
  9. package/dist/index.d.ts +11 -3242
  10. package/dist/index.js +0 -47
  11. package/dist/index.mjs +0 -14
  12. package/dist/models/index.d.mts +393 -0
  13. package/dist/models/index.d.ts +393 -0
  14. package/dist/models/index.js +34 -0
  15. package/dist/models/index.mjs +16 -0
  16. package/dist/queryKeys-AaZqDYle.d.ts +43 -0
  17. package/dist/scallopUtils-BZLZd2z8.d.ts +2404 -0
  18. package/dist/types/index.d.mts +9 -0
  19. package/dist/types/index.d.ts +9 -0
  20. package/dist/types/index.js +2 -0
  21. package/dist/types/index.mjs +1 -0
  22. package/package.json +31 -4
  23. package/src/builders/borrowIncentiveBuilder.ts +2 -2
  24. package/src/builders/coreBuilder.ts +5 -14
  25. package/src/builders/index.ts +2 -2
  26. package/src/builders/oracles/error.ts +29 -0
  27. package/src/builders/oracles/index.ts +114 -365
  28. package/src/builders/oracles/oraclePackageRegistry.ts +323 -0
  29. package/src/builders/oracles/priceFeedUpdater.ts +112 -0
  30. package/src/builders/oracles/priceUpdateRequester.ts +50 -0
  31. package/src/builders/oracles/xOracleUpdateStrategy.ts +178 -0
  32. package/src/builders/oracles/xOracleUpdater.ts +160 -0
  33. package/src/builders/vescaBuilder.ts +2 -2
  34. package/src/constants/api.ts +2 -0
  35. package/src/constants/common.ts +0 -3
  36. package/src/constants/index.ts +2 -1
  37. package/src/constants/package.ts +14 -0
  38. package/src/constants/testAddress.ts +190 -105
  39. package/src/constants/xoracle.ts +8 -2
  40. package/src/index.ts +2 -12
  41. package/src/models/index.ts +2 -1
  42. package/src/models/interface.ts +6 -6
  43. package/src/models/scallopAddress.ts +24 -4
  44. package/src/models/scallopBuilder.ts +4 -4
  45. package/src/models/scallopClient.ts +1 -1
  46. package/src/models/scallopConstants.ts +2 -2
  47. package/src/models/scallopIndexer.ts +3 -2
  48. package/src/models/scallopQuery.ts +52 -36
  49. package/src/models/scallopQueryClient.ts +1 -1
  50. package/src/models/scallopSuiKit.ts +1 -1
  51. package/src/models/scallopUtils.ts +5 -8
  52. package/src/queries/borrowIncentiveQuery.ts +2 -3
  53. package/src/queries/coreQuery.ts +2 -3
  54. package/src/queries/index.ts +4 -3
  55. package/src/queries/loyaltyProgramQuery.ts +1 -1
  56. package/src/queries/portfolioQuery.ts +13 -13
  57. package/src/queries/sCoinQuery.ts +2 -2
  58. package/src/queries/spoolQuery.ts +8 -8
  59. package/src/queries/vescaQuery.ts +2 -2
  60. package/src/queries/xOracleQuery.ts +20 -3
  61. package/src/types/address.ts +85 -47
  62. package/src/types/builder/core.ts +2 -4
  63. package/src/types/constant/index.ts +2 -1
  64. package/src/types/constant/package.ts +3 -0
  65. package/src/types/constant/xOracle.ts +10 -7
  66. package/src/types/query/index.ts +0 -1
  67. package/src/utils/builder.ts +1 -1
  68. package/src/utils/index.ts +2 -2
  69. package/src/utils/query.ts +6 -6
  70. package/src/utils/util.ts +1 -1
  71. package/src/builders/oracles/pyth.ts +0 -52
  72. package/src/queries/ownerQuery.ts +0 -32
  73. package/src/types/constant/enum.ts +0 -64
  74. package/src/types/query/sCoin.ts +0 -1
@@ -10,9 +10,10 @@ import {
10
10
  Spool,
11
11
  Spools,
12
12
  TotalValueLocked,
13
- } from 'src/types';
13
+ } from 'src/types/query';
14
14
  import ScallopAxios, { ScallopAxiosParams } from './scallopAxios';
15
- import { queryKeys, SDK_API_BASE_URL } from 'src/constants';
15
+ import { SDK_API_BASE_URL } from 'src/constants/api';
16
+ import { queryKeys } from 'src/constants/queryKeys';
16
17
 
17
18
  export type ScallopIndexerParams = {
18
19
  indexerApiUrl?: string;
@@ -2,65 +2,82 @@ import ScallopUtils, { ScallopUtilsParams } from './scallopUtils';
2
2
  import ScallopIndexer, { ScallopIndexerParams } from './scallopIndexer';
3
3
  import { withIndexerFallback } from 'src/utils';
4
4
  import {
5
- CoinPrices,
6
5
  MarketCollaterals,
7
6
  MarketPool,
8
7
  MarketPools,
9
8
  StakePools,
10
9
  StakeRewardPools,
11
- SupportOracleType,
12
- xOracleRules,
13
- } from 'src/types';
10
+ } from 'src/types/query';
11
+ import { SuiObjectRef, SuiObjectData } from '@mysten/sui/dist/cjs/client';
12
+ import { SuiObjectArg } from '@scallop-io/sui-kit';
13
+ import { ScallopQueryInterface } from './interface';
14
14
  import {
15
- getAllCoinPrices,
16
- getAssetOracles,
15
+ getBorrowIncentivePools,
16
+ queryBorrowIncentiveAccounts,
17
17
  getBindedObligationId,
18
18
  getBindedVeScaKey,
19
- getBorrowIncentivePools,
20
- getBorrowLimit,
21
- getCoinAmount,
19
+ } from 'src/queries/borrowIncentiveQuery';
20
+ import { getBorrowLimit } from 'src/queries/borrowLimitQuery';
21
+ import {
22
+ queryMarket,
23
+ getMarketPools,
24
+ getMarketCollaterals,
25
+ getMarketCollateral,
26
+ getObligations,
27
+ queryObligation,
22
28
  getCoinAmounts,
29
+ getCoinAmount,
30
+ getMarketCoinAmounts,
31
+ getMarketCoinAmount,
23
32
  getFlashLoanFees,
33
+ } from 'src/queries/coreQuery';
34
+ import {
24
35
  getIsolatedAssets,
25
- getLending,
26
- getLendings,
36
+ isIsolatedAsset,
37
+ } from 'src/queries/isolatedAssetQuery';
38
+ import {
27
39
  getLoyaltyProgramInformations,
28
- getMarketCoinAmount,
29
- getMarketCoinAmounts,
30
- getMarketCollateral,
31
- getMarketCollaterals,
32
- getMarketPools,
40
+ getVeScaLoyaltyProgramInformations,
41
+ } from 'src/queries/loyaltyProgramQuery';
42
+ import { getPoolAddresses } from 'src/queries/poolAddressesQuery';
43
+ import {
44
+ getLendings,
45
+ getLending,
33
46
  getObligationAccounts,
34
- getObligations,
35
- getOnDemandAggObjectIds,
36
- getPoolAddresses,
37
- getPriceUpdatePolicies,
47
+ getTotalValueLocked,
48
+ getUserPortfolio,
49
+ } from 'src/queries/portfolioQuery';
50
+ import {
38
51
  getPythPrice,
39
52
  getPythPrices,
40
- getSCoinAmount,
53
+ getAllCoinPrices,
54
+ } from 'src/queries/priceQuery';
55
+ import { queryVeScaKeyIdFromReferralBindings } from 'src/queries/referralQuery';
56
+ import {
57
+ getSCoinTotalSupply,
41
58
  getSCoinAmounts,
59
+ getSCoinAmount,
42
60
  getSCoinSwapRate,
43
- getSCoinTotalSupply,
61
+ } from 'src/queries/sCoinQuery';
62
+ import {
44
63
  getSpools,
45
64
  getStakeAccounts,
46
65
  getStakePool,
47
66
  getStakeRewardPool,
48
- getSupplyLimit,
49
- getTotalValueLocked,
50
- getUserPortfolio,
67
+ } from 'src/queries/spoolQuery';
68
+ import { getSupplyLimit } from 'src/queries/supplyLimitQuery';
69
+ import { getOnDemandAggObjectIds } from 'src/queries/switchboardQuery';
70
+ import {
51
71
  getVeSca,
52
- getVeScaLoyaltyProgramInformations,
53
72
  getVeScas,
54
73
  getVeScaTreasuryInfo,
55
- isIsolatedAsset,
56
- queryBorrowIncentiveAccounts,
57
- queryMarket,
58
- queryObligation,
59
- queryVeScaKeyIdFromReferralBindings,
60
- } from 'src/queries';
61
- import { SuiObjectRef, SuiObjectData } from '@mysten/sui/dist/cjs/client';
62
- import { SuiObjectArg } from '@scallop-io/sui-kit';
63
- import { ScallopQueryInterface } from './interface';
74
+ } from 'src/queries/vescaQuery';
75
+ import {
76
+ getPriceUpdatePolicies,
77
+ getAssetOracles,
78
+ } from 'src/queries/xOracleQuery';
79
+ import { CoinPrices } from 'src/types/utils';
80
+ import { SupportOracleType, xOracleRules } from 'src/types/constant';
64
81
 
65
82
  export type ScallopQueryParams = {
66
83
  indexer?: ScallopIndexer;
@@ -851,7 +868,6 @@ class ScallopQuery implements ScallopQueryInterface {
851
868
 
852
869
  /**
853
870
  * Return the supported primary and secondary oracles for all supported pool assets
854
- * @returns
855
871
  */
856
872
  async getAssetOracles() {
857
873
  const [primary, secondary] = await Promise.all([
@@ -1,5 +1,5 @@
1
1
  import { QueryClient, QueryClientConfig } from '@tanstack/query-core';
2
- import { DEFAULT_CACHE_OPTIONS } from 'src/constants';
2
+ import { DEFAULT_CACHE_OPTIONS } from 'src/constants/cache';
3
3
 
4
4
  export type ScallopQueryClientParams = {
5
5
  queryClient?: QueryClient;
@@ -8,7 +8,7 @@ import {
8
8
  SuiTxBlock,
9
9
  Transaction,
10
10
  } from '@scallop-io/sui-kit';
11
- import { queryKeys } from 'src/constants';
11
+ import { queryKeys } from 'src/constants/queryKeys';
12
12
  import {
13
13
  CoinBalance,
14
14
  DevInspectResults,
@@ -7,18 +7,16 @@ import {
7
7
  Transaction,
8
8
  } from '@scallop-io/sui-kit';
9
9
  import ScallopConstants, { ScallopConstantsParams } from './scallopConstants';
10
- import { CoinPrices, CoinWrappedType, PoolAddress } from 'src/types';
11
10
  import { findClosestUnlockRound } from 'src/utils';
12
- import {
13
- MAX_LOCK_DURATION,
14
- queryKeys,
15
- UNLOCK_ROUND_DURATION,
16
- } from 'src/constants';
17
11
  import { PriceFeed, SuiPriceServiceConnection } from '@pythnetwork/pyth-sui-js';
18
12
  import ScallopSuiKit, { ScallopSuiKitParams } from './scallopSuiKit';
19
13
  import { SuiObjectData } from '@mysten/sui/dist/cjs/client';
20
- import { queryObligation } from 'src/queries';
14
+ import { queryObligation } from 'src/queries/coreQuery';
21
15
  import { ScallopUtilsInterface } from './interface';
16
+ import { MAX_LOCK_DURATION, UNLOCK_ROUND_DURATION } from 'src/constants/vesca';
17
+ import { queryKeys } from 'src/constants/queryKeys';
18
+ import { CoinWrappedType, PoolAddress } from 'src/types/constant';
19
+ import { CoinPrices } from 'src/types/utils';
22
20
 
23
21
  export type ScallopUtilsParams = {
24
22
  pythEndpoints?: string[];
@@ -43,7 +41,6 @@ class ScallopUtils implements ScallopUtilsInterface {
43
41
 
44
42
  this.pythEndpoints = params.pythEndpoints ?? [
45
43
  'https://hermes.pyth.network',
46
- 'https://scallop.rpc.p2p.world',
47
44
  ];
48
45
  }
49
46
 
@@ -16,12 +16,11 @@ import type {
16
16
  BorrowIncentiveAccountsQueryInterface,
17
17
  BorrowIncentiveAccounts,
18
18
  BorrowIncentivePoolPoints,
19
- OptionalKeys,
20
- CoinPrices,
21
19
  MarketPools,
22
- } from 'src/types';
20
+ } from 'src/types/query';
23
21
  import BigNumber from 'bignumber.js';
24
22
  import { SuiObjectRef } from '@mysten/sui/client';
23
+ import { CoinPrices, OptionalKeys } from 'src/types/utils';
25
24
 
26
25
  /**
27
26
  * Query borrow incentive pools data using moveCall
@@ -26,13 +26,11 @@ import {
26
26
  BalanceSheet,
27
27
  RiskModel,
28
28
  CollateralStat,
29
- OptionalKeys,
30
- CoinPrices,
31
29
  OriginMarketPoolData,
32
30
  BorrowFee,
33
31
  BorrowDynamic,
34
32
  OriginMarketCollateralData,
35
- } from 'src/types';
33
+ } from 'src/types/query';
36
34
  import BigNumber from 'bignumber.js';
37
35
  import { getSupplyLimit } from './supplyLimitQuery';
38
36
  import { isIsolatedAsset } from './isolatedAssetQuery';
@@ -45,6 +43,7 @@ import {
45
43
  ScallopIndexer,
46
44
  ScallopAddress,
47
45
  } from 'src/models';
46
+ import { CoinPrices, OptionalKeys } from 'src/types';
48
47
 
49
48
  /**
50
49
  * Query market data.
@@ -1,15 +1,16 @@
1
1
  export * from './borrowIncentiveQuery';
2
+ export * from './borrowLimitQuery';
2
3
  export * from './coreQuery';
4
+ export * from './flashloanFeeQuery';
3
5
  export * from './isolatedAssetQuery';
4
6
  export * from './loyaltyProgramQuery';
7
+ export * from './poolAddressesQuery';
5
8
  export * from './portfolioQuery';
6
9
  export * from './priceQuery';
7
10
  export * from './referralQuery';
8
11
  export * from './sCoinQuery';
9
12
  export * from './spoolQuery';
10
13
  export * from './supplyLimitQuery';
11
- export * from './vescaQuery';
12
- export * from './borrowLimitQuery';
13
- export * from './poolAddressesQuery';
14
14
  export * from './switchboardQuery';
15
+ export * from './vescaQuery';
15
16
  export * from './xOracleQuery';
@@ -1,6 +1,6 @@
1
1
  import { SuiObjectData } from '@mysten/sui/client';
2
2
  import BigNumber from 'bignumber.js';
3
- import { MAX_LOCK_DURATION } from 'src/constants';
3
+ import { MAX_LOCK_DURATION } from 'src/constants/vesca';
4
4
  import { ScallopQuery } from 'src/models';
5
5
  import { LoyaltyProgramInfo, VeScaLoyaltyProgramInfo } from 'src/types';
6
6
  import { z as zod } from 'zod';
@@ -1,24 +1,24 @@
1
1
  import BigNumber from 'bignumber.js';
2
2
  import { minBigNumber, estimatedFactor } from 'src/utils';
3
3
  import type { ScallopQuery } from 'src/models';
4
- import type {
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,
5
10
  Market,
11
+ MarketCollaterals,
6
12
  MarketPool,
13
+ MarketPools,
14
+ ObligationAccount,
15
+ ObligationAccounts,
16
+ ObligationBorrowIncentiveReward,
7
17
  Spool,
8
18
  StakeAccount,
9
- Lendings,
10
- Lending,
11
- ObligationAccounts,
12
- ObligationAccount,
13
- CoinAmounts,
14
- CoinPrices,
15
19
  TotalValueLocked,
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';
20
+ } from 'src/types/query';
21
+ import { CoinPrices } from 'src/types/utils';
22
22
 
23
23
  /**
24
24
  * Get user lending infomation for specific pools.
@@ -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, sCoinBalance } from 'src/types';
5
+ import { OptionalKeys } 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<sCoinBalance> => {
20
+ ): Promise<number> => {
21
21
  const sCoinPkgId = utils.address.get('scoin.id');
22
22
  // get treasury
23
23
  const args = [utils.getSCoinTreasury(sCoinName)];
@@ -8,18 +8,18 @@ import {
8
8
  } from 'src/utils';
9
9
  import type { SuiObjectData, SuiObjectResponse } from '@mysten/sui/client';
10
10
  import type { ScallopQuery, ScallopUtils } from 'src/models';
11
- import type {
11
+ import { CoinPrices } from 'src/types';
12
+ import {
13
+ OriginSpoolData,
14
+ OriginSpoolRewardPoolData,
15
+ SpoolData,
16
+ MarketPools,
12
17
  Spools,
13
18
  Spool,
19
+ StakeAccounts,
14
20
  StakePool,
15
21
  StakeRewardPool,
16
- StakeAccounts,
17
- CoinPrices,
18
- MarketPools,
19
- OriginSpoolRewardPoolData,
20
- SpoolData,
21
- OriginSpoolData,
22
- } from '../types';
22
+ } from 'src/types/query';
23
23
 
24
24
  const queryRequiredSpoolObjects = async (
25
25
  query: ScallopQuery,
@@ -6,11 +6,11 @@ import {
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';
9
+ import { MAX_LOCK_DURATION } from 'src/constants/vesca';
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';
13
+ import { queryKeys } from 'src/constants/queryKeys';
14
14
  import assert from 'assert';
15
15
  /**
16
16
  * Query all owned veSca key.
@@ -61,11 +61,28 @@ 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
+
64
79
  const ruleTypeNameToOracleType: Record<string, SupportOracleType> = {
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`]:
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'))]:
68
84
  'switchboard',
85
+ ...pythLstRuleTypeNameToOracleType,
69
86
  };
70
87
 
71
88
  const assetOracles = {} as Record<string, SupportOracleType[]>;
@@ -1,5 +1,54 @@
1
- import { _SUPPORT_ORACLES, SupportOracleType } from './constant/xOracle';
1
+ import { SUPPORT_ORACLE_LST, SUPPORT_ORACLES } from 'src/constants/xoracle';
2
+ import { SupportOracleType, SupportedOracleSuiLst } from './constant/xOracle';
3
+ import { PackageName } from './constant/package';
2
4
 
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
+ export type OracleLstConfig<T extends SupportedOracleSuiLst> = T extends 'afsui'
32
+ ? Record<
33
+ T,
34
+ {
35
+ stakedSuiVaultId: string;
36
+ safeId: string;
37
+ configId: string;
38
+ }
39
+ >
40
+ : never;
41
+
42
+ export type OracleLst<
43
+ T extends SupportOracleLst,
44
+ U extends SupportedOracleSuiLst = SupportedOracleSuiLst,
45
+ > = T extends 'pyth' ? OracleLstConfig<U> : undefined;
46
+
47
+ type MaybeWithOracleLst<T, U> = T extends SupportOracleLst
48
+ ? U & {
49
+ lst: OracleLst<T>;
50
+ }
51
+ : U;
3
52
  export interface AddressesInterface {
4
53
  id?: string;
5
54
  core: {
@@ -21,11 +70,11 @@ export interface AddressesInterface {
21
70
  symbol: string;
22
71
  decimals: number;
23
72
  oracle: {
24
- [K in SupportOracleType]: K extends (typeof _SUPPORT_ORACLES)[0]
73
+ [K in SupportOracleType]: K extends (typeof SUPPORT_ORACLES)[0]
25
74
  ? string
26
- : K extends (typeof _SUPPORT_ORACLES)[1]
75
+ : K extends (typeof SUPPORT_ORACLES)[1]
27
76
  ? string
28
- : K extends (typeof _SUPPORT_ORACLES)[2]
77
+ : K extends (typeof SUPPORT_ORACLES)[2]
29
78
  ? {
30
79
  feed: string;
31
80
  feedObject: string;
@@ -36,27 +85,36 @@ export interface AddressesInterface {
36
85
  >
37
86
  >;
38
87
  oracles: {
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
- ? {
88
+ [K in SupportOracleType]: K extends (typeof SUPPORT_ORACLES)[0]
89
+ ? MaybeWithOracleLst<
90
+ K,
91
+ {
47
92
  registry: string;
48
93
  registryCap: string;
49
- registryTableId: string;
50
- state: string;
94
+ holder: string;
51
95
  }
52
- : K extends (typeof _SUPPORT_ORACLES)[2]
53
- ? {
96
+ >
97
+ : K extends (typeof SUPPORT_ORACLES)[1]
98
+ ? MaybeWithOracleLst<
99
+ K,
100
+ {
54
101
  registry: string;
55
102
  registryCap: string;
103
+ registryTableId: string;
56
104
  state: string;
57
- wormhole: string;
58
- wormholeState: string;
59
105
  }
106
+ >
107
+ : K extends (typeof SUPPORT_ORACLES)[2]
108
+ ? MaybeWithOracleLst<
109
+ K,
110
+ {
111
+ registry: string;
112
+ registryCap: string;
113
+ state: string;
114
+ wormhole: string;
115
+ wormholeState: string;
116
+ }
117
+ >
60
118
  : never;
61
119
  } & {
62
120
  xOracle: string;
@@ -66,16 +124,7 @@ export interface AddressesInterface {
66
124
  primaryPriceUpdatePolicyVecsetId: string;
67
125
  secondaryPriceUpdatePolicyVecsetId: string;
68
126
  };
69
- packages: Partial<
70
- Record<
71
- string,
72
- {
73
- id: string;
74
- object?: string;
75
- upgradeCap: string;
76
- }
77
- >
78
- >;
127
+ packages: Packages;
79
128
  };
80
129
  spool: {
81
130
  id: string;
@@ -156,23 +205,12 @@ export interface AddressesInterface {
156
205
  };
157
206
  }
158
207
 
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>];
164
-
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;
208
+ type Paths<T> = T extends object
209
+ ? {
210
+ [K in Extract<keyof T, string>]: T[K] extends object // if T[K] is itself an object, emit K *and* K.<deep>
211
+ ? K | `${K}.${Paths<T[K]>}`
212
+ : K;
213
+ }[Extract<keyof T, string>]
214
+ : never;
174
215
 
175
- export type AddressStringPath = Join<
176
- AddressPathsProps<AddressesInterface>,
177
- '.'
178
- >;
216
+ export type AddressStringPath = Paths<AddressesInterface>;
@@ -99,16 +99,14 @@ export type CoreQuickMethods = {
99
99
  amount: number,
100
100
  poolCoinName: string,
101
101
  obligationId?: SuiObjectArg,
102
- obligationKey?: SuiObjectArg,
103
- isSponsoredTx?: boolean
102
+ obligationKey?: SuiObjectArg
104
103
  ) => Promise<TransactionResult>;
105
104
  borrowWithReferralQuick: (
106
105
  amount: number,
107
106
  poolCoinName: string,
108
107
  borrowReferral: SuiObjectArg,
109
108
  obligationId?: SuiObjectArg,
110
- obligationKey?: SuiObjectArg,
111
- isSponsoredTx?: boolean
109
+ obligationKey?: SuiObjectArg
112
110
  ) => Promise<TransactionResult>;
113
111
  depositQuick: (
114
112
  amount: number,
@@ -1,3 +1,4 @@
1
1
  export type * from './common';
2
- export type * from './enum';
2
+ export type * from './queryKeys';
3
3
  export type * from './xOracle';
4
+ export type * from './package';
@@ -0,0 +1,3 @@
1
+ import { PACKAGE_NAMES } from 'src/constants/package';
2
+
3
+ export type PackageName = (typeof PACKAGE_NAMES)[number];
@@ -1,12 +1,15 @@
1
- export const _SUPPORT_ORACLES = ['supra', 'switchboard', 'pyth'] as const;
2
- export type SupportOracleType = (typeof _SUPPORT_ORACLES)[number];
1
+ import {
2
+ SUPPORT_ORACLES,
3
+ X_ORACLE_RULES,
4
+ SUPPORT_SUI_LST,
5
+ } from 'src/constants/xoracle';
3
6
 
4
- export type xOracleRules = {
5
- primary: SupportOracleType[];
6
- secondary: SupportOracleType[];
7
- };
8
- export type xOracleRuleType = keyof xOracleRules;
7
+ export type SupportOracleType = (typeof SUPPORT_ORACLES)[number];
8
+ export type xOracleRuleType = (typeof X_ORACLE_RULES)[number];
9
+
10
+ export type xOracleRules = Record<xOracleRuleType, SupportOracleType[]>;
9
11
 
10
12
  export type xOracleListType = {
11
13
  [key in string]: xOracleRules;
12
14
  };
15
+ export type SupportedOracleSuiLst = (typeof SUPPORT_SUI_LST)[number];
@@ -2,6 +2,5 @@ export type * from './borrowIncentive';
2
2
  export type * from './core';
3
3
  export type * from './loyaltyProgram';
4
4
  export type * from './portfolio';
5
- export type * from './sCoin';
6
5
  export type * from './spool';
7
6
  export type * from './vesca';
@@ -5,7 +5,7 @@ import {
5
5
  MAX_LOCK_ROUNDS,
6
6
  MIN_INITIAL_LOCK_AMOUNT,
7
7
  MIN_TOP_UP_AMOUNT,
8
- } from 'src/constants';
8
+ } from 'src/constants/vesca';
9
9
  import type { SuiObjectArg } from '@scallop-io/sui-kit';
10
10
 
11
11
  /**
@@ -1,5 +1,5 @@
1
1
  export * from './builder';
2
+ export * from './core';
3
+ export * from './indexer';
2
4
  export * from './query';
3
5
  export * from './util';
4
- export * from './indexer';
5
- export * from './core';