@scallop-io/sui-scallop-sdk 1.5.3 → 2.0.0-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 (60) hide show
  1. package/dist/index.d.mts +451 -602
  2. package/dist/index.d.ts +451 -602
  3. package/dist/index.js +29 -60
  4. package/dist/index.mjs +6 -6
  5. package/package.json +1 -1
  6. package/src/builders/loyaltyProgramBuilder.ts +5 -3
  7. package/src/builders/oracle.ts +10 -24
  8. package/src/builders/referralBuilder.ts +5 -9
  9. package/src/builders/sCoinBuilder.ts +9 -8
  10. package/src/builders/spoolBuilder.ts +4 -6
  11. package/src/constants/common.ts +114 -126
  12. package/src/constants/index.ts +0 -5
  13. package/src/constants/pyth.ts +25 -34
  14. package/src/constants/queryKeys.ts +2 -0
  15. package/src/models/index.ts +1 -0
  16. package/src/models/scallop.ts +23 -19
  17. package/src/models/scallopAddress.ts +7 -4
  18. package/src/models/scallopBuilder.ts +36 -41
  19. package/src/models/scallopCache.ts +1 -1
  20. package/src/models/scallopClient.ts +93 -94
  21. package/src/models/scallopConstants.ts +342 -0
  22. package/src/models/scallopIndexer.ts +11 -24
  23. package/src/models/scallopQuery.ts +70 -77
  24. package/src/models/scallopUtils.ts +122 -249
  25. package/src/queries/borrowIncentiveQuery.ts +21 -56
  26. package/src/queries/borrowLimitQuery.ts +3 -6
  27. package/src/queries/coreQuery.ts +94 -112
  28. package/src/queries/flashloanFeeQuery.ts +86 -0
  29. package/src/queries/isolatedAssetQuery.ts +12 -11
  30. package/src/queries/poolAddressesQuery.ts +187 -112
  31. package/src/queries/portfolioQuery.ts +65 -67
  32. package/src/queries/priceQuery.ts +16 -22
  33. package/src/queries/sCoinQuery.ts +15 -16
  34. package/src/queries/spoolQuery.ts +49 -59
  35. package/src/queries/supplyLimitQuery.ts +2 -6
  36. package/src/queries/xOracleQuery.ts +4 -15
  37. package/src/types/address.ts +12 -18
  38. package/src/types/builder/borrowIncentive.ts +2 -3
  39. package/src/types/builder/core.ts +20 -27
  40. package/src/types/builder/index.ts +1 -2
  41. package/src/types/builder/referral.ts +4 -8
  42. package/src/types/builder/sCoin.ts +4 -8
  43. package/src/types/builder/spool.ts +7 -10
  44. package/src/types/constant/common.ts +43 -49
  45. package/src/types/constant/enum.ts +15 -27
  46. package/src/types/constant/xOracle.ts +3 -5
  47. package/src/types/model.ts +49 -28
  48. package/src/types/query/borrowIncentive.ts +7 -24
  49. package/src/types/query/core.ts +8 -18
  50. package/src/types/query/portfolio.ts +8 -17
  51. package/src/types/query/spool.ts +5 -11
  52. package/src/types/utils.ts +1 -21
  53. package/src/utils/core.ts +1 -1
  54. package/src/utils/query.ts +13 -20
  55. package/src/utils/util.ts +6 -84
  56. package/src/constants/coinGecko.ts +0 -34
  57. package/src/constants/enum.ts +0 -268
  58. package/src/constants/flashloan.ts +0 -18
  59. package/src/constants/poolAddress.ts +0 -898
  60. package/src/models/scallopPrice.ts +0 -0
@@ -5,7 +5,6 @@ import type {
5
5
  } from '@scallop-io/sui-kit';
6
6
  import type { TransactionResult } from '@mysten/sui/transactions';
7
7
  import type { ScallopBuilder } from '../../models';
8
- import type { SupportStakeMarketCoins } from '../constant';
9
8
  import { SuiTxBlockWithSCoin } from '.';
