@scallop-io/sui-scallop-sdk 1.3.4 → 1.3.5-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 (37) hide show
  1. package/dist/constants/common.d.ts +3 -3
  2. package/dist/constants/enum.d.ts +2 -1
  3. package/dist/constants/tokenBucket.d.ts +1 -1
  4. package/dist/index.js +200 -121
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +199 -121
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/models/scallopQuery.d.ts +41 -7
  9. package/dist/models/scallopUtils.d.ts +10 -3
  10. package/dist/queries/borrowIncentiveQuery.d.ts +2 -2
  11. package/dist/queries/coreQuery.d.ts +0 -2
  12. package/dist/queries/portfolioQuery.d.ts +0 -2
  13. package/dist/queries/priceQuery.d.ts +32 -2
  14. package/dist/queries/sCoinQuery.d.ts +1 -1
  15. package/dist/types/constant/common.d.ts +1 -1
  16. package/dist/types/utils.d.ts +2 -6
  17. package/package.json +1 -1
  18. package/src/constants/coinGecko.ts +3 -2
  19. package/src/constants/common.ts +10 -5
  20. package/src/constants/enum.ts +54 -31
  21. package/src/constants/poolAddress.ts +10 -7
  22. package/src/constants/pyth.ts +3 -2
  23. package/src/constants/tokenBucket.ts +1 -1
  24. package/src/models/scallopQuery.ts +14 -1
  25. package/src/models/scallopUtils.ts +14 -2
  26. package/src/queries/borrowIncentiveQuery.ts +29 -12
  27. package/src/queries/borrowLimitQuery.ts +3 -2
  28. package/src/queries/coreQuery.ts +4 -9
  29. package/src/queries/isolatedAssetQuery.ts +3 -2
  30. package/src/queries/portfolioQuery.ts +65 -62
  31. package/src/queries/priceQuery.ts +36 -2
  32. package/src/queries/sCoinQuery.ts +1 -1
  33. package/src/queries/spoolQuery.ts +2 -4
  34. package/src/queries/supplyLimitQuery.ts +3 -2
  35. package/src/types/constant/common.ts +1 -2
  36. package/src/types/utils.ts +2 -10
  37. package/src/utils/query.ts +0 -87
package/dist/index.mjs CHANGED
@@ -23,9 +23,10 @@ var COIN_GECKGO_IDS = {
23
23
  afsui: "sui",
24
24
  hasui: "sui",
25
25
  vsui: "sui",
26
- sca: "scallop-2",
27
- deep: "deepbook",
28
- fud: "fud-the-pug"
26
+ sca: "scallop-2"
27
+ // TODO: enable for production
28
+ // deep: 'deepbook',
29
+ // fud: 'fud-the-pug',
29
30
  };
30
31
 
31
32
  // src/constants/common.ts
@@ -54,9 +55,10 @@ var SUPPORT_POOLS = [
54
55
  "afsui",
55
56
  "hasui",
56
57
  "vsui",
57
- "sca",
58
- "fud",
59
- "deep"
58
+ "sca"
59
+ // TODO: enable for production
60
+ // 'fud',
61
+ // 'deep',
60
62
  ];
