@scallop-io/sui-scallop-sdk 1.4.14-alpha.1 → 1.4.15-rc.1

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 (43) hide show
  1. package/dist/constants/poolAddress.d.ts +14 -4
  2. package/dist/constants/queryKeys.d.ts +1 -2
  3. package/dist/constants/tokenBucket.d.ts +1 -1
  4. package/dist/index.js +714 -316
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +669 -271
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/models/scallopQuery.d.ts +20 -17
  9. package/dist/queries/coreQuery.d.ts +18 -19
  10. package/dist/queries/index.d.ts +2 -0
  11. package/dist/queries/isolatedAssetQuery.d.ts +2 -2
  12. package/dist/queries/objectsQuery.d.ts +3 -0
  13. package/dist/queries/poolAddressesQuery.d.ts +15 -0
  14. package/dist/types/query/core.d.ts +22 -5
  15. package/dist/types/utils.d.ts +7 -2
  16. package/dist/utils/core.d.ts +2 -0
  17. package/dist/utils/index.d.ts +1 -0
  18. package/dist/utils/util.d.ts +1 -0
  19. package/package.json +1 -1
  20. package/src/constants/enum.ts +6 -14
  21. package/src/constants/poolAddress.ts +290 -29
  22. package/src/constants/queryKeys.ts +5 -5
  23. package/src/constants/tokenBucket.ts +1 -1
  24. package/src/models/scallopCache.ts +34 -7
  25. package/src/models/scallopQuery.ts +24 -12
  26. package/src/queries/borrowIncentiveQuery.ts +1 -1
  27. package/src/queries/borrowLimitQuery.ts +2 -2
  28. package/src/queries/coreQuery.ts +378 -248
  29. package/src/queries/index.ts +2 -0
  30. package/src/queries/isolatedAssetQuery.ts +39 -33
  31. package/src/queries/objectsQuery.ts +20 -0
  32. package/src/queries/poolAddressesQuery.ts +134 -0
  33. package/src/queries/portfolioQuery.ts +14 -7
  34. package/src/queries/priceQuery.ts +3 -1
  35. package/src/queries/spoolQuery.ts +3 -1
  36. package/src/queries/supplyLimitQuery.ts +2 -2
  37. package/src/types/query/core.ts +21 -5
  38. package/src/types/utils.ts +8 -3
  39. package/src/utils/core.ts +11 -0
  40. package/src/utils/index.ts +1 -0
  41. package/src/utils/query.ts +16 -2
  42. package/src/utils/tokenBucket.ts +1 -1
  43. package/src/utils/util.ts +8 -0
@@ -34,6 +34,7 @@ export declare class ScallopQuery {
34
34
  */
35
35
  init(force?: boolean, address?: ScallopAddress): Promise<void>;
36
36
  /**
37
+ * @deprecated use getMarketPools
37
38
  * Query market data.
38
39
  * @param indexer - Whether to use indexer.
39
40
  * @return Market data.
@@ -57,22 +58,8 @@ export declare class ScallopQuery {
57
58
  coinPrices?: CoinPrices;
58
59
  indexer?: boolean;
59
60
  }): Promise<{
60
- usdc?: MarketPool | undefined;
61
- sbeth?: MarketPool | undefined;
62
- weth?: MarketPool | undefined;
63
- wbtc?: MarketPool | undefined;
64
- wusdc?: MarketPool | undefined;
65
- wusdt?: MarketPool | undefined;
66
- sui?: MarketPool | undefined;
67
- wapt?: MarketPool | undefined;
68
- wsol?: MarketPool | undefined;
69
- cetus?: MarketPool | undefined;
70
- afsui?: MarketPool | undefined;
71
- hasui?: MarketPool | undefined;
72
- vsui?: MarketPool | undefined;
73
- sca?: MarketPool | undefined;
74
- fud?: MarketPool | undefined;
75
- deep?: MarketPool | undefined;
61
+ pools: MarketPools;
62
+ collaterals: import("../types").MarketCollaterals;
76
63
  }>;
77
64
  /**
78
65
  * Get market pool
@@ -82,7 +69,6 @@ export declare class ScallopQuery {
82
69
  * @return Market pool data.
83
70
  */
84
71
  getMarketPool(poolCoinName: SupportPoolCoins, args?: {
85
- marketObject?: SuiObjectData | null;
86
72
  coinPrice?: number;
87
73
  indexer?: boolean;
88
74
  }): Promise<MarketPool | undefined>;
@@ -568,4 +554,21 @@ export declare class ScallopQuery {
568
554
  deep?: number | undefined;
569
555
  swapt?: number | undefined;
570
556
  }>;
557
+ /**
558
+ * Query all address (lending pool, collateral pool, borrow dynamics, interest models) of all pool
559
+ * @returns
560
+ */
561
+ getPoolAddresses(): Promise<import("../types").OptionalKeys<Record<"usdc" | "sbeth" | "weth" | "wbtc" | "wusdc" | "wusdt" | "sui" | "wapt" | "wsol" | "cetus" | "afsui" | "hasui" | "vsui" | "sca" | "fud" | "deep", {
562
+ lendingPoolAddress?: string;
563
+ collateralPoolAddress?: string;
564
+ borrowDynamic?: string;
565
+ spoolReward?: string;
566
+ spool?: string;
567
+ interestModel?: string;
568
+ riskModel?: string;
569
+ borrowFeeKey?: string;
570
+ supplyLimitKey?: string;
571
+ borrowLimitKey?: string;
572
+ isolatedAssetKey?: string;
573
+ }>>>;
571
574
  }
