@scallop-io/sui-scallop-sdk 1.3.4-alpha.6 → 1.3.4-hotfix

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 (107) hide show
  1. package/dist/builders/borrowIncentiveBuilder.d.ts +12 -0
  2. package/dist/builders/coreBuilder.d.ts +12 -0
  3. package/dist/builders/index.d.ts +12 -0
  4. package/dist/builders/loyaltyProgramBuilder.d.ts +12 -0
  5. package/dist/builders/oracle.d.ts +14 -0
  6. package/dist/builders/referralBuilder.d.ts +12 -0
  7. package/dist/builders/sCoinBuilder.d.ts +4 -0
  8. package/dist/builders/spoolBuilder.d.ts +12 -0
  9. package/dist/builders/vescaBuilder.d.ts +25 -0
  10. package/dist/constants/cache.d.ts +14 -0
  11. package/dist/constants/common.d.ts +20 -0
  12. package/dist/constants/enum.d.ts +13 -0
  13. package/dist/constants/flashloan.d.ts +2 -0
  14. package/dist/constants/index.d.ts +5 -0
  15. package/dist/constants/pyth.d.ts +3 -0
  16. package/dist/constants/queryKeys.d.ts +58 -0
  17. package/dist/constants/testAddress.d.ts +2 -0
  18. package/dist/constants/tokenBucket.d.ts +2 -0
  19. package/dist/constants/vesca.d.ts +5 -0
  20. package/dist/index.d.ts +3 -0
  21. package/dist/index.js +2317 -2481
  22. package/dist/index.js.map +1 -1
  23. package/dist/index.mjs +2316 -2470
  24. package/dist/index.mjs.map +1 -1
  25. package/dist/models/index.d.ts +8 -0
  26. package/dist/models/scallop.d.ts +74 -0
  27. package/dist/models/scallopAddress.d.ts +150 -0
  28. package/dist/models/scallopBuilder.d.ts +89 -0
  29. package/dist/models/scallopCache.d.ts +74 -0
  30. package/dist/models/scallopClient.d.ts +321 -0
  31. package/dist/models/scallopIndexer.d.ts +89 -0
  32. package/dist/models/scallopPrice.d.ts +0 -0
  33. package/dist/models/scallopQuery.d.ts +474 -0
  34. package/dist/models/scallopUtils.d.ts +217 -0
  35. package/dist/queries/borrowIncentiveQuery.d.ts +61 -0
  36. package/dist/queries/coreQuery.d.ts +167 -0
  37. package/dist/queries/index.d.ts +8 -0
  38. package/dist/queries/isolatedAsset.d.ts +14 -0
  39. package/dist/queries/loyaltyProgramQuery.d.ts +10 -0
  40. package/dist/queries/portfolioQuery.d.ts +73 -0
  41. package/dist/queries/priceQuery.d.ts +16 -0
  42. package/dist/queries/referralQuery.d.ts +7 -0
  43. package/dist/queries/sCoinQuery.d.ts +41 -0
  44. package/dist/queries/spoolQuery.d.ts +70 -0
  45. package/dist/queries/supplyLimit.d.ts +9 -0
  46. package/dist/queries/vescaQuery.d.ts +36 -0
  47. package/dist/types/address.d.ts +107 -0
  48. package/dist/types/builder/borrowIncentive.d.ts +35 -0
  49. package/dist/types/builder/core.d.ts +56 -0
  50. package/dist/types/builder/index.d.ts +24 -0
  51. package/dist/types/builder/loyaltyProgram.d.ts +23 -0
  52. package/dist/types/builder/referral.d.ts +30 -0
  53. package/dist/types/builder/sCoin.d.ts +37 -0
  54. package/dist/types/builder/spool.d.ts +29 -0
  55. package/dist/types/builder/vesca.d.ts +51 -0
  56. package/dist/types/constant/common.d.ts +24 -0
  57. package/dist/types/constant/enum.d.ts +48 -0
  58. package/dist/types/constant/index.d.ts +2 -0
  59. package/dist/types/index.d.ts +6 -0
  60. package/dist/types/model.d.ts +54 -0
  61. package/dist/types/query/borrowIncentive.d.ts +124 -0
  62. package/dist/types/query/core.d.ts +361 -0
  63. package/dist/types/query/index.d.ts +7 -0
  64. package/dist/types/query/loyaltyProgram.d.ts +5 -0
  65. package/dist/types/query/portfolio.d.ts +115 -0
  66. package/dist/types/query/sCoin.d.ts +1 -0
  67. package/dist/types/query/spool.d.ts +122 -0
  68. package/dist/types/query/vesca.d.ts +26 -0
  69. package/dist/types/utils.d.ts +9 -0
  70. package/dist/utils/builder.d.ts +15 -0
  71. package/dist/utils/index.d.ts +5 -0
  72. package/dist/utils/indexer.d.ts +17 -0
  73. package/dist/utils/query.d.ts +62 -0
  74. package/dist/utils/tokenBucket.d.ts +11 -0
  75. package/dist/utils/util.d.ts +26 -0
  76. package/package.json +2 -2
  77. package/src/builders/loyaltyProgramBuilder.ts +1 -1
  78. package/src/constants/common.ts +2 -1
  79. package/src/constants/enum.ts +0 -8
  80. package/src/constants/index.ts +0 -7
  81. package/src/constants/pyth.ts +0 -19
  82. package/src/constants/queryKeys.ts +5 -1
  83. package/src/constants/tokenBucket.ts +1 -1
  84. package/src/models/scallop.ts +2 -3
  85. package/src/models/scallopAddress.ts +2 -2
  86. package/src/models/scallopBuilder.ts +3 -4
  87. package/src/models/scallopCache.ts +1 -1
  88. package/src/models/scallopClient.ts +26 -27
  89. package/src/models/scallopPrice.ts +0 -0
  90. package/src/models/scallopQuery.ts +17 -63
  91. package/src/models/scallopUtils.ts +96 -96
  92. package/src/queries/borrowIncentiveQuery.ts +13 -6
  93. package/src/queries/coreQuery.ts +23 -38
  94. package/src/queries/index.ts +5 -8
  95. package/src/queries/{isolatedAssetQuery.ts → isolatedAsset.ts} +2 -2
  96. package/src/queries/loyaltyProgramQuery.ts +1 -1
  97. package/src/queries/portfolioQuery.ts +34 -55
  98. package/src/queries/spoolQuery.ts +17 -17
  99. package/src/queries/{supplyLimitQuery.ts → supplyLimit.ts} +2 -2
  100. package/src/types/query/index.ts +4 -4
  101. package/src/types/utils.ts +0 -13
  102. package/src/utils/tokenBucket.ts +1 -2
  103. package/src/utils/util.ts +1 -2
  104. package/src/constants/coinGecko.ts +0 -18
  105. package/src/constants/poolAddress.ts +0 -94
  106. package/src/constants/rpc.ts +0 -16
  107. package/src/models/suiKit.ts +0 -11