61
63
  var SUPPORT_COLLATERALS = [
62
64
  "usdc",
@@ -100,9 +102,10 @@ var SUPPORT_SCOIN = [
100
102
  "ssca",
101
103
  "scetus",
102
104
  "swsol",
103
- "swbtc",
104
- "sdeep",
105
- "sfud"
105
+ "swbtc"
106
+ // TODO: enable for production
107
+ // 'sdeep',
108
+ // 'sfud',
106
109
  ];
107
110
  var SUPPORT_SUI_BRIDGE = ["sbeth"];
108
111
  var SUPPORT_WORMHOLE = [
@@ -126,7 +129,10 @@ var SUPPORT_BORROW_INCENTIVE_POOLS = [
126
129
  "sca",
127
130
  "usdc"
128
131
  ];
129
- var SUPPORT_BORROW_INCENTIVE_REWARDS = ["sui", "sca"];
132
+ var SUPPORT_BORROW_INCENTIVE_REWARDS = [
133
+ ...SUPPORT_POOLS,
134
+ ...SUPPORT_SCOIN
135
+ ];
130
136
  var SUPPORT_ORACLES = ["supra", "switchboard", "pyth"];
131
137
  var SUPPORT_PACKAGES = [
132
138
  "coinDecimalsRegistry",
@@ -159,8 +165,9 @@ var coinDecimals = {
159
165
  hasui: 9,
160
166
  vsui: 9,
161
167
  sca: 9,
162
- deep: 6,
163
- fud: 5,
168
+ // TODO: enable for production
169
+ // deep: 6,
170
+ // fud: 5,
164
171
  susdc: 6,
165
172
  sweth: 8,
166
173
  ssbeth: 8,
@@ -174,9 +181,10 @@ var coinDecimals = {
174
181
  safsui: 9,
175
182
  shasui: 9,
176
183
  svsui: 9,
177
- ssca: 9,
178
- sdeep: 6,
179
- sfud: 5
184
+ ssca: 9
185
+ // TODO: enable for production
186
+ // sdeep: 6,
187
+ // sfud: 5,
180
188
  };
181
189
  var assetCoins = {
182
190
  usdc: "usdc",
@@ -192,9 +200,10 @@ var assetCoins = {
192
200
  afsui: "afsui",
193
201
  hasui: "hasui",
194
202
  vsui: "vsui",
195
- sca: "sca",
196
- deep: "deep",
197
- fud: "fud"
203
+ sca: "sca"
204
+ // TODO: enable for production
205
+ // deep: 'deep',
206
+ // fud: 'fud',
198
207
  };
199
208
  var marketCoins = {
200
209
  susdc: "susdc",
@@ -210,9 +219,10 @@ var marketCoins = {
210
219
  safsui: "safsui",
211
220
  shasui: "shasui",
212
221
  svsui: "svsui",
213
- ssca: "ssca",
214
- sdeep: "sdeep",
215
- sfud: "sfud"
222
+ ssca: "ssca"
223
+ // TODO: enable for production
224
+ // sdeep: 'sdeep',
225
+ // sfud: 'sfud',
216
226
  };
217
227
  var sCoins = {
218
228
  susdc: "susdc",
@@ -227,9 +237,10 @@ var sCoins = {
227
237
  svsui: "svsui",
228
238
  ssca: "ssca",
229
239
  swsol: "swsol",
230
- swbtc: "swbtc",
231
- sfud: "sfud",
232
- sdeep: "sdeep"
240
+ swbtc: "swbtc"
241
+ // TODO: enable for production
242
+ // sfud: 'sfud',
243
+ // sdeep: 'sdeep',
233
244
  };
234
245
  var stakeMarketCoins = {
235
246
  susdc: "susdc",
@@ -257,16 +268,16 @@ var suiBridgeCoins = {
257
268
  sbeth: "sbeth"
258
269
  };
259
270
  var borrowIncentiveRewardCoins = {
260
- usdc: ["sui", "sca"],
261
- sui: ["sui", "sca"],
262
- wusdc: ["sui", "sca"],
263
- wusdt: ["sui", "sca"],
264
- sca: ["sui", "sca"],
265
- afsui: ["sui"],
266
- hasui: ["sui"],
267
- vsui: ["sui"],
268
- weth: ["sui"],
269
- sbeth: ["sui"]
271
+ usdc: ["ssui", "ssca"],
272
+ sui: ["ssui", "ssca"],
273
+ wusdc: ["ssui", "ssca"],
274
+ wusdt: ["ssui", "ssca"],
275
+ sca: ["ssui", "ssca"],
276
+ afsui: ["ssui"],
277
+ hasui: ["ssui"],
278
+ vsui: ["ssui"],
279
+ weth: ["ssui"],
280
+ sbeth: ["ssui"]
270
281
  };
271
282
  var coinIds = {
272
283
  usdc: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7",
@@ -282,10 +293,10 @@ var coinIds = {
282
293
  afsui: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc",
283
294
  hasui: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d",
284
295
  vsui: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55",
285
- sca: IS_VE_SCA_TEST ? "0x6cd813061a3adf3602b76545f076205f0c8e7ec1d3b1eab9a1da7992c18c0524" : "0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6",
296
+ sca: IS_VE_SCA_TEST ? "0x6cd813061a3adf3602b76545f076205f0c8e7ec1d3b1eab9a1da7992c18c0524" : "0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6"
286
297
  // isolated assets
287
- deep: "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270",
288
- fud: "0x76cb819b01abed502bee8a702b4c2d547532c12f25001c9dea795a5e631c26f1"
298
+ // deep: '0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270',
299
+ // fud: '0x76cb819b01abed502bee8a702b4c2d547532c12f25001c9dea795a5e631c26f1',
289
300
  };
290
301
  var wormholeCoinIds = {
291
302
  weth: "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5",
@@ -301,19 +312,28 @@ var voloCoinIds = {
301
312
  var sCoinIds = {
302
313
  susdc: "0x854950aa624b1df59fe64e630b2ba7c550642e9342267a33061d59fb31582da5::scallop_usdc::SCALLOP_USDC",
303
314
  ssbeth: "0xb14f82d8506d139eacef109688d1b71e7236bcce9b2c0ad526abcd6aa5be7de0::scallop_sb_eth::SCALLOP_SB_ETH",
304
- ssui: "0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI",
315
+ // prod values
316
+ // ssui: '0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI',
317
+ // swusdc:
318
+ // '0xad4d71551d31092230db1fd482008ea42867dbf27b286e9c70a79d2a6191d58d::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC',
319
+ // swusdt:
320
+ // '0xe6e5a012ec20a49a3d1d57bd2b67140b96cd4d3400b9d79e541f7bdbab661f95::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT',
321
+ // ssca: '0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA',
322
+ // test values
323
+ ssui: "0xf569919046f19a0c40b519ecfbb6ca0319698cd5908716c29b62ef56541f298b::scallop_sui::SCALLOP_SUI",
324
+ swusdt: "0xac781d9f73058ff5e69f9bf8dde32f2e8c71c66d7fe8497fc83b2d9182254b22::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT",
325
+ swusdc: "0xf5447c4305a486d8c8557559887c2c39449ddb5e748f15d33946d02a1663c158::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC",
326
+ ssca: "0x958428555e778e55918a59eb1c92c77f32b5c554fa3a5e56cd0815086b5072e7::scallop_sca::SCALLOP_SCA",
305
327
  scetus: "0xea346ce428f91ab007210443efcea5f5cdbbb3aae7e9affc0ca93f9203c31f0c::scallop_cetus::SCALLOP_CETUS",
306
- ssca: "0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA",
307
- swusdc: "0xad4d71551d31092230db1fd482008ea42867dbf27b286e9c70a79d2a6191d58d::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC",
308
- swusdt: "0xe6e5a012ec20a49a3d1d57bd2b67140b96cd4d3400b9d79e541f7bdbab661f95::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT",
309
328
  sweth: "0x67540ceb850d418679e69f1fb6b2093d6df78a2a699ffc733f7646096d552e9b::scallop_wormhole_eth::SCALLOP_WORMHOLE_ETH",
310
329
  safsui: "0x00671b1fa2a124f5be8bdae8b91ee711462c5d9e31bda232e70fd9607b523c88::scallop_af_sui::SCALLOP_AF_SUI",
311
330
  shasui: "0x9a2376943f7d22f88087c259c5889925f332ca4347e669dc37d54c2bf651af3c::scallop_ha_sui::SCALLOP_HA_SUI",
312
331
  svsui: "0xe1a1cc6bcf0001a015eab84bcc6713393ce20535f55b8b6f35c142e057a25fbe::scallop_v_sui::SCALLOP_V_SUI",
313
332
  swsol: "0x1392650f2eca9e3f6ffae3ff89e42a3590d7102b80e2b430f674730bc30d3259::scallop_wormhole_sol::SCALLOP_WORMHOLE_SOL",
314
- swbtc: "0x2cf76a9cf5d3337961d1154283234f94da2dcff18544dfe5cbdef65f319591b5::scallop_wormhole_btc::SCALLOP_WORMHOLE_BTC",
315
- sdeep: "0xeb7a05a3224837c5e5503575aed0be73c091d1ce5e43aa3c3e716e0ae614608f::scallop_deep::SCALLOP_DEEP",
316
- sfud: "0xe56d5167f427cbe597da9e8150ef5c337839aaf46891d62468dcf80bdd8e10d1::scallop_fud::SCALLOP_FUD"
333
+ swbtc: "0x2cf76a9cf5d3337961d1154283234f94da2dcff18544dfe5cbdef65f319591b5::scallop_wormhole_btc::SCALLOP_WORMHOLE_BTC"
334
+ // sdeep:
335
+ // '0xeb7a05a3224837c5e5503575aed0be73c091d1ce5e43aa3c3e716e0ae614608f::scallop_deep::SCALLOP_DEEP',
336
+ // sfud: '0xe56d5167f427cbe597da9e8150ef5c337839aaf46891d62468dcf80bdd8e10d1::scallop_fud::SCALLOP_FUD',
317
337
  };
318
338
  var sCoinTypeToName = Object.entries(sCoinIds).reduce(
319
339
  (acc, [coinName, coinType]) => {
@@ -322,6 +342,13 @@ var sCoinTypeToName = Object.entries(sCoinIds).reduce(
322
342
  },
323
343
  {}
324
344
  );
345
+ var sCoinRawNameToName = Object.entries(sCoinIds).reduce(
346
+ (acc, [coinName, coinType]) => {
347
+ acc[coinType.split("::")[2].toLowerCase()] = coinName;
348
+ return acc;
349
+ },
350
+ {}
351
+ );
325
352
 
326
353
  // src/constants/flashloan.ts
327
354
  var FlashLoanFeeObjectMap = {
@@ -396,13 +423,16 @@ var POOL_ADDRESSES = {
396
423
  sca: {
397
424
  lendingPoolAddress: "0x6fc7d4211fc7018b6c75e7b908b88f2e0536443239804a3d32af547637bd28d7",
398
425
  collateralPoolAddress: "0xff677a5d9e9dc8f08f0a8681ebfc7481d1c7d57bc441f2881974adcdd7b13c31"
399
- },
400
- fud: {
401
- lendingPoolAddress: ""
402
- },
403
- deep: {
404
- lendingPoolAddress: ""
405
426
  }
427
+ // TODO: enable for production
428
+ // fud: {
429
+ // lendingPoolAddress:
430
+ // '0x14367ddca30e2860cb89ed4eaca20c7ece260c5d59dd9990d2c85a8321326acb',
431
+ // },
432
+ // deep: {
433
+ // lendingPoolAddress:
434
+ // '0xf4a67ffb43da1e1c61c049f188f19463ea8dbbf2d5ef4722d6df854ff1b1cc03',
435
+ // },
406
436
  };
407
437
 
408
438
  // src/constants/pyth.ts
@@ -424,9 +454,10 @@ var PYTH_FEED_IDS = {
424
454
  afsui: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
425
455
  hasui: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
426
456
  vsui: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
427
- sca: "7e17f0ac105abe9214deb9944c30264f5986bf292869c6bd8e8da3ccd92d79bc",
428
- deep: "29bdd5248234e33bd93d3b81100b5fa32eaa5997843847e2c2cb16d7c6d9f7ff",
429
- fud: "6a4090703da959247727f2b490eb21aea95c8684ecfac675f432008830890c75"
457
+ sca: "7e17f0ac105abe9214deb9944c30264f5986bf292869c6bd8e8da3ccd92d79bc"
458
+ // TODO: enable for production
459
+ // deep: '29bdd5248234e33bd93d3b81100b5fa32eaa5997843847e2c2cb16d7c6d9f7ff',
460
+ // fud: '6a4090703da959247727f2b490eb21aea95c8684ecfac675f432008830890c75',
430
461
  };
431
462
 
432
463
  // src/constants/queryKeys.ts
@@ -951,7 +982,7 @@ var TEST_ADDRESSES = {
951
982
  };
952
983
 
953
984
  // src/constants/tokenBucket.ts
954
- var DEFAULT_TOKENS_PER_INTERVAL = 10;
985
+ var DEFAULT_TOKENS_PER_INTERVAL = 50;
955
986
  var DEFAULT_INTERVAL_IN_MS = 300;
956
987
 
957
988
  // src/constants/vesca.ts
@@ -2466,15 +2497,21 @@ var queryBorrowIncentivePools = async (address) => {
2466
2497
  };
2467
2498
  var getBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
2468
2499
  ...SUPPORT_BORROW_INCENTIVE_POOLS
2469
- ], indexer = false, coinPrices) => {
2500
+ ], indexer = false, marketPools, coinPrices) => {
2470
2501
  const borrowIncentivePools = {};
2471
- coinPrices = coinPrices ?? await query.utils.getCoinPrices() ?? {};
2502
+ marketPools = marketPools ?? await query.getMarketPools(void 0, false, { coinPrices });
2503
+ coinPrices = coinPrices ?? await query.getAllCoinPrices({ marketPools });
2472
2504
  if (indexer) {
2473
2505
  const borrowIncentivePoolsIndexer = await query.indexer.getBorrowIncentivePools();
2474
2506
  const updateBorrowIncentivePool = (pool) => {
2475
2507
  if (!borrowIncentiveCoinNames.includes(pool.coinName))
2476
2508
  return;
2477
- pool.coinPrice = coinPrices[pool.coinName] ?? pool.coinPrice;
2509
+ pool.coinPrice = coinPrices[pool.coinName] || pool.coinPrice;
2510
+ for (const sCoinName of SUPPORT_BORROW_INCENTIVE_REWARDS) {
2511
+ if (pool.points[sCoinName]) {
2512
+ pool.points[sCoinName].coinPrice = coinPrices[sCoinName] ?? pool.points[sCoinName].coinPrice;
2513
+ }
2514
+ }
2478
2515
  borrowIncentivePools[pool.coinName] = pool;
2479
2516
  };
2480
2517
  Object.values(borrowIncentivePoolsIndexer).forEach(
@@ -2500,12 +2537,15 @@ var getBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
2500
2537
  for (const [coinName, poolPoint] of Object.entries(
2501
2538
  parsedBorrowIncentivePoolData.poolPoints
2502
2539
  )) {
2503
- const rewardCoinType = normalizeStructTag3(poolPoint.pointType);
2504
- const rewardCoinName = query.utils.parseCoinNameFromType(
2540
+ const rewardCoinType = poolPoint.pointType;
2541
+ let rewardCoinName = query.utils.parseCoinNameFromType(
2505
2542
  rewardCoinType
2506
2543
  );
2507
- const rewardCoinPrice = coinPrices?.[rewardCoinName] ?? 0;
2544
+ if (sCoinRawNameToName[rewardCoinName]) {
2545
+ rewardCoinName = sCoinRawNameToName[rewardCoinName];
2546
+ }
2508
2547
  const rewardCoinDecimal = query.utils.getCoinDecimal(rewardCoinName);
2548
+ const rewardCoinPrice = coinPrices?.[rewardCoinName] ?? 0;
2509
2549
  const symbol = query.utils.parseSymbol(rewardCoinName);
2510
2550
  const coinDecimal = query.utils.getCoinDecimal(rewardCoinName);
2511
2551
  const calculatedPoolPoint = calculateBorrowIncentivePoolPointData(
@@ -2651,7 +2691,7 @@ var supplyLimitZod = zod.object({
2651
2691
  value: zod.string()
2652
2692
  })
2653
2693
  });
2654
- var supplyLimitKeyType = `0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e::market_dynamic_keys::SupplyLimitKey`;
2694
+ var supplyLimitKeyType = `0x6c23585e940a989588432509107e98bae06dbca4e333f26d0635d401b3c7c76d::market_dynamic_keys::SupplyLimitKey`;
2655
2695
  var getSupplyLimit = async (utils, poolName) => {
2656
2696
  try {
2657
2697
  const poolCoinType = utils.parseCoinType(poolName).slice(2);
@@ -2691,7 +2731,7 @@ var isolatedAssetZod = zod2.object({
2691
2731
  value: zod2.boolean()
2692
2732
  })
2693
2733
  });
2694
- var isolatedAssetKeyType = `0xe7dbb371a9595631f7964b7ece42255ad0e738cc85fe6da26c7221b220f01af6::market_dynamic_keys::IsolatedAssetKey`;
2734
+ var isolatedAssetKeyType = `0x6c23585e940a989588432509107e98bae06dbca4e333f26d0635d401b3c7c76d::market_dynamic_keys::IsolatedAssetKey`;
2695
2735
  var getIsolatedAssets = async (address) => {
2696
2736
  try {
2697
2737
  const marketObject = address.get("core.market");
@@ -2771,7 +2811,7 @@ var borrowLimitZod = zod3.object({
2771
2811
  value: zod3.string()
2772
2812
  })
2773
2813
  });
2774
- var borrowLimitKeyType = `0xe7dbb371a9595631f7964b7ece42255ad0e738cc85fe6da26c7221b220f01af6::market_dynamic_keys::BorrowLimitKey`;
2814
+ var borrowLimitKeyType = `0xb784ea287d944e478a3ceaa071f8885072cce6b7224cf245914dc2f9963f460e::market_dynamic_keys::BorrowLimitKey`;
2775
2815
  var getBorrowLimit = async (utils, poolName) => {
2776
2816
  try {
2777
2817
  const poolCoinType = utils.parseCoinType(poolName).slice(2);
@@ -2938,7 +2978,7 @@ var getMarketPools = async (query, poolCoinNames = [...SUPPORT_POOLS], indexer =
2938
2978
  const marketObjectResponse = await query.cache.queryGetObject(marketId, {
2939
2979
  showContent: true
2940
2980
  });
2941
- coinPrices = await query.utils.getCoinPrices(poolCoinNames) ?? {};
2981
+ coinPrices = coinPrices ?? await query.utils.getCoinPrices();
2942
2982
  const marketPools = {};
2943
2983
  if (indexer) {
2944
2984
  const marketPoolsIndexer = await query.indexer.getMarketPools();
@@ -2972,7 +3012,7 @@ var getMarketPools = async (query, poolCoinNames = [...SUPPORT_POOLS], indexer =
2972
3012
  };
2973
3013
  var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, coinPrice) => {
2974
3014
  try {
2975
- coinPrice = coinPrice || (await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName];
3015
+ coinPrice = coinPrice ?? (await query.utils.getCoinPrices())?.[poolCoinName];
2976
3016
  if (indexer) {
2977
3017
  const marketPoolIndexer = await query.indexer.getMarketPool(poolCoinName);
2978
3018
  if (!marketPoolIndexer) {
@@ -3118,7 +3158,7 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
3118
3158
  };
3119
3159
  var getMarketCollaterals = async (query, collateralCoinNames = [...SUPPORT_COLLATERALS], indexer = false) => {
3120
3160
  const marketId = query.address.get("core.market");
3121
- const coinPrices = await query.utils.getCoinPrices(collateralCoinNames) ?? {};
3161
+ const coinPrices = await query.utils.getCoinPrices() ?? {};
3122
3162
  const marketCollaterals = {};
3123
3163
  if (indexer) {
3124
3164
  const marketCollateralsIndexer = await query.indexer.getMarketCollaterals();
@@ -3154,7 +3194,7 @@ var getMarketCollaterals = async (query, collateralCoinNames = [...SUPPORT_COLLA
3154
3194
  return marketCollaterals;
3155
3195
  };
3156
3196
  var getMarketCollateral = async (query, collateralCoinName, indexer = false, marketObject, coinPrice) => {
3157
- coinPrice = coinPrice || (await query.utils.getCoinPrices([collateralCoinName]))?.[collateralCoinName];
3197
+ coinPrice = coinPrice ?? (await query.utils.getCoinPrices())?.[collateralCoinName];
3158
3198
  if (indexer) {
3159
3199
  const marketCollateralIndexer = await query.indexer.getMarketCollateral(collateralCoinName);
3160
3200
  marketCollateralIndexer.coinPrice = coinPrice ?? marketCollateralIndexer.coinPrice;
@@ -3470,7 +3510,7 @@ var getLendings = async (query, poolCoinNames = [...SUPPORT_POOLS], ownerAddress
3470
3510
  const stakeMarketCoinNames = marketCoinNames.filter(
3471
3511
  (marketCoinName) => SUPPORT_SPOOLS.includes(marketCoinName)
3472
3512
  );
3473
- const coinPrices = await query.utils.getCoinPrices(poolCoinNames);
3513
+ const coinPrices = await query.utils.getCoinPrices();
3474
3514
  const marketPools = await query.getMarketPools(poolCoinNames, indexer, {
3475
3515
  coinPrices
3476
3516
  });
@@ -3508,7 +3548,7 @@ var getLendings = async (query, poolCoinNames = [...SUPPORT_POOLS], ownerAddress
3508
3548
  };
3509
3549
  var getLending = async (query, poolCoinName, ownerAddress, indexer = false, marketPool, spool, stakeAccounts, coinAmount, marketCoinAmount, coinPrice, sCoinAmount) => {
3510
3550
  const marketCoinName = query.utils.parseMarketCoinName(poolCoinName);
3511
- coinPrice = coinPrice ?? (await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName] ?? 0;
3551
+ coinPrice = coinPrice ?? (await query.utils.getCoinPrices())?.[poolCoinName] ?? 0;
3512
3552
  marketPool = marketPool ?? await query.getMarketPool(poolCoinName, indexer, {
3513
3553
  coinPrice
3514
3554
  });
@@ -3668,8 +3708,8 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
3668
3708
  const collateralAssetCoinNames = [
3669
3709
  ...SUPPORT_COLLATERALS
3670
3710
  ];
3671
- coinPrices = coinPrices ?? await query.utils.getCoinPrices(collateralAssetCoinNames);
3672
- market = market ?? await query.queryMarket(indexer, { coinPrices });
3711
+ market = market ?? await query.queryMarket(indexer);
3712
+ coinPrices = coinPrices ?? await query.getAllCoinPrices({ marketPools: market.pools });
3673
3713
  coinAmounts = coinAmounts || await query.getCoinAmounts(collateralAssetCoinNames, ownerAddress);
3674
3714
  const [obligationQuery, borrowIncentivePools, borrowIncentiveAccounts] = await Promise.all([
3675
3715
  query.queryObligation(obligationId),
@@ -3810,44 +3850,47 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
3810
3850
  const borrowIncentivePool = borrowIncentivePools[coinName];
3811
3851
  if (borrowIncentivePool) {
3812
3852
  const rewards = [];
3813
- for (const rewardCoinName of SUPPORT_BORROW_INCENTIVE_REWARDS) {
3814
- const accountPoint = borrowIncentiveAccount.pointList[rewardCoinName];
3815
- const poolPoint = borrowIncentivePool.points[rewardCoinName];
3816
- if (accountPoint && poolPoint) {
3817
- let availableClaimAmount = BigNumber5(0);
3818
- let availableClaimCoin = BigNumber5(0);
3819
- const accountBorrowedAmount = BigNumber5(accountPoint.weightedAmount);
3820
- const baseIndexRate = 1e9;
3821
- const increasedPointRate = poolPoint.currentPointIndex ? Math.max(
3822
- BigNumber5(poolPoint.currentPointIndex - accountPoint.index).dividedBy(baseIndexRate).toNumber(),
3823
- 0
3824
- ) : 1;
3825
- availableClaimAmount = availableClaimAmount.plus(
3826
- accountBorrowedAmount.multipliedBy(increasedPointRate).plus(accountPoint.points)
3827
- );
3828
- availableClaimCoin = availableClaimAmount.shiftedBy(
3829
- -1 * poolPoint.coinDecimal
3830
- );
3831
- const weightScale = BigNumber5(1e12);
3832
- const boostValue = BigNumber5(accountPoint.weightedAmount).div(
3833
- BigNumber5(borrowIncentiveAccount.debtAmount).multipliedBy(poolPoint.baseWeight).dividedBy(weightScale)
3834
- ).isFinite() ? BigNumber5(accountPoint.weightedAmount).div(
3835
- BigNumber5(borrowIncentiveAccount.debtAmount).multipliedBy(poolPoint.baseWeight).dividedBy(weightScale)
3836
- ).toNumber() : 1;
3837
- if (availableClaimAmount.isGreaterThanOrEqualTo(0)) {
3838
- rewards.push({
3839
- coinName: poolPoint.coinName,
3840
- coinType: poolPoint.coinType,
3841
- symbol: poolPoint.symbol,
3842
- coinDecimal: poolPoint.coinDecimal,
3843
- coinPrice: poolPoint.coinPrice,
3844
- availableClaimAmount: availableClaimAmount.toNumber(),
3845
- availableClaimCoin: availableClaimCoin.toNumber(),
3846
- boostValue
3847
- });
3853
+ Object.entries(borrowIncentiveAccount.pointList).forEach(
3854
+ ([key, accountPoint]) => {
3855
+ const poolPoint = borrowIncentivePool.points[key];
3856
+ if (accountPoint && poolPoint) {
3857
+ let availableClaimAmount = BigNumber5(0);
3858
+ let availableClaimCoin = BigNumber5(0);
3859
+ const accountBorrowedAmount = BigNumber5(
3860
+ accountPoint.weightedAmount
3861
+ );
3862
+ const baseIndexRate = 1e9;
3863
+ const increasedPointRate = poolPoint.currentPointIndex ? Math.max(
3864
+ BigNumber5(poolPoint.currentPointIndex - accountPoint.index).dividedBy(baseIndexRate).toNumber(),
3865
+ 0
3866
+ ) : 1;
3867
+ availableClaimAmount = availableClaimAmount.plus(
3868
+ accountBorrowedAmount.multipliedBy(increasedPointRate).plus(accountPoint.points)
3869
+ );
3870
+ availableClaimCoin = availableClaimAmount.shiftedBy(
3871
+ -1 * poolPoint.coinDecimal
3872
+ );
3873
+ const weightScale = BigNumber5(1e12);
3874
+ const boostValue = BigNumber5(accountPoint.weightedAmount).div(
3875
+ BigNumber5(borrowIncentiveAccount.debtAmount).multipliedBy(poolPoint.baseWeight).dividedBy(weightScale)
3876
+ ).isFinite() ? BigNumber5(accountPoint.weightedAmount).div(
3877
+ BigNumber5(borrowIncentiveAccount.debtAmount).multipliedBy(poolPoint.baseWeight).dividedBy(weightScale)
3878
+ ).toNumber() : 1;
3879
+ if (availableClaimAmount.isGreaterThanOrEqualTo(0)) {
3880
+ rewards.push({
3881
+ coinName: poolPoint.coinName,
3882
+ coinType: poolPoint.coinType,
3883
+ symbol: poolPoint.symbol,
3884
+ coinDecimal: poolPoint.coinDecimal,
3885
+ coinPrice: poolPoint.coinPrice,
3886
+ availableClaimAmount: availableClaimAmount.toNumber(),
3887
+ availableClaimCoin: availableClaimCoin.toNumber(),
3888
+ boostValue
3889
+ });
3890
+ }
3848
3891
  }
3849
3892
  }
3850
- }
3893
+ );
3851
3894
  if (Object.keys(borrowIncentivePool.points).some((coinName2) => {
3852
3895
  const rewardApr = borrowIncentivePool.points[coinName2]?.rewardApr;
3853
3896
  return rewardApr !== Infinity && typeof rewardApr == "number" && rewardApr > 0;
@@ -3991,6 +4034,7 @@ var getTotalValueLocked = async (query, indexer = false) => {
3991
4034
  };
3992
4035
 
3993
4036
  // src/queries/priceQuery.ts
4037
+ import BigNumber6 from "bignumber.js";
3994
4038
  var getPythPrice = async ({
3995
4039
  address
3996
4040
  }, assetCoinName, priceFeedObject) => {
@@ -4072,6 +4116,22 @@ var getPythPrices = async ({
4072
4116
  {}
4073
4117
  );
4074
4118
  };
4119
+ var getAllCoinPrices = async (query, marketPools, coinPrices) => {
4120
+ coinPrices = coinPrices ?? await query.utils.getCoinPrices();
4121
+ marketPools = marketPools ?? await query.getMarketPools(void 0, void 0, { coinPrices });
4122
+ if (!marketPools) {
4123
+ throw new Error(`Failed to fetch market pool for getAllCoinPrices`);
4124
+ }
4125
+ const sCoinPrices = {};
4126
+ SUPPORT_SCOIN.forEach((sCoinName) => {
4127
+ const coinName = query.utils.parseCoinName(sCoinName);
4128
+ sCoinPrices[sCoinName] = BigNumber6(coinPrices[coinName] ?? 0).multipliedBy(marketPools[coinName]?.conversionRate ?? 1).toNumber();
4129
+ });
4130
+ return {
4131
+ ...coinPrices,
4132
+ ...sCoinPrices
4133
+ };
4134
+ };
4075
4135
 
4076
4136
  // src/queries/referralQuery.ts
4077
4137
  var queryVeScaKeyIdFromReferralBindings = async (address, refereeAddress) => {
@@ -4092,7 +4152,7 @@ var queryVeScaKeyIdFromReferralBindings = async (address, refereeAddress) => {
4092
4152
  // src/queries/sCoinQuery.ts
4093
4153
  import { bcs } from "@mysten/sui/bcs";
4094
4154
  import assert from "assert";
4095
- import BigNumber6 from "bignumber.js";
4155
+ import BigNumber7 from "bignumber.js";
4096
4156
  var getSCoinTotalSupply = async ({
4097
4157
  utils
4098
4158
  }, sCoinName) => {
@@ -4113,7 +4173,7 @@ var getSCoinTotalSupply = async ({
4113
4173
  const value = Uint8Array.from(results[0].returnValues[0][0]);
4114
4174
  const type = results[0].returnValues[0][1];
4115
4175
  assert(type === "u64", "Result type is not u64");
4116
- return BigNumber6(bcs.u64().parse(value)).shiftedBy(utils.getCoinDecimal(utils.parseCoinName(sCoinName))).toNumber();
4176
+ return BigNumber7(bcs.u64().parse(value)).shiftedBy(utils.getCoinDecimal(utils.parseCoinName(sCoinName))).toNumber();
4117
4177
  }
4118
4178
  return 0;
4119
4179
  };
@@ -4139,7 +4199,7 @@ var getSCoinAmount = async ({
4139
4199
  owner,
4140
4200
  coinType: sCoinType
4141
4201
  });
4142
- return BigNumber6(amount).toNumber();
4202
+ return BigNumber7(amount).toNumber();
4143
4203
  };
4144
4204
  var isSupportStakeCoins = (value) => {
4145
4205
  return SUPPORT_SCOIN.includes(value);
@@ -4169,7 +4229,7 @@ var getSCoinSwapRate = async (query, fromSCoin, toSCoin, underlyingCoinPrice) =>
4169
4229
  const ScoinAToARate = marketPools[0].conversionRate;
4170
4230
  const BtoSCoinBRate = 1 / marketPools[1].conversionRate;
4171
4231
  const calcAtoBRate = async () => {
4172
- const prices = await query.utils.getCoinPrices([fromCoinName, toCoinName]);
4232
+ const prices = await query.utils.getCoinPrices();
4173
4233
  if (!prices[fromCoinName] || !prices[toCoinName]) {
4174
4234
  throw new Error("Failed to fetch the coin prices");
4175
4235
  }
@@ -4179,7 +4239,7 @@ var getSCoinSwapRate = async (query, fromSCoin, toSCoin, underlyingCoinPrice) =>
4179
4239
  return prices[fromCoinName] / prices[toCoinName];
4180
4240
  };
4181
4241
  const AtoBRate = underlyingCoinPrice ?? await calcAtoBRate();
4182
- return BigNumber6(ScoinAToARate).multipliedBy(AtoBRate).multipliedBy(BtoSCoinBRate).toNumber();
4242
+ return BigNumber7(ScoinAToARate).multipliedBy(AtoBRate).multipliedBy(BtoSCoinBRate).toNumber();
4183
4243
  };
4184
4244
 
4185
4245
  // src/queries/spoolQuery.ts
@@ -4239,7 +4299,7 @@ var getSpool = async (query, marketCoinName, indexer = false, marketPool, coinPr
4239
4299
  `spool.pools.${marketCoinName}.rewardPoolId`
4240
4300
  );
4241
4301
  let spool = void 0;
4242
- coinPrices = coinPrices || await query.utils.getCoinPrices([coinName]);
4302
+ coinPrices = coinPrices || await query.utils.getCoinPrices();
4243
4303
  if (indexer) {
4244
4304
  const spoolIndexer = await query.indexer.getSpool(marketCoinName);
4245
4305
  const coinName2 = query.utils.parseCoinName(marketCoinName);
@@ -4259,7 +4319,7 @@ var getSpool = async (query, marketCoinName, indexer = false, marketPool, coinPr
4259
4319
  throw new Error("Fail to fetch spoolObjectResponse!");
4260
4320
  }
4261
4321
  const rewardCoinName = query.utils.getSpoolRewardCoinName(marketCoinName);
4262
- coinPrices = coinPrices || await query.utils.getCoinPrices([coinName, rewardCoinName]);
4322
+ coinPrices = coinPrices || await query.utils.getCoinPrices();
4263
4323
  const spoolObject = spoolObjectResponse[0];
4264
4324
  const rewardPoolObject = spoolObjectResponse[1];
4265
4325
  if (spoolObject.content && "fields" in spoolObject.content) {
@@ -4503,7 +4563,7 @@ var getStakeRewardPool = async ({
4503
4563
  };
4504
4564
 
4505
4565
  // src/queries/vescaQuery.ts
4506
- import BigNumber7 from "bignumber.js";
4566
+ import BigNumber8 from "bignumber.js";
4507
4567
  import { SUI_CLOCK_OBJECT_ID, SuiTxBlock as SuiTxBlock2 } from "@scallop-io/sui-kit";
4508
4568
  import { bcs as bcs2 } from "@mysten/sui/bcs";
4509
4569
  import { z as zod5 } from "zod";
@@ -4585,7 +4645,7 @@ var getVeSca = async (utils, veScaKey) => {
4585
4645
  0
4586
4646
  );
4587
4647
  const lockedScaAmount = String(dynamicFields.locked_sca_amount);
4588
- const lockedScaCoin = BigNumber7(dynamicFields.locked_sca_amount).shiftedBy(-9).toNumber();
4648
+ const lockedScaCoin = BigNumber8(dynamicFields.locked_sca_amount).shiftedBy(-9).toNumber();
4589
4649
  const currentVeScaBalance = lockedScaCoin * (Math.floor(remainingLockPeriodInMilliseconds / 1e3) / MAX_LOCK_DURATION);
4590
4650
  vesca = {
4591
4651
  id: veScaDynamicFieldObject.objectId,
@@ -4595,7 +4655,7 @@ var getVeSca = async (utils, veScaKey) => {
4595
4655
  lockedScaAmount,
4596
4656
  lockedScaCoin,
4597
4657
  currentVeScaBalance,
4598
- unlockAt: BigNumber7(dynamicFields.unlock_at * 1e3).toNumber()
4658
+ unlockAt: BigNumber8(dynamicFields.unlock_at * 1e3).toNumber()
4599
4659
  };
4600
4660
  }
4601
4661
  return vesca;
@@ -4657,10 +4717,10 @@ var getVeScaTreasuryInfo = async (utils) => {
4657
4717
  if (!veScaTreasury || veScaTreasury.data?.content?.dataType !== "moveObject")
4658
4718
  return null;
4659
4719
  const treasuryFields = veScaTreasury.data.content.fields;
4660
- const totalLockedSca = BigNumber7(
4720
+ const totalLockedSca = BigNumber8(
4661
4721
  treasuryFields.unlock_schedule.fields.locked_sca_amount
4662
4722
  ).shiftedBy(-9).toNumber();
4663
- const totalVeSca = BigNumber7(
4723
+ const totalVeSca = BigNumber8(
4664
4724
  await getTotalVeScaTreasuryAmount(utils, veScaTreasury.data) ?? 0
4665
4725
  ).shiftedBy(-9).toNumber();
4666
4726
  const averageLockingPeriod = totalLockedSca > 0 ? totalVeSca / totalLockedSca * 4 : 0;
@@ -4829,6 +4889,15 @@ var ScallopUtils = class {
4829
4889
  return void 0;
4830
4890
  }
4831
4891
  }
4892
+ /**
4893
+ * Convert sCoin name to coin name.
4894
+ * This function will parse new sCoin name `scallop_...` to its old market coin name which is shorter
4895
+ * e.g: `scallop_sui -> ssui
4896
+ * @return sCoin name
4897
+ */
4898
+ parseCoinNameFromSCoinName(coinName) {
4899
+ return sCoinRawNameToName[coinName];
4900
+ }
4832
4901
  /**
4833
4902
  * Convert sCoin name into sCoin type
4834
4903
  * @param sCoinName
@@ -4880,7 +4949,7 @@ var ScallopUtils = class {
4880
4949
  const coinTypeMatch = coinType.match(coinTypeRegex);
4881
4950
  const isMarketCoinType = coinType.includes("reserve::MarketCoin");
4882
4951
  coinType = coinTypeMatch?.[1] ?? coinType;
4883
- const wormHoleCoinTypeMap = {
4952
+ const wormholeCoinTypeMap = {
4884
4953
  [`${this.address.get("core.coins.wusdc.id") ?? wormholeCoinIds.wusdc}::coin::COIN`]: "wusdc",
4885
4954
  [`${this.address.get("core.coins.wusdt.id") ?? wormholeCoinIds.wusdt}::coin::COIN`]: "wusdt",
4886
4955
  [`${this.address.get("core.coins.weth.id") ?? wormholeCoinIds.weth}::coin::COIN`]: "weth",
@@ -4900,7 +4969,7 @@ var ScallopUtils = class {
4900
4969
  },
4901
4970
  {}
4902
4971
  );
4903
- const assetCoinName = wormHoleCoinTypeMap[coinType] || voloCoinTypeMap[coinType] || suiBridgeTypeMap[coinType] || coinType.split("::")[2].toLowerCase();
4972
+ const assetCoinName = wormholeCoinTypeMap[coinType] || voloCoinTypeMap[coinType] || suiBridgeTypeMap[coinType] || coinType.split("::")[2].toLowerCase();
4904
4973
  return isMarketCoinType ? this.parseMarketCoinName(assetCoinName) : assetCoinName;
4905
4974
  }
4906
4975
  /**
@@ -7294,6 +7363,7 @@ var ScallopQuery = class {
7294
7363
  this,
7295
7364
  coinNames,
7296
7365
  indexer,
7366
+ args?.marketPools,
7297
7367
  args?.coinPrices
7298
7368
  );
7299
7369
  }
@@ -7509,6 +7579,13 @@ var ScallopQuery = class {
7509
7579
  async getCoinPriceByIndexer(poolName) {
7510
7580
  return this.indexer.getCoinPrice(poolName);
7511
7581
  }
7582
+ /**
7583
+ * Get all coin prices, including sCoin
7584
+ * @returns prices data
7585
+ */
7586
+ async getAllCoinPrices(args) {
7587
+ return getAllCoinPrices(this, args?.marketPools, args?.coinPrices);
7588
+ }
7512
7589
  };
7513
7590
 
7514
7591
  // src/models/scallopBuilder.ts
@@ -8496,6 +8573,7 @@ export {
8496
8573
  marketCoins,
8497
8574
  queryKeys,
8498
8575
  sCoinIds,
8576
+ sCoinRawNameToName,
8499
8577
  sCoinTypeToName,
8500
8578
  sCoins,
8501
8579
  spoolRewardCoins,