10
9
 
11
10
  export type SpoolIds = {
@@ -13,39 +12,37 @@ export type SpoolIds = {
13
12
  };
14
13
 
15
14
  export type SpoolNormalMethods = {
16
- createStakeAccount: (
17
- stakeMarketCoinName: SupportStakeMarketCoins
18
- ) => TransactionResult;
15
+ createStakeAccount: (stakeMarketCoinName: string) => TransactionResult;
19
16
  stake: (
20
17
  stakeAccount: SuiAddressArg,
21
18
  coin: SuiObjectArg,
22
- stakeMarketCoinName: SupportStakeMarketCoins
19
+ stakeMarketCoinName: string
23
20
  ) => void;
24
21
  unstake: (
25
22
  stakeAccount: SuiAddressArg,
26
23
  amount: number,
27
- stakeMarketCoinName: SupportStakeMarketCoins
24
+ stakeMarketCoinName: string
28
25
  ) => TransactionResult;
29
26
  claim: (
30
27
  stakeAccount: SuiAddressArg,
31
- stakeMarketCoinName: SupportStakeMarketCoins
28
+ stakeMarketCoinName: string
32
29
  ) => TransactionResult;
33
30
  };
34
31
 
35
32
  export type SpoolQuickMethods = {
36
33
  stakeQuick(
37
34
  amountOrMarketCoin: SuiObjectArg | number,
38
- stakeMarketCoinName: SupportStakeMarketCoins,
35
+ stakeMarketCoinName: string,
39
36
  stakeAccountId?: SuiAddressArg
40
37
  ): Promise<void>;
41
38
  unstakeQuick(
42
39
  amount: number,
43
- stakeMarketCoinName: SupportStakeMarketCoins,
40
+ stakeMarketCoinName: string,
44
41
  stakeAccountId?: SuiAddressArg,
45
42
  returnSCoin?: boolean
46
43
  ): Promise<TransactionResult | undefined>;
47
44
  claimQuick(
48
- stakeMarketCoinName: SupportStakeMarketCoins,
45
+ stakeMarketCoinName: string,
49
46
  stakeAccountId?: SuiAddressArg
50
47
  ): Promise<TransactionResult[]>;
51
48
  };
@@ -1,53 +1,47 @@
1
- import {
2
- SUPPORT_POOLS,
3
- SUPPORT_COLLATERALS,
4
- SUPPORT_ORACLES,
5
- SUPPORT_PACKAGES,
6
- SUPPORT_SPOOLS,
7
- SUPPORT_SPOOLS_REWARDS,
8
- SUPPORT_BORROW_INCENTIVE_POOLS,
9
- SUPPORT_BORROW_INCENTIVE_REWARDS,
10
- SUPPORT_SCOIN,
11
- SUPPORT_SUI_BRIDGE,
12
- SUPPORT_WORMHOLE,
13
- } from '../../constants';
1
+ export type PoolAddress = {
2
+ coinName: string;
3
+ symbol: string;
4
+ coinType: string;
5
+ coinMetadataId: string;
6
+ decimals: number;
7
+ // optional keys
8
+ pythFeed?: string;
9
+ pythFeedObjectId?: string;
10
+ lendingPoolAddress?: string;
11
+ borrowDynamic?: string;
12
+ interestModel?: string;
13
+ borrowFeeKey?: string;
14
+ flashloanFeeObject?: string;
15
+ coinGeckoId?: string;
16
+ collateralPoolAddress?: string; // not all pool has collateral
17
+ riskModel?: string;
18
+ supplyLimitKey?: string;
19
+ borrowLimitKey?: string;
20
+ sCoinType?: string;
21
+ sCoinName?: string;
22
+ sCoinSymbol?: string;
23
+ sCoinMetadataId?: string;
24
+ sCoinTreasury?: string;
25
+ isolatedAssetKey?: string;
26
+ spool?: string;
27
+ spoolReward?: string;
28
+ spoolName?: string;
29
+ };
14
30
 
15
- type ParseMarketCoins<T extends string> = `s${T}`;
16
- type ParseCoins<T extends string> = T extends `s${infer R}` ? R : never;
17
-
18
- export type SupportCoins =
19
- | SupportAssetCoins
20
- | SupportMarketCoins
21
- | SupportStakeMarketCoins
22
- | SupportSCoin;
23
- export type SupportAssetCoins =
24
- | SupportPoolCoins
25
- | SupportCollateralCoins
26
- | SupportStakeRewardCoins;
27
- export type SupportPoolCoins = (typeof SUPPORT_POOLS)[number];
28
- export type SupportCollateralCoins = (typeof SUPPORT_COLLATERALS)[number];
29
- export type SupportMarketCoins =
30
- | ParseMarketCoins<SupportPoolCoins>
31
- | SupportStakeMarketCoins;
32
- export type SupportStakeMarketCoins = (typeof SUPPORT_SPOOLS)[number];
33
- export type SupportSuiBridgeCoins = (typeof SUPPORT_SUI_BRIDGE)[number];
34
- export type SupportWormholeCoins = (typeof SUPPORT_WORMHOLE)[number];
35
- export type SupportStakeCoins = Extract<
36
- SupportPoolCoins,
37
- ParseCoins<SupportStakeMarketCoins>
38
- >;
39
- export type SupportStakeRewardCoins = (typeof SUPPORT_SPOOLS_REWARDS)[number];
40
- export type SupportBorrowIncentiveCoins =
41
- (typeof SUPPORT_BORROW_INCENTIVE_POOLS)[number];
42
- export type SupportBorrowIncentiveRewardCoins =
43
- (typeof SUPPORT_BORROW_INCENTIVE_REWARDS)[number];
44
- export type SupportSCoin = (typeof SUPPORT_SCOIN)[number];
45
-
46
- export type SupportOracleType = (typeof SUPPORT_ORACLES)[number];
47
-
48
- export type SupportPackageType = (typeof SUPPORT_PACKAGES)[number];
49
-
50
- export type SupportCoinDecimals = Record<SupportCoins, number>;
31
+ export type Whitelist = {
32
+ lending: Set<string>;
33
+ borrowing: Set<string>;
34
+ collateral: Set<string>;
35
+ packages: Set<string>;
36
+ spool: Set<string>;
37
+ scoin: Set<string>;
38
+ suiBridge: Set<string>;
39
+ wormhole: Set<string>;
40
+ oracles: Set<string>;
41
+ borrowIncentiveRewards: Set<string>;
42
+ pythEndpoints: Set<string>;
43
+ deprecated: Set<string>;
44
+ };
51
45
 
52
46
  export type CoinWrappedType =
53
47
  | {
@@ -1,76 +1,64 @@
1
- import {
2
- SupportCoins,
3
- SupportAssetCoins,
4
- SupportMarketCoins,
5
- SupportStakeMarketCoins,
6
- SupportStakeRewardCoins,
7
- SupportBorrowIncentiveCoins,
8
- SupportBorrowIncentiveRewardCoins,
9
- SupportSCoin,
10
- SupportSuiBridgeCoins,
11
- } from './common';
12
-
13
1
  export type Coins = {
14
- [K in SupportCoins]: K;
2
+ [K in string]: K;
15
3
  };
16
4
 
17
5
  export type AssetCoins = {
18
- [K in SupportAssetCoins]: K;
6
+ [K in string]: K;
19
7
  };
20
8
 
21
9
  export type MarketCoins = {
22
- [K in SupportMarketCoins]: K;
10
+ [K in string]: K;
23
11
  };
24
12
 
25
13
  export type SCoins = {
26
- [K in SupportSCoin]: K;
14
+ [K in string]: K;
27
15
  };
28
16
 
29
17
  export type StakeMarketCoins = {
30
- [K in SupportStakeMarketCoins]: K;
18
+ [K in string]: K;
31
19
  };
32
20
 
33
21
  export type StakeRewardCoins = {
34
- [key in SupportStakeMarketCoins]: SupportStakeRewardCoins;
22
+ [key in string]: string;
35
23
  };
36
24
 
37
25
  export type SuiBridgeCoins = {
38
- [K in SupportSuiBridgeCoins]: K;
26
+ [K in string]: K;
39
27
  };
40
28
 
41
29
  export type BorrowIncentiveRewardCoins = {
42
- [key in SupportBorrowIncentiveCoins]: SupportBorrowIncentiveRewardCoins[];
30
+ [key in string]: string[];
43
31
  };
44
32
 
45
33
  export type AssetCoinIds = {
46
- [key in SupportAssetCoins]: string;
34
+ [key in string]: string;
47
35
  };
48
36
 
49
37
  export type SCoinIds = {
50
- [key in SupportSCoin]: string;
38
+ [key in string]: string;
51
39
  };
52
40
 
53
41
  export type SCoinTreasuryCaps = {
54
- [key in SupportSCoin]: string;
42
+ [key in string]: string;
55
43
  };
56
44
 
57
45
  export type SCoinConverterTreasury = {
58
- [key in SupportSCoin]: string;
46
+ [key in string]: string;
59
47
  };
60
48
 
61
49
  type PickFromUnion<T, K extends string> = K extends T ? K : never;
62
50
 
63
51
  export type WormholeCoinIds = {
64
52
  [key in PickFromUnion<
65
- SupportAssetCoins,
53
+ string,
66
54
  'weth' | 'wbtc' | 'wusdc' | 'wusdt' | 'wapt' | 'wsol'
67
55
  >]: string;
68
56
  };
69
57
 
70
58
  export type VoloCoinIds = {
71
- [key in PickFromUnion<SupportAssetCoins, 'vsui'>]: string;
59
+ [key in PickFromUnion<string, 'vsui'>]: string;
72
60
  };
73
61
 
74
62
  export type SuiBridgedCoinPackageIds = {
75
- [key in SupportSuiBridgeCoins]: string;
63
+ [key in string]: string;
76
64
  };
@@ -1,11 +1,9 @@
1
- import { SupportAssetCoins, SupportOracleType } from './common';
2
-
3
1
  export type xOracleRules = {
4
- primary: SupportOracleType[];
5
- secondary: SupportOracleType[];
2
+ primary: string[];
3
+ secondary: string[];
6
4
  };
7
5
  export type xOracleRuleType = keyof xOracleRules;
8
6
 
9
7
  export type xOracleListType = {
10
- [key in SupportAssetCoins]: xOracleRules;
8
+ [key in string]: xOracleRules;
11
9
  };
@@ -11,6 +11,9 @@ import type {
11
11
  import { ScallopCache } from 'src/models/scallopCache';
12
12
  import { AddressesInterface } from './address';
13
13
  import { QueryClient, QueryClientConfig } from '@tanstack/query-core';
14
+ import { AxiosInstance } from 'axios';
15
+ import { PoolAddress, Whitelist } from './constant';
16
+ import { ScallopConstants } from 'src/models/scallopConstants';
14
17
 
15
18
  export type ScallopClientFnReturnType<T extends boolean> = T extends true
16
19
  ? SuiTransactionBlockResponse
@@ -25,6 +28,7 @@ export type ScallopClientVeScaReturnType<T extends boolean> = T extends true
25
28
 
26
29
  export type ScallopBaseInstanceParams = {
27
30
  suiKit?: SuiKit;
31
+ cache?: ScallopCache;
28
32
  };
29
33
 
30
34
  export type ScallopCacheInstanceParams = ScallopBaseInstanceParams & {
@@ -35,12 +39,17 @@ export type ScallopAddressInstanceParams = ScallopBaseInstanceParams & {
35
39
  cache?: ScallopCache;
36
40
  };
37
41
 
42
+ export type ScallopConstantsInstanceParams = {
43
+ address?: ScallopAddress;
44
+ cache?: ScallopCache;
45
+ };
46
+
38
47
  export type ScallopIndexerInstanceParams = {
39
48
  cache?: ScallopCache;
40
49
  };
41
50
 
42
51
  export type ScallopUtilsInstanceParams = ScallopBaseInstanceParams & {
43
- address?: ScallopAddress;
52
+ constants?: ScallopConstants;
44
53
  };
45
54
 
46
55
  export type ScallopQueryInstanceParams = ScallopBaseInstanceParams & {
@@ -56,40 +65,52 @@ export type ScallopClientInstanceParams = ScallopBaseInstanceParams & {
56
65
  builder?: ScallopBuilder;
57
66
  };
58
67
 
59
- export type ScallopAddressParams = {
60
- id: string;
61
- auth?: string;
62
- network?: NetworkType;
63
- forceInterface?: Partial<Record<NetworkType, AddressesInterface>>;
68
+ export type ScallopCacheConfig = {
69
+ tokensPerInterval?: number; // How many requests per interval
70
+ interval?: number; // Interval in milliseconds
64
71
  };
65
72
 
66
- export type ScallopParams = {
67
- addressId?: string;
68
- forceAddressesInterface?: Partial<Record<NetworkType, AddressesInterface>>;
73
+ export type ScallopCacheParams = {
69
74
  walletAddress?: string;
75
+ cacheOptions?: QueryClientConfig;
76
+ config?: ScallopCacheConfig;
70
77
  } & SuiKitParams;
71
78
 
72
- export type ScallopClientParams = ScallopParams &
73
- ScallopBuilderParams &
74
- ScallopQueryParams &
75
- ScallopUtilsParams &
76
- ScallopCacheParams;
77
-
78
- export type ScallopBuilderParams = ScallopParams & {
79
- pythEndpoints?: string[];
80
- usePythPullModel?: boolean;
81
- useOnChainXOracleList?: boolean;
82
- } & ScallopQueryParams;
79
+ export type ScallopIndexerParams = ScallopCacheParams & {
80
+ indexerApiUrl?: string;
81
+ axios?: AxiosInstance;
82
+ };
83
83
 
84
- export type ScallopQueryParams = ScallopParams & ScallopUtilsParams;
84
+ export type ScallopAddressParams = ScallopCacheParams & {
85
+ addressApiUrl?: string;
86
+ addressId: string;
87
+ auth?: string;
88
+ network?: NetworkType;
89
+ forceAddressesInterface?: Partial<Record<NetworkType, AddressesInterface>>;
90
+ };
85
91
 
86
- export type ScallopUtilsParams = ScallopParams & {
87
- pythEndpoints?: string[];
92
+ export type ScallopConstantsParams = ScallopAddressParams & {
93
+ poolAddressesApiUrl?: string;
94
+ whitelistApiUrl?: string;
95
+ forcePoolAddressInterface?: Record<string, PoolAddress>;
96
+ forceWhitelistInterface?: Whitelist;
88
97
  };
89
98
 
90
- export type ScallopCacheParams = Omit<
91
- ScallopParams,
92
- 'addressId' | 'forceAddressesInterface'
93
- > & {
94
- cacheOptions?: QueryClientConfig;
99
+ export type ScallopUtilsParams = ScallopAddressParams &
100
+ ScallopConstantsParams & {
101
+ pythEndpoints?: string[];
102
+ };
103
+
104
+ export type ScallopQueryParams = ScallopUtilsParams & ScallopIndexerParams;
105
+
106
+ export type ScallopBuilderParams = ScallopQueryParams & {
107
+ usePythPullModel?: boolean;
108
+ useOnChainXOracleList?: boolean;
95
109
  };
110
+
111
+ export type ScallopClientParams = ScallopBuilderParams;
112
+ export type ScallopParams = SuiKitParams &
113
+ ScallopAddressParams &
114
+ ScallopConstantsParams & {
115
+ walletAddress?: string;
116
+ };
@@ -1,8 +1,3 @@
1
- import type {
2
- SupportBorrowIncentiveCoins,
3
- SupportBorrowIncentiveRewardCoins,
4
- } from '../constant';
5
-
6
1
  export interface BorrowIncentiveAccountKey {
7
2
  id: string;
8
3
  onwerId: string;
@@ -13,12 +8,12 @@ type OptionalKeys<T> = {
13
8
  };
14
9
 
15
10
  export type BorrowIncentivePools = OptionalKeys<
16
- Record<SupportBorrowIncentiveCoins, BorrowIncentivePool>
11
+ Record<string, BorrowIncentivePool>
17
12
  >;
18
13
 
19
14
  export type BorrowIncentivePoolPoints = {
20
15
  symbol: string;
21
- coinName: SupportBorrowIncentiveRewardCoins;
16
+ coinName: string;
22
17
  coinType: string;
23
18
  coinDecimal: number;
24
19
  coinPrice: number;
@@ -31,7 +26,7 @@ export type BorrowIncentivePoolPoints = {
31
26
  CalculatedBorrowIncentivePoolPointData;
32
27
 
33
28
  export type BorrowIncentivePool = {
34
- coinName: SupportBorrowIncentiveCoins;
29
+ coinName: string;
35
30
  symbol: string;
36
31
  coinType: string;
37
32
  coinDecimal: number;
@@ -39,9 +34,7 @@ export type BorrowIncentivePool = {
39
34
  stakedAmount: number;
40
35
  stakedCoin: number;
41
36
  stakedValue: number;
42
- points: OptionalKeys<
43
- Record<SupportBorrowIncentiveRewardCoins, BorrowIncentivePoolPoints>
44
- >;
37
+ points: OptionalKeys<Record<string, BorrowIncentivePoolPoints>>;
45
38
  };
46
39
 
47
40
  export type OriginBorrowIncentivePoolPointData = {
@@ -85,12 +78,7 @@ export type ParsedBorrowIncentivePoolPointData = {
85
78
 
86
79
  export type ParsedBorrowIncentivePoolData = {
87
80
  poolType: string;
88
- poolPoints: OptionalKeys<
89
- Record<
90
- SupportBorrowIncentiveRewardCoins,
91
- ParsedBorrowIncentivePoolPointData
92
- >
93
- >;
81
+ poolPoints: OptionalKeys<Record<string, ParsedBorrowIncentivePoolPointData>>;
94
82
  minStakes: number;
95
83
  maxStakes: number;
96
84
  staked: number;
@@ -110,7 +98,7 @@ export type CalculatedBorrowIncentivePoolPointData = {
110
98
  };
111
99
 
112
100
  export type BorrowIncentiveAccounts = OptionalKeys<
113
- Record<SupportBorrowIncentiveCoins, ParsedBorrowIncentiveAccountData>
101
+ Record<string, ParsedBorrowIncentiveAccountData>
114
102
  >;
115
103
 
116
104
  export type OriginBorrowIncentiveAccountPoolData = {
@@ -140,12 +128,7 @@ export type ParsedBorrowIncentiveAccountPoolData = {
140
128
  };
141
129
 
142
130
  export type ParsedBorrowIncentiveAccountData = {
143
- pointList: OptionalKeys<
144
- Record<
145
- SupportBorrowIncentiveRewardCoins,
146
- ParsedBorrowIncentiveAccountPoolData
147
- >
148
- >;
131
+ pointList: OptionalKeys<Record<string, ParsedBorrowIncentiveAccountPoolData>>;
149
132
  poolType: string;
150
133
  debtAmount: number;
151
134
  };
@@ -1,25 +1,15 @@
1
- import type {
2
- SupportPoolCoins,
3
- SupportCollateralCoins,
4
- SupportMarketCoins,
5
- CoinWrappedType,
6
- SupportSCoin,
7
- } from '../constant';
1
+ import type { CoinWrappedType } from '../constant';
8
2
 
9
3
  type OptionalKeys<T> = {
10
4
  [K in keyof T]?: T[K];
11
5
  };
12
6
 
13
- export type MarketPools = OptionalKeys<Record<SupportPoolCoins, MarketPool>>;
14
- export type MarketCollaterals = OptionalKeys<
15
- Record<SupportCollateralCoins, MarketCollateral>
16
- >;
17
- export type CoinAmounts = OptionalKeys<Record<SupportPoolCoins, number>>;
18
- export type MarketCoinAmounts = OptionalKeys<
19
- Record<SupportMarketCoins, number>
20
- >;
7
+ export type MarketPools = OptionalKeys<Record<string, MarketPool>>;
8
+ export type MarketCollaterals = OptionalKeys<Record<string, MarketCollateral>>;
9
+ export type CoinAmounts = OptionalKeys<Record<string, number>>;
10
+ export type MarketCoinAmounts = OptionalKeys<Record<string, number>>;
21
11
 
22
- export type SCoinAmounts = OptionalKeys<Record<SupportSCoin, number>>;
12
+ export type SCoinAmounts = OptionalKeys<Record<string, number>>;
23
13
 
24
14
  export type BalanceSheet = {
25
15
  cash: string;
@@ -123,7 +113,7 @@ export type RiskModel = {
123
113
  export type CollateralStat = { amount: string };
124
114
 
125
115
  export type MarketPool = {
126
- coinName: SupportPoolCoins;
116
+ coinName: string;
127
117
  symbol: string;
128
118
  coinType: string;
129
119
  marketCoinType: string;
@@ -149,7 +139,7 @@ export type MarketPool = {
149
139
  CalculatedMarketPoolData;
150
140
 
151
141
  export type MarketCollateral = {
152
- coinName: SupportCollateralCoins;
142
+ coinName: string;
153
143
  symbol: string;
154
144
  coinType: string;
155
145
  marketCoinType: string;
@@ -1,16 +1,11 @@
1
1
  import type { MarketPool } from './core';
2
2
  import type { Spool } from './spool';
3
- import type {
4
- SupportPoolCoins,
5
- SupportCollateralCoins,
6
- SupportBorrowIncentiveRewardCoins,
7
- } from '../constant';
8
3
 
9
4
  type OptionalKeys<T> = {
10
5
  [K in keyof T]?: T[K];
11
6
  };
12
7
 
13
- export type Lendings = OptionalKeys<Record<SupportPoolCoins, Lending>>;
8
+ export type Lendings = OptionalKeys<Record<string, Lending>>;
14
9
  export type ObligationAccounts = OptionalKeys<
15
10
  Record<string, ObligationAccount>
16
11
  >;
@@ -72,17 +67,13 @@ export type ObligationAccount = {
72
67
  totalDepositedPools: number;
73
68
  totalBorrowedPools: number;
74
69
  totalRewardedPools: number;
75
- collaterals: OptionalKeys<
76
- Record<SupportCollateralCoins, ObligationCollateral>
77
- >;
78
- debts: OptionalKeys<Record<SupportPoolCoins, ObligationDebt>>;
79
- borrowIncentives: OptionalKeys<
80
- Record<SupportPoolCoins, ObligationBorrowIncentive>
81
- >;
70
+ collaterals: OptionalKeys<Record<string, ObligationCollateral>>;
71
+ debts: OptionalKeys<Record<string, ObligationDebt>>;
72
+ borrowIncentives: OptionalKeys<Record<string, ObligationBorrowIncentive>>;
82
73
  };
83
74
 
84
75
  export type ObligationCollateral = {
85
- coinName: SupportCollateralCoins;
76
+ coinName: string;
86
77
  coinType: string;
87
78
  symbol: string;
88
79
  coinDecimal: number;
@@ -99,7 +90,7 @@ export type ObligationCollateral = {
99
90
  };
100
91
 
101
92
  export type ObligationDebt = {
102
- coinName: SupportPoolCoins;
93
+ coinName: string;
103
94
  coinType: string;
104
95
  symbol: string;
105
96
  coinDecimal: number;
@@ -118,7 +109,7 @@ export type ObligationDebt = {
118
109
  };
119
110
 
120
111
  export type ObligationBorrowIcentiveReward = {
121
- coinName: SupportBorrowIncentiveRewardCoins;
112
+ coinName: string;
122
113
  coinType: string;
123
114
  symbol: string;
124
115
  coinDecimal: number;
@@ -129,7 +120,7 @@ export type ObligationBorrowIcentiveReward = {
129
120
  };
130
121
 
131
122
  export type ObligationBorrowIncentive = {
132
- coinName: SupportPoolCoins;
123
+ coinName: string;
133
124
  coinType: string;
134
125
  symbol: string;
135
126
  coinDecimal: number;
@@ -1,13 +1,11 @@
1
- import type { SupportStakeMarketCoins } from '../constant';
2
-
3
1
  type OptionalKeys<T> = {
4
2
  [K in keyof T]?: T[K];
5
3
  };
6
4
 
7
- export type Spools = OptionalKeys<Record<SupportStakeMarketCoins, Spool>>;
5
+ export type Spools = OptionalKeys<Record<string, Spool>>;
8
6
 
9
7
  export type Spool = {
10
- marketCoinName: SupportStakeMarketCoins;
8
+ marketCoinName: string;
11
9
  symbol: string;
12
10
  coinType: string;
13
11
  marketCoinType: string;
@@ -121,13 +119,9 @@ export type CalculatedSpoolRewardPoolData = {
121
119
  rewardPerSec: number;
122
120
  };
123
121
 
124
- export type StakePools = OptionalKeys<
125
- Record<SupportStakeMarketCoins, StakePool>
126
- >;
127
- export type StakeRewardPools = OptionalKeys<
128
- Record<SupportStakeMarketCoins, StakeRewardPool>
129
- >;
130
- export type StakeAccounts = Record<SupportStakeMarketCoins, StakeAccount[]>;
122
+ export type StakePools = OptionalKeys<Record<string, StakePool>>;
123
+ export type StakeRewardPools = OptionalKeys<Record<string, StakeRewardPool>>;
124
+ export type StakeAccounts = Record<string, StakeAccount[]>;
131
125
 
132
126
  export interface StakeAccount {
133
127
  id: string;
@@ -1,25 +1,5 @@
1
- import type { SupportCoins } from './constant';
2
-
3
1
  export type OptionalKeys<T> = {
4
2
  [K in keyof T]?: T[K];
5
3
  };
6
4
 
7
- export type CoinPrices = OptionalKeys<Record<SupportCoins, number>>;
8
-
9
- export type PoolAddressInfo = {
10
- name: string;
11
- coingeckoId: string;
12
- decimal: number;
13
- pythFeedId: string;
14
- lendingPoolAddress?: string;
15
- collateralPoolAddress?: string; // not all pool has collateral
16
- borrowDynamic?: string;
17
- interestModelId?: string;
18
- borrowFeeKey?: string;
19
- supplyLimitKey?: string;
20
- borrowLimitKey?: string;
21
- isolatedAssetKey?: string;
22
- sCoinAddress: string | undefined;
23
- marketCoinAddress: string;
24
- sCoinName: string | undefined;
25
- };
5
+ export type CoinPrices = OptionalKeys<Record<string, number>>;
package/src/utils/core.ts CHANGED
@@ -2,7 +2,7 @@ import { SuiObjectData } from '@mysten/sui/client';
2
2
 
3
3
  export const parseObjectAs = <T>(object: SuiObjectData): T => {
4
4
  if (!(object && object.content && 'fields' in object.content))
5
- throw new Error(`Failed to parse object`);
5
+ throw new Error(`Failed to parse object ${object}`);
6
6
 
7
7
  const fields = object.content.fields as any;
8
8