@@ -0,0 +1,474 @@
1
+ import { SuiKit } from '@scallop-io/sui-kit';
2
+ import { ScallopQueryParams, SupportStakeMarketCoins, SupportAssetCoins, SupportPoolCoins, SupportCollateralCoins, SupportMarketCoins, SupportBorrowIncentiveCoins, SupportSCoin, ScallopQueryInstanceParams } from '../types';
3
+ import { ScallopAddress } from './scallopAddress';
4
+ import { ScallopUtils } from './scallopUtils';
5
+ import { ScallopIndexer } from './scallopIndexer';
6
+ import { ScallopCache } from './scallopCache';
7
+ import { SuiObjectData } from '@mysten/sui/client';
8
+ /**
9
+ * @description
10
+ * It provides methods for getting on-chain data from the Scallop contract.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const scallopQuery = new ScallopQuery(<parameters>);
15
+ * await scallopQuery.init();
16
+ * scallopQuery.<query functions>();
17
+ * await scallopQuery.<query functions>();
18
+ * ```
19
+ */
20
+ export declare class ScallopQuery {
21
+ readonly params: ScallopQueryParams;
22
+ suiKit: SuiKit;
23
+ address: ScallopAddress;
24
+ utils: ScallopUtils;
25
+ indexer: ScallopIndexer;
26
+ cache: ScallopCache;
27
+ walletAddress: string;
28
+ constructor(params: ScallopQueryParams, instance?: ScallopQueryInstanceParams);
29
+ /**
30
+ * Request the scallop API to initialize data.
31
+ *
32
+ * @param force - Whether to force initialization.
33
+ * @param address - ScallopAddress instance.
34
+ */
35
+ init(force?: boolean, address?: ScallopAddress): Promise<void>;
36
+ /**
37
+ * Query market data.
38
+ * @param indexer - Whether to use indexer.
39
+ * @return Market data.
40
+ */
41
+ queryMarket(indexer?: boolean): Promise<import("../types").Market>;
42
+ /**
43
+ * Get market pools.
44
+ *
45
+ * @description
46
+ * To obtain all market pools at once, it is recommended to use
47
+ * the `queryMarket` method to reduce time consumption.
48
+ *
49
+ * @param poolCoinNames - Specific an array of support pool coin name.
50
+ * @param indexer - Whether to use indexer.
51
+ * @return Market pools data.
52
+ */
53
+ getMarketPools(poolCoinNames?: SupportPoolCoins[], indexer?: boolean): Promise<{
54
+ usdc?: import("../types").MarketPool | undefined;
55
+ sbeth?: import("../types").MarketPool | undefined;
56
+ weth?: import("../types").MarketPool | undefined;
57
+ wbtc?: import("../types").MarketPool | undefined;
58
+ wusdc?: import("../types").MarketPool | undefined;
59
+ wusdt?: import("../types").MarketPool | undefined;
60
+ sui?: import("../types").MarketPool | undefined;
61
+ wapt?: import("../types").MarketPool | undefined;
62
+ wsol?: import("../types").MarketPool | undefined;
63
+ cetus?: import("../types").MarketPool | undefined;
64
+ afsui?: import("../types").MarketPool | undefined;
65
+ hasui?: import("../types").MarketPool | undefined;
66
+ vsui?: import("../types").MarketPool | undefined;
67
+ sca?: import("../types").MarketPool | undefined;
68
+ }>;
69
+ /**
70
+ * Get market pool
71
+ *
72
+ * @param poolCoinName - Specific support pool coin name.
73
+ * @param indexer - Whether to use indexer.
74
+ * @return Market pool data.
75
+ */
76
+ getMarketPool(poolCoinName: SupportPoolCoins, indexer?: boolean): Promise<import("../types").MarketPool | undefined>;
77
+ /**
78
+ * Get market collaterals.
79
+ *
80
+ * @description
81
+ * To obtain all market collaterals at once, it is recommended to use
82
+ * the `queryMarket` method to reduce time consumption.
83
+ *
84
+ * @param collateralCoinNames - Specific an array of support collateral coin name.
85
+ * @param indexer - Whether to use indexer.
86
+ * @return Market collaterals data.
87
+ */
88
+ getMarketCollaterals(collateralCoinNames?: SupportCollateralCoins[], indexer?: boolean): Promise<{
89
+ usdc?: import("../types").MarketCollateral | undefined;
90
+ sbeth?: import("../types").MarketCollateral | undefined;
91
+ weth?: import("../types").MarketCollateral | undefined;
92
+ wbtc?: import("../types").MarketCollateral | undefined;
93
+ wusdc?: import("../types").MarketCollateral | undefined;
94
+ wusdt?: import("../types").MarketCollateral | undefined;
95
+ sui?: import("../types").MarketCollateral | undefined;
96
+ wapt?: import("../types").MarketCollateral | undefined;
97
+ wsol?: import("../types").MarketCollateral | undefined;
98
+ cetus?: import("../types").MarketCollateral | undefined;
99
+ afsui?: import("../types").MarketCollateral | undefined;
100
+ hasui?: import("../types").MarketCollateral | undefined;
101
+ vsui?: import("../types").MarketCollateral | undefined;
102
+ sca?: import("../types").MarketCollateral | undefined;
103
+ }>;
104
+ /**
105
+ * Get market collateral
106
+ *
107
+ * @param collateralCoinName - Specific support collateral coin name.
108
+ * @param indexer - Whether to use indexer.
109
+ * @return Market collateral data.
110
+ */
111
+ getMarketCollateral(collateralCoinName: SupportCollateralCoins, indexer?: boolean): Promise<import("../types").MarketCollateral | undefined>;
112
+ /**
113
+ * Get obligations data.
114
+ *
115
+ * @param ownerAddress - The owner address.
116
+ * @return Obligations data.
117
+ */
118
+ getObligations(ownerAddress?: string): Promise<import("../types").Obligation[]>;
119
+ /**
120
+ * Query obligation data.
121
+ *
122
+ * @param obligationId - The obligation id.
123
+ * @return Obligation data.
124
+ */
125
+ queryObligation(obligationId: string): Promise<import("../types").ObligationQueryInterface | undefined>;
126
+ /**
127
+ * Get all asset coin amounts.
128
+ *
129
+ * @param assetCoinNames - Specific an array of support asset coin name.
130
+ * @param ownerAddress - The owner address.
131
+ * @return All coin amounts.
132
+ */
133
+ getCoinAmounts(assetCoinNames?: SupportAssetCoins[], ownerAddress?: string): Promise<import("../types").OptionalKeys<Record<SupportAssetCoins, number>>>;
134
+ /**
135
+ * Get asset coin amount.
136
+ *
137
+ * @param assetCoinName - Specific support asset coin name.
138
+ * @param ownerAddress - The owner address.
139
+ * @return Coin amount.
140
+ */
141
+ getCoinAmount(assetCoinName: SupportAssetCoins, ownerAddress?: string): Promise<number>;
142
+ /**
143
+ * Get all market coin amounts.
144
+ *
145
+ * @param coinNames - Specific an array of support market coin name.
146
+ * @param ownerAddress - The owner address.
147
+ * @return All market market coin amounts.
148
+ */
149
+ getMarketCoinAmounts(marketCoinNames?: SupportMarketCoins[], ownerAddress?: string): Promise<import("../types").OptionalKeys<Record<SupportMarketCoins, number>>>;
150
+ /**
151
+ * Get market coin amount.
152
+ *
153
+ * @param coinNames - Specific support market coin name.
154
+ * @param ownerAddress - The owner address.
155
+ * @return Market market coin amount.
156
+ */
157
+ getMarketCoinAmount(marketCoinName: SupportMarketCoins, ownerAddress?: string): Promise<number>;
158
+ /**
159
+ * Get price from pyth fee object.
160
+ *
161
+ * @param assetCoinName - Specific support asset coin name.
162
+ * @return Asset coin price.
163
+ */
164
+ getPriceFromPyth(assetCoinName: SupportAssetCoins): Promise<number>;
165
+ /**
166
+ * Get prices from pyth fee object.
167
+ *
168
+ * @param assetCoinNames - Array of supported asset coin names.
169
+ * @return Array of asset coin prices.
170
+ */
171
+ getPricesFromPyth(assetCoinNames: SupportAssetCoins[]): Promise<Record<SupportAssetCoins, number>>;
172
+ /**
173
+ * Get spools data.
174
+ *
175
+ * @param stakeMarketCoinNames - Specific an array of support stake market coin name.
176
+ * @param indexer - Whether to use indexer.
177
+ * @return Spools data.
178
+ */
179
+ getSpools(stakeMarketCoinNames?: SupportStakeMarketCoins[], indexer?: boolean): Promise<{
180
+ susdc?: import("../types").Spool | undefined;
181
+ sweth?: import("../types").Spool | undefined;
182
+ ssui?: import("../types").Spool | undefined;
183
+ swusdc?: import("../types").Spool | undefined;
184
+ swusdt?: import("../types").Spool | undefined;
185
+ scetus?: import("../types").Spool | undefined;
186
+ safsui?: import("../types").Spool | undefined;
187
+ shasui?: import("../types").Spool | undefined;
188
+ svsui?: import("../types").Spool | undefined;
189
+ }>;
190
+ /**
191
+ * Get spool data.
192
+ *
193
+ * @param stakeMarketCoinName - Specific support stake market coin name.
194
+ * @param indexer - Whether to use indexer.
195
+ * @return Spool data.
196
+ */
197
+ getSpool(stakeMarketCoinName: SupportStakeMarketCoins, indexer?: boolean): Promise<import("../types").Spool | undefined>;
198
+ /**
199
+ * Get stake accounts data for all stake pools (spools).
200
+ *
201
+ * @param ownerAddress - The owner address.
202
+ * @return All Stake accounts data.
203
+ */
204
+ getAllStakeAccounts(ownerAddress?: string): Promise<import("../types").StakeAccounts>;
205
+ /**
206
+ * Get stake accounts data for specific stake pool (spool).
207
+ *
208
+ * @param stakeMarketCoinName - Specific support stake market coin name.
209
+ * @param ownerAddress - The owner address.
210
+ * @return Stake accounts data.
211
+ */
212
+ getStakeAccounts(stakeMarketCoinName: SupportStakeMarketCoins, ownerAddress?: string): Promise<import("../types").StakeAccount[]>;
213
+ /**
214
+ * Get stake pools (spools) data.
215
+ *
216
+ * @description
217
+ * For backward compatible, it is recommended to use `getSpools` method
218
+ * to get all spools data.
219
+ *
220
+ * @param stakeMarketCoinNames - Specific an array of support stake market coin name.
221
+ * @return Stake pools data.
222
+ */
223
+ getStakePools(stakeMarketCoinNames?: SupportStakeMarketCoins[]): Promise<{
224
+ susdc?: import("../types").StakePool | undefined;
225
+ sweth?: import("../types").StakePool | undefined;
226
+ ssui?: import("../types").StakePool | undefined;
227
+ swusdc?: import("../types").StakePool | undefined;
228
+ swusdt?: import("../types").StakePool | undefined;
229
+ scetus?: import("../types").StakePool | undefined;
230
+ safsui?: import("../types").StakePool | undefined;
231
+ shasui?: import("../types").StakePool | undefined;
232
+ svsui?: import("../types").StakePool | undefined;
233
+ }>;
234
+ /**
235
+ * Get stake pool (spool) data.
236
+ *
237
+ * @description
238
+ * For backward compatible, it is recommended to use `getSpool` method
239
+ * to get all spool data.
240
+ *
241
+ * @param stakeMarketCoinName - Specific support stake market coin name.
242
+ * @return Stake pool data.
243
+ */
244
+ getStakePool(stakeMarketCoinName: SupportStakeMarketCoins): Promise<import("../types").StakePool | undefined>;
245
+ /**
246
+ * Get stake reward pools data.
247
+ *
248
+ * @description
249
+ * For backward compatible, it is recommended to use `getSpools` method
250
+ * to get all spools data.
251
+ *
252
+ * @param stakeMarketCoinNames - Specific an array of stake market coin name.
253
+ * @return Stake reward pools data.
254
+ */
255
+ getStakeRewardPools(stakeMarketCoinNames?: SupportStakeMarketCoins[]): Promise<{
256
+ susdc?: import("../types").StakeRewardPool | undefined;
257
+ sweth?: import("../types").StakeRewardPool | undefined;
258
+ ssui?: import("../types").StakeRewardPool | undefined;
259
+ swusdc?: import("../types").StakeRewardPool | undefined;
260
+ swusdt?: import("../types").StakeRewardPool | undefined;
261
+ scetus?: import("../types").StakeRewardPool | undefined;
262
+ safsui?: import("../types").StakeRewardPool | undefined;
263
+ shasui?: import("../types").StakeRewardPool | undefined;
264
+ svsui?: import("../types").StakeRewardPool | undefined;
265
+ }>;
266
+ /**
267
+ * Get stake reward pool data.
268
+ *
269
+ * @description
270
+ * For backward compatible, it is recommended to use `getSpool` method
271
+ * to get spool data.
272
+ *
273
+ * @param marketCoinName - Specific support stake market coin name.
274
+ * @return Stake reward pool data.
275
+ */
276
+ getStakeRewardPool(stakeMarketCoinName: SupportStakeMarketCoins): Promise<import("../types").StakeRewardPool | undefined>;
277
+ /**
278
+ * Get borrow incentive pools data.
279
+ *
280
+ * @param coinNames - Specific an array of support borrow incentive coin name.
281
+ * @param indexer - Whether to use indexer.
282
+ * @return Borrow incentive pools data.
283
+ */
284
+ getBorrowIncentivePools(coinNames?: SupportBorrowIncentiveCoins[], indexer?: boolean): Promise<{
285
+ usdc?: import("../types").BorrowIncentivePool | undefined;
286
+ sbeth?: import("../types").BorrowIncentivePool | undefined;
287
+ weth?: import("../types").BorrowIncentivePool | undefined;
288
+ wusdc?: import("../types").BorrowIncentivePool | undefined;
289
+ wusdt?: import("../types").BorrowIncentivePool | undefined;
290
+ sui?: import("../types").BorrowIncentivePool | undefined;
291
+ afsui?: import("../types").BorrowIncentivePool | undefined;
292
+ hasui?: import("../types").BorrowIncentivePool | undefined;
293
+ vsui?: import("../types").BorrowIncentivePool | undefined;
294
+ sca?: import("../types").BorrowIncentivePool | undefined;
295
+ }>;
296
+ /**
297
+ * Get borrow incentive accounts data.
298
+ *
299
+ * @param coinNames - Specific support borrow incentive coin name.
300
+ * @param ownerAddress - The owner address.
301
+ * @return Borrow incentive accounts data.
302
+ */
303
+ getBorrowIncentiveAccounts(obligationId: string, coinNames?: SupportBorrowIncentiveCoins[]): Promise<{
304
+ usdc?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
305
+ sbeth?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
306
+ weth?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
307
+ wusdc?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
308
+ wusdt?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
309
+ sui?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
310
+ afsui?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
311
+ hasui?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
312
+ vsui?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
313
+ sca?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
314
+ }>;
315
+ /**
316
+ * Get user lending and spool infomation for specific pools.
317
+ *
318
+ * @param poolCoinNames - Specific an array of support pool coin name.
319
+ * @param ownerAddress - The owner address.
320
+ * @param indexer - Whether to use indexer.
321
+ * @return All lending and spool infomation.
322
+ */
323
+ getLendings(poolCoinNames?: SupportPoolCoins[], ownerAddress?: string, indexer?: boolean): Promise<{
324
+ usdc?: import("../types").Lending | undefined;
325
+ sbeth?: import("../types").Lending | undefined;
326
+ weth?: import("../types").Lending | undefined;
327
+ wbtc?: import("../types").Lending | undefined;
328
+ wusdc?: import("../types").Lending | undefined;
329
+ wusdt?: import("../types").Lending | undefined;
330
+ sui?: import("../types").Lending | undefined;
331
+ wapt?: import("../types").Lending | undefined;
332
+ wsol?: import("../types").Lending | undefined;
333
+ cetus?: import("../types").Lending | undefined;
334
+ afsui?: import("../types").Lending | undefined;
335
+ hasui?: import("../types").Lending | undefined;
336
+ vsui?: import("../types").Lending | undefined;
337
+ sca?: import("../types").Lending | undefined;
338
+ }>;
339
+ /**
340
+ * Get user lending and spool information for specific pool.
341
+ *
342
+ * @param poolCoinName - Specific support pool coin name.
343
+ * @param ownerAddress - The owner address.
344
+ * @param indexer - Whether to use indexer.
345
+ * @return Lending pool data.
346
+ */
347
+ getLending(poolCoinName: SupportPoolCoins, ownerAddress?: string, indexer?: boolean): Promise<import("../types").Lending>;
348
+ /**
349
+ * Get user all obligation accounts information.
350
+ *
351
+ * @description
352
+ * All collateral and borrowing information in all obligation accounts owned by the user.
353
+ *
354
+ * @param ownerAddress - The owner address.
355
+ * @param indexer - Whether to use indexer.
356
+ * @return All obligation accounts information.
357
+ */
358
+ getObligationAccounts(ownerAddress?: string, indexer?: boolean): Promise<{
359
+ [x: string]: import("../types").ObligationAccount | undefined;
360
+ }>;
361
+ /**
362
+ * Get obligation account information for specific id.
363
+ *
364
+ * @description
365
+ * borrowing and obligation information for specific pool.
366
+ *
367
+ * @param obligationId - The obligation id.
368
+ * @param ownerAddress - The owner address.
369
+ * @param indexer - Whether to use indexer.
370
+ * @return Borrowing and collateral information.
371
+ */
372
+ getObligationAccount(obligationId: string, ownerAddress?: string, indexer?: boolean): Promise<import("../types").ObligationAccount>;
373
+ /**
374
+ * Get total value locked.
375
+ *
376
+ * @param indexer - Whether to use indexer.
377
+ * @description
378
+ * Include total supplied value and total borrowed value.
379
+ *
380
+ * @return Total value locked.
381
+ */
382
+ getTvl(indexer?: boolean): Promise<import("../types").TotalValueLocked>;
383
+ /**
384
+ * Get veSca data.
385
+ * @param veScaKey
386
+ * @returns veSca
387
+ */
388
+ getVeSca(veScaKey: string | SuiObjectData): Promise<import("../types").Vesca | undefined>;
389
+ /**
390
+ * Get all veSca from walletAdddress
391
+ * @param walletAddress
392
+ * @returns array of veSca
393
+ */
394
+ getVeScas({ walletAddress, excludeEmpty, }?: {
395
+ walletAddress?: string;
396
+ excludeEmpty?: boolean;
397
+ }): Promise<import("../types").Vesca[]>;
398
+ /**
399
+ * Get total vesca treasury with movecall
400
+ * @returns Promise<string | undefined>
401
+ */
402
+ getVeScaTreasuryInfo(): Promise<import("../types").VeScaTreasuryInfo | null>;
403
+ /**
404
+ * Return binded referrer veScaKeyId of referee walletAddress if exist
405
+ * @param walletAddress
406
+ * @returns veScaKeyId
407
+ */
408
+ getVeScaKeyIdFromReferralBindings(walletAddress?: string): Promise<string | null>;
409
+ /**
410
+ * Get binded obligationId from a veScaKey if it exists.
411
+ * @param veScaKey
412
+ * @returns obligationId
413
+ */
414
+ getBindedObligationId(veScaKey: string): Promise<string | null>;
415
+ /**
416
+ * Get binded veSCA key from a obligationId if it exists.
417
+ * @param obligationId
418
+ * @returns veScaKey
419
+ */
420
+ getBindedVeScaKey(obligationId: string): Promise<string | null>;
421
+ /**
422
+ * Get user's veSCA loyalty program informations
423
+ * @param walletAddress
424
+ * @returns Loyalty program information
425
+ */
426
+ getLoyaltyProgramInfos(veScaKey?: string | SuiObjectData): Promise<import("../types").LoyaltyProgramInfo | null>;
427
+ /**
428
+ * Get total supply of sCoin
429
+ * @param sCoinName - Supported sCoin name
430
+ * @returns Total Supply
431
+ */
432
+ getSCoinTotalSupply(sCoinName: SupportSCoin): Promise<number>;
433
+ /**
434
+ * Get all sCoin amounts.
435
+ *
436
+ * @param sCoinNames - Specific an array of support sCoin name.
437
+ * @param ownerAddress - The owner address.
438
+ * @return All market sCoin amounts.
439
+ */
440
+ getSCoinAmounts(sCoinNames?: SupportSCoin[], ownerAddress?: string): Promise<import("../types").OptionalKeys<Record<"susdc" | "sweth" | "ssui" | "swusdc" | "swusdt" | "scetus" | "safsui" | "shasui" | "svsui" | "ssbeth" | "ssca" | "swsol" | "swbtc", number>>>;
441
+ /**
442
+ * Get sCoin amount.
443
+ *
444
+ * @param coinNames - Specific support sCoin name.
445
+ * @param ownerAddress - The owner address.
446
+ * @return sCoin amount.
447
+ */
448
+ getSCoinAmount(sCoinName: SupportSCoin | SupportMarketCoins, ownerAddress?: string): Promise<number>;
449
+ /**
450
+ * Get swap rate from sCoin A to sCoin B
451
+ * @param assetCoinNames
452
+ * @returns
453
+ */
454
+ getSCoinSwapRate(fromSCoin: SupportSCoin, toSCoin: SupportSCoin): Promise<number>;
455
+ getFlashLoanFees(assetCoinNames?: SupportAssetCoins[]): Promise<Record<"usdc" | "sbeth" | "weth" | "wbtc" | "wusdc" | "wusdt" | "sui" | "wapt" | "wsol" | "cetus" | "afsui" | "hasui" | "vsui" | "sca", number>>;
456
+ /**
457
+ * Get supply limit of supply pool
458
+ */
459
+ getPoolSupplyLimit(poolName: SupportPoolCoins): Promise<string | null>;
460
+ /**
461
+ * Get list of isolated assets
462
+ */
463
+ getIsolatedAssets(): Promise<string[]>;
464
+ /**
465
+ * Check if asset is an isolated asset
466
+ */
467
+ isIsolatedAsset(assetCoinName: SupportAssetCoins): Promise<boolean>;
468
+ /**
469
+ * Get pool coin price from indexer
470
+ * @param coinName
471
+ * @returns price data
472
+ */
473
+ getCoinPriceByIndexer(poolName: SupportPoolCoins): Promise<number>;
474
+ }
@@ -0,0 +1,217 @@
1
+ import { SuiKit } from '@scallop-io/sui-kit';
2
+ import { ScallopAddress } from './scallopAddress';
3
+ import { ScallopCache } from './scallopCache';
4
+ import type { ScallopUtilsParams, SupportCoins, SupportAssetCoins, SupportMarketCoins, SupportStakeMarketCoins, SupportBorrowIncentiveCoins, CoinWrappedType, SupportSCoin, ScallopUtilsInstanceParams, SupportSuiBridgeCoins, SupportWormholeCoins } from '../types';
5
+ import type { SuiObjectArg, SuiTxArg, SuiTxBlock } from '@scallop-io/sui-kit';
6
+ /**
7
+ * @description
8
+ * Integrates some helper functions frequently used in interactions with the Scallop contract.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const scallopUtils = new ScallopUtils(<parameters>);
13
+ * await scallopUtils.init();
14
+ * scallopUtils.<utils functions>();
15
+ * await scallopUtils.<utils functions>();
16
+ * ```
17
+ */
18
+ export declare class ScallopUtils {
19
+ readonly params: ScallopUtilsParams;
20
+ readonly isTestnet: boolean;
21
+ suiKit: SuiKit;
22
+ address: ScallopAddress;
23
+ cache: ScallopCache;
24
+ walletAddress: string;
25
+ private _priceMap;
26
+ constructor(params: ScallopUtilsParams, instance?: ScallopUtilsInstanceParams);
27
+ isSuiBridgeAsset(coinName: any): coinName is SupportSuiBridgeCoins;
28
+ isWormholeAsset(coinName: any): coinName is SupportWormholeCoins;
29
+ /**
30
+ * Request the scallop API to initialize data.
31
+ *
32
+ * @param force - Whether to force initialization.
33
+ * @param address - ScallopAddress instance.
34
+ */
35
+ init(force?: boolean, address?: ScallopAddress): Promise<void>;
36
+ /**
37
+ * Convert coin name to symbol.
38
+ *
39
+ * @param coinName - Specific support coin name.
40
+ * @return Symbol string.
41
+ */
42
+ parseSymbol(coinName: SupportCoins): string;
43
+ /**
44
+ * Convert coin name to coin type.
45
+ *
46
+ * @description
47
+ * The Coin type of wormhole is fixed `coin:Coin`. Here using package id
48
+ * to determine and return the type.
49
+ *
50
+ * @param coinPackageId - Package id of coin.
51
+ * @param coinName - Specific support coin name.
52
+ * @return Coin type.
53
+ */
54
+ parseCoinType(coinName: SupportCoins): string;
55
+ /**
56
+ * Convert coin name to sCoin name.
57
+ *
58
+ * @param coinName - Specific support coin name.
59
+ * @return sCoin name.
60
+ */
61
+ parseSCoinName<T extends SupportSCoin>(coinName: SupportCoins | SupportMarketCoins): T | undefined;
62
+ /**
63
+ * Convert sCoin name into sCoin type
64
+ * @param sCoinName
65
+ * @returns sCoin type
66
+ */
67
+ parseSCoinType(sCoinName: SupportSCoin): string;
68
+ /**
69
+ * Convert sCoin name into its underlying coin type
70
+ * @param sCoinName
71
+ * @returns coin type
72
+ */
73
+ parseUnderlyingSCoinType(sCoinName: SupportSCoin): string;
74
+ /**
75
+ * Get sCoin treasury id from sCoin name
76
+ * @param sCoinName
77
+ * @returns sCoin treasury id
78
+ */
79
+ getSCoinTreasury(sCoinName: SupportSCoin): any;
80
+ /**
81
+ * Convert coin name to market coin type.
82
+ *
83
+ * @param coinPackageId - Package id of coin.
84
+ * @param coinName - Specific support coin name.
85
+ * @return Market coin type.
86
+ */
87
+ parseMarketCoinType(coinName: SupportCoins): string;
88
+ /**
89
+ * Convert coin type to coin name.
90
+ *
91
+ * @description
92
+ * The coin name cannot be obtained directly from the wormhole type. Here
93
+ * the package id is used to determine and return a specific name.
94
+ *
95
+ * @param coinType - Specific support coin type.
96
+ * @return Coin Name.
97
+ */
98
+ parseCoinNameFromType<T extends SupportAssetCoins>(coinType: string): T extends SupportAssetCoins ? T : SupportAssetCoins;
99
+ parseCoinNameFromType<T extends SupportMarketCoins>(coinType: string): T extends SupportMarketCoins ? T : SupportMarketCoins;
100
+ parseCoinNameFromType<T extends SupportCoins>(coinType: string): T extends SupportCoins ? T : SupportCoins;
101
+ /**
102
+ * Convert market coin name to coin name.
103
+ *
104
+ * @param marketCoinName - Specific support market coin name.
105
+ * @return Coin Name.
106
+ */
107
+ parseCoinName<T extends SupportAssetCoins>(marketCoinName: string): T;
108
+ /**
109
+ * Convert coin name to market coin name.
110
+ *
111
+ * @param coinName - Specific support coin name.
112
+ * @return Market coin name.
113
+ */
114
+ parseMarketCoinName<T extends SupportMarketCoins>(coinName: SupportCoins): T;
115
+ /**
116
+ * Get reward type of spool.
117
+ *
118
+ * @param stakeMarketCoinName - Support stake market coin.
119
+ * @return Spool reward coin name.
120
+ */
121
+ getSpoolRewardCoinName: (stakeMarketCoinName: SupportStakeMarketCoins) => "sui";
122
+ /**
123
+ * Get reward type of borrow incentive pool.
124
+ *
125
+ * @param borrowIncentiveCoinName - Support borrow incentive coin.
126
+ * @return Borrow incentive reward coin name.
127
+ */
128
+ getBorrowIncentiveRewardCoinName: (borrowIncentiveCoinName: SupportBorrowIncentiveCoins) => ("sui" | "sca")[];
129
+ /**
130
+ * Get coin decimal.
131
+ *
132
+ * return Coin decimal.
133
+ */
134
+ getCoinDecimal(coinName: SupportCoins): number;
135
+ /**
136
+ * Get coin wrapped type.
137
+ *
138
+ * return Coin wrapped type.
139
+ */
140
+ getCoinWrappedType(assetCoinName: SupportAssetCoins): CoinWrappedType;
141
+ /**
142
+ * Select coin id that add up to the given amount as transaction arguments.
143
+ *
144
+ * @param ownerAddress - The address of the owner.
145
+ * @param amount - The amount that including coin decimals.
146
+ * @param coinType - The coin type, default is 0x2::SUI::SUI.
147
+ * @return The selected transaction coin arguments.
148
+ */
149
+ selectCoins(amount: number, coinType?: string, ownerAddress?: string): Promise<{
150
+ objectId: string;
151
+ digest: string;
152
+ version: string;
153
+ balance: string;
154
+ }[]>;
155
+ /**
156
+ * Merge coins with type `coinType` to dest
157
+ * @param txBlock
158
+ * @param dest
159
+ * @param coinType
160
+ * @param sender
161
+ */
162
+ mergeSimilarCoins(txBlock: SuiTxBlock, dest: SuiTxArg, coinType: string, sender?: string): Promise<void>;
163
+ /**
164
+ * Get all asset coin names in the obligation record by obligation id.
165
+ *
166
+ * @description
167
+ * This can often be used to determine which assets in an obligation require
168
+ * price updates before interacting with specific instructions of the Scallop contract.
169
+ *
170
+ * @param obligationId - The obligation id.
171
+ * @return Asset coin Names.
172
+ */
173
+ getObligationCoinNames(obligationId: SuiObjectArg): Promise<SupportAssetCoins[] | undefined>;
174
+ /**
175
+ * Get asset coin price.
176
+ *
177
+ * @description
178
+ * The strategy for obtaining the price is to get it through API first,
179
+ * and then on-chain data if API cannot be retrieved.
180
+ * Currently, we only support obtaining from pyth protocol, other
181
+ * oracles will be supported in the future.
182
+ *
183
+ * @param assetCoinNames - Specific an array of support asset coin name.
184
+ * @return Asset coin price.
185
+ */
186
+ getCoinPrices(assetCoinNames?: SupportAssetCoins[]): Promise<import("../types").OptionalKeys<Record<SupportAssetCoins, number>>>;
187
+ /**
188
+ * Convert apr to apy.
189
+ *
190
+ * @param apr The annual percentage rate (APR).
191
+ * @param compoundFrequency How often interest is compounded per year. Default is daily (365 times a year).
192
+ * @return The equivalent annual percentage yield (APY) for the given APR and compounding frequency.
193
+ */
194
+ parseAprToApy(apr: number, compoundFrequency?: number): number;
195
+ /**
196
+ * Convert apy to apr.
197
+ *
198
+ * @param apr The equivalent annual percentage yield (APY).
199
+ * @param compoundFrequency How often interest is compounded per year. Default is daily (365 times a year).
200
+ * @return The equivalent annual percentage rate (APR) for the given APY and compounding frequency.
201
+ */
202
+ parseApyToApr(apy: number, compoundFrequency?: number): number;
203
+ /**
204
+ * Give extend lock period to get unlock at in seconds timestamp.
205
+ *
206
+ * @description
207
+ * - When the user without remaining unlock period, If the extended unlock day is not specified,
208
+ * the unlock period will be increased by one day by default.
209
+ * - When the given extended day plus the user's remaining unlock period exceeds the maximum
210
+ * unlock period, the maximum unlock period is used as unlock period.
211
+ *
212
+ * @param extendLockPeriodInDay The extend lock period in day.
213
+ * @param unlockAtInSecondTimestamp The unlock timestamp from veSca object.
214
+ * @return New unlock at in seconds timestamp.
215
+ */
216
+ getUnlockAt(extendLockPeriodInDay?: number, unlockAtInMillisTimestamp?: number): number;
217
+ }