@@ -1,10 +1,12 @@
1
1
  import type { SuiObjectData } from '@mysten/sui/client';
2
2
  import type { SuiObjectArg } from '@scallop-io/sui-kit';
3
3
  import type { ScallopAddress, ScallopCache, ScallopQuery } from '../models';
4
- import { Market, MarketPool, MarketCollateral, SupportAssetCoins, SupportPoolCoins, SupportCollateralCoins, ObligationQueryInterface, Obligation, SupportMarketCoins, OptionalKeys, CoinPrices } from '../types';
4
+ import { Market, MarketPools, MarketPool, MarketCollaterals, MarketCollateral, SupportAssetCoins, SupportPoolCoins, SupportCollateralCoins, ObligationQueryInterface, Obligation, SupportMarketCoins, OptionalKeys, CoinPrices } from '../types';
5
5
  /**
6
6
  * Query market data.
7
7
  *
8
+ * @deprecated Use query market pools
9
+ *
8
10
  * @description
9
11
  * Use inspectTxn call to obtain the data provided in the scallop contract query module.
10
12
  *
@@ -25,23 +27,9 @@ export declare const queryMarket: (query: ScallopQuery, indexer?: boolean, coinP
25
27
  * @param indexer - Whether to use indexer.
26
28
  * @return Market pools data.
27
29
  */
28
- export declare const getMarketPools: (query: ScallopQuery, poolCoinNames?: SupportPoolCoins[], indexer?: boolean, coinPrices?: CoinPrices) => Promise<{
29
- usdc?: MarketPool | undefined;
30
- sbeth?: MarketPool | undefined;
31
- weth?: MarketPool | undefined;
32
- wbtc?: MarketPool | undefined;
33
- wusdc?: MarketPool | undefined;
34
- wusdt?: MarketPool | undefined;
35
- sui?: MarketPool | undefined;
36
- wapt?: MarketPool | undefined;
37
- wsol?: MarketPool | undefined;
38
- cetus?: MarketPool | undefined;
39
- afsui?: MarketPool | undefined;
40
- hasui?: MarketPool | undefined;
41
- vsui?: MarketPool | undefined;
42
- sca?: MarketPool | undefined;
43
- fud?: MarketPool | undefined;
44
- deep?: MarketPool | undefined;
30
+ export declare const getMarketPools: (query: ScallopQuery, poolCoinNames: SupportPoolCoins[], indexer?: boolean, coinPrices?: CoinPrices) => Promise<{
31
+ pools: MarketPools;
32
+ collaterals: MarketCollaterals;
45
33
  }>;
46
34
  /**
47
35
  * Get market pool data.
@@ -53,7 +41,18 @@ export declare const getMarketPools: (query: ScallopQuery, poolCoinNames?: Suppo
53
41
  * @param coinPrice - The coin price.
54
42
  * @returns Market pool data.
55
43
  */
56
- export declare const getMarketPool: (query: ScallopQuery, poolCoinName: SupportPoolCoins, indexer?: boolean, marketObject?: SuiObjectData | null, coinPrice?: number) => Promise<MarketPool | undefined>;
44
+ export declare const getMarketPool: (query: ScallopQuery, poolCoinName: SupportPoolCoins, indexer: boolean | undefined, coinPrice: number, requiredObjects?: {
45
+ balanceSheet: SuiObjectData;
46
+ borrowDynamic: SuiObjectData;
47
+ interestModel: SuiObjectData;
48
+ borrowFeeKey: SuiObjectData;
49
+ supplyLimitKey: SuiObjectData;
50
+ borrowLimitKey: SuiObjectData;
51
+ isolatedAssetKey: SuiObjectData;
52
+ }) => Promise<{
53
+ marketPool: MarketPool;
54
+ collateral?: MarketCollateral;
55
+ } | undefined>;
57
56
  /**
58
57
  * Get coin market collaterals data.
59
58
  *
@@ -10,3 +10,5 @@ export * from './spoolQuery';
10
10
  export * from './supplyLimitQuery';
11
11
  export * from './vescaQuery';
12
12
  export * from './borrowLimitQuery';
13
+ export * from './poolAddressesQuery';
14
+ export * from './objectsQuery';
@@ -1,11 +1,11 @@
1
- import { ScallopAddress, ScallopUtils } from '../models';
1
+ import { ScallopQuery, ScallopUtils } from '../models';
2
2
  import { SupportPoolCoins } from '../types';
3
3
  /**
4
4
  * Return list of isolated assets coin types
5
5
  * @param utils ScallopUtils
6
6
  * @returns list of isolated assets coin types
7
7
  */
8
- export declare const getIsolatedAssets: (address: ScallopAddress) => Promise<string[]>;
8
+ export declare const getIsolatedAssets: (query: ScallopQuery) => Promise<string[]>;
9
9
  /**
10
10
  * Check if the coin type is an isolated asset
11
11
  * @param coinName coin name
@@ -0,0 +1,3 @@
1
+ import { SuiObjectDataOptions } from '@mysten/sui/dist/cjs/client';
2
+ import { ScallopCache } from 'src/models/scallopCache';
3
+ export declare const queryMultipleObjects: (cache: ScallopCache, objectIds: string[], options?: SuiObjectDataOptions, partitionSize?: number) => Promise<import("@mysten/sui/dist/cjs/client").SuiObjectData[]>;
@@ -0,0 +1,15 @@
1
+ import { ScallopQuery } from 'src/models';
2
+ import { OptionalKeys } from 'src/types';
3
+ export declare const getAllAddresses: (query: ScallopQuery) => Promise<OptionalKeys<Record<"usdc" | "sbeth" | "weth" | "wbtc" | "wusdc" | "wusdt" | "sui" | "wapt" | "wsol" | "cetus" | "afsui" | "hasui" | "vsui" | "sca" | "fud" | "deep", {
4
+ lendingPoolAddress?: string;
5
+ collateralPoolAddress?: string;
6
+ borrowDynamic?: string;
7
+ spoolReward?: string;
8
+ spool?: string;
9
+ interestModel?: string;
10
+ riskModel?: string;
11
+ borrowFeeKey?: string;
12
+ supplyLimitKey?: string;
13
+ borrowLimitKey?: string;
14
+ isolatedAssetKey?: string;
15
+ }>>>;
@@ -13,7 +13,7 @@ export type BalanceSheet = {
13
13
  market_coin_supply: string;
14
14
  revenue: string;
15
15
  };
16
- export type BorrowIndex = {
16
+ export type BorrowDynamic = {
17
17
  borrow_index: string;
18
18
  interest_rate: {
19
19
  fields: {
@@ -23,6 +23,9 @@ export type BorrowIndex = {
23
23
  interest_rate_scale: string;
24
24
  last_updated: string;
25
25
  };
26
+ export type BorrowFee = {
27
+ value: string;
28
+ };
26
29
  export type InterestModel = {
27
30
  base_borrow_rate_per_sec: {
28
31
  fields: {
@@ -135,7 +138,7 @@ export type MarketCollateral = {
135
138
  coinDecimal: number;
136
139
  coinPrice: number;
137
140
  isIsolated: boolean;
138
- } & Required<Pick<ParsedMarketCollateralData, 'collateralFactor' | 'liquidationFactor' | 'liquidationDiscount' | 'liquidationPanelty' | 'liquidationReserveFactor'>> & CalculatedMarketCollateralData;
141
+ } & Required<Pick<ParsedMarketCollateralData, 'collateralFactor' | 'liquidationFactor' | 'liquidationDiscount' | 'liquidationPenalty' | 'liquidationReserveFactor'>> & CalculatedMarketCollateralData;
139
142
  export type OriginMarketPoolData = {
140
143
  type: {
141
144
  name: string;
@@ -178,6 +181,9 @@ export type OriginMarketPoolData = {
178
181
  value: string;
179
182
  };
180
183
  minBorrowAmount: string;
184
+ isIsolated: boolean;
185
+ supplyLimit: string;
186
+ borrowLimit: string;
181
187
  };
182
188
  export type ParsedMarketPoolData = {
183
189
  coinType: string;
@@ -199,6 +205,9 @@ export type ParsedMarketPoolData = {
199
205
  highKink: number;
200
206
  midKink: number;
201
207
  minBorrowAmount: number;
208
+ isIsolated: boolean;
209
+ supplyLimit: number;
210
+ borrowLimit: number;
202
211
  };
203
212
  export type CalculatedMarketPoolData = {
204
213
  baseBorrowApr: number;
@@ -207,6 +216,8 @@ export type CalculatedMarketPoolData = {
207
216
  borrowApyOnHighKink: number;
208
217
  borrowAprOnMidKink: number;
209
218
  borrowApyOnMidKink: number;
219
+ coinDecimal: number;
220
+ conversionRate: number;
210
221
  maxBorrowApr: number;
211
222
  maxBorrowApy: number;
212
223
  borrowApr: number;
@@ -222,12 +233,15 @@ export type CalculatedMarketPoolData = {
222
233
  utilizationRate: number;
223
234
  supplyApr: number;
224
235
  supplyApy: number;
225
- conversionRate: number;
236
+ isIsolated: boolean;
237
+ maxSupplyCoin: number;
238
+ maxBorrowCoin: number;
226
239
  };
227
240
  export type OriginMarketCollateralData = {
228
241
  type: {
229
242
  name: string;
230
243
  };
244
+ isIsolated: boolean;
231
245
  collateralFactor: {
232
246
  value: string;
233
247
  };
@@ -237,7 +251,7 @@ export type OriginMarketCollateralData = {
237
251
  liquidationDiscount: {
238
252
  value: string;
239
253
  };
240
- liquidationPanelty: {
254
+ liquidationPenalty: {
241
255
  value: string;
242
256
  };
243
257
  liquidationReserveFactor: {
@@ -251,12 +265,15 @@ export type ParsedMarketCollateralData = {
251
265
  collateralFactor: number;
252
266
  liquidationFactor: number;
253
267
  liquidationDiscount: number;
254
- liquidationPanelty: number;
268
+ liquidationPenalty: number;
255
269
  liquidationReserveFactor: number;
256
270
  maxCollateralAmount: number;
257
271
  totalCollateralAmount: number;
272
+ isIsolated: boolean;
258
273
  };
259
274
  export type CalculatedMarketCollateralData = {
275
+ coinDecimal: number;
276
+ isIsolated: boolean;
260
277
  maxDepositAmount: number;
261
278
  maxDepositCoin: number;
262
279
  depositAmount: number;
@@ -8,10 +8,15 @@ export type PoolAddressInfo = {
8
8
  coingeckoId: string;
9
9
  decimal: number;
10
10
  pythFeedId: string;
11
- lendingPoolAddress: string;
11
+ lendingPoolAddress?: string;
12
12
  collateralPoolAddress?: string;
13
+ borrowDynamic?: string;
14
+ interestModelId?: string;
15
+ borrowFeeKey?: string;
16
+ supplyLimitKey?: string;
17
+ borrowLimitKey?: string;
18
+ isolatedAssetKey?: string;
13
19
  sCoinAddress: string | undefined;
14
20
  marketCoinAddress: string;
15
- coinAddress: string;
16
21
  sCoinName: string | undefined;
17
22
  };
@@ -0,0 +1,2 @@
1
+ import { SuiObjectData } from '@mysten/sui/client';
2
+ export declare const parseObjectAs: <T>(object: SuiObjectData) => T;
@@ -3,3 +3,4 @@ export * from './query';
3
3
  export * from './util';
4
4
  export * from './tokenBucket';
5
5
  export * from './indexer';
6
+ export * from './core';
@@ -24,3 +24,4 @@ export declare const parseDataFromPythPriceFeed: (feed: PriceFeed, address: Scal
24
24
  * @returns Closest round (12AM) in seconds timestamp.
25
25
  */
26
26
  export declare const findClosestUnlockRound: (unlockAtInSecondTimestamp: number) => number;
27
+ export declare const partitionArray: <T>(array: T[], chunkSize: number) => T[][];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scallop-io/sui-scallop-sdk",
3
- "version": "1.4.14-alpha.1",
3
+ "version": "1.4.15-rc.1",
4
4
  "description": "Typescript sdk for interacting with Scallop contract on SUI",
5
5
  "keywords": [
6
6
  "sui",
@@ -157,24 +157,16 @@ export const voloCoinIds: types.VoloCoinIds = {
157
157
 
158
158
  // PROD VERSION
159
159
  export const sCoinIds: types.SCoinIds = {
160
- // prod values
161
- // ssui: '0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI',
162
- // swusdc:
163
- // '0xad4d71551d31092230db1fd482008ea42867dbf27b286e9c70a79d2a6191d58d::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC',
164
- // swusdt:
165
- // '0xe6e5a012ec20a49a3d1d57bd2b67140b96cd4d3400b9d79e541f7bdbab661f95::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT',
166
- // ssca: '0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA',
167
-
168
- ssui: '0xf569919046f19a0c40b519ecfbb6ca0319698cd5908716c29b62ef56541f298b::scallop_sui::SCALLOP_SUI',
169
- swusdt:
170
- '0xac781d9f73058ff5e69f9bf8dde32f2e8c71c66d7fe8497fc83b2d9182254b22::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT',
171
- swusdc:
172
- '0xf5447c4305a486d8c8557559887c2c39449ddb5e748f15d33946d02a1663c158::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC',
173
- ssca: '0x958428555e778e55918a59eb1c92c77f32b5c554fa3a5e56cd0815086b5072e7::scallop_sca::SCALLOP_SCA',
174
160
  susdc:
175
161
  '0x854950aa624b1df59fe64e630b2ba7c550642e9342267a33061d59fb31582da5::scallop_usdc::SCALLOP_USDC',
176
162
  ssbeth:
177
163
  '0xb14f82d8506d139eacef109688d1b71e7236bcce9b2c0ad526abcd6aa5be7de0::scallop_sb_eth::SCALLOP_SB_ETH',
164
+ ssui: '0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI',
165
+ swusdc:
166
+ '0xad4d71551d31092230db1fd482008ea42867dbf27b286e9c70a79d2a6191d58d::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC',
167
+ swusdt:
168
+ '0xe6e5a012ec20a49a3d1d57bd2b67140b96cd4d3400b9d79e541f7bdbab661f95::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT',
169
+ ssca: '0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA',
178
170
  scetus:
179
171
  '0xea346ce428f91ab007210443efcea5f5cdbbb3aae7e9affc0ca93f9203c31f0c::scallop_cetus::SCALLOP_CETUS',
180
172
  sweth: