@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.js CHANGED
@@ -80,6 +80,7 @@ __export(src_exports, {
80
80
  marketCoins: () => marketCoins,
81
81
  queryKeys: () => queryKeys,
82
82
  sCoinIds: () => sCoinIds,
83
+ sCoinRawNameToName: () => sCoinRawNameToName,
83
84
  sCoinTypeToName: () => sCoinTypeToName,
84
85
  sCoins: () => sCoins,
85
86
  spoolRewardCoins: () => spoolRewardCoins,
@@ -115,9 +116,10 @@ var COIN_GECKGO_IDS = {
115
116
  afsui: "sui",
116
117
  hasui: "sui",
117
118
  vsui: "sui",
118
- sca: "scallop-2",
119
- deep: "deepbook",
120
- fud: "fud-the-pug"
119
+ sca: "scallop-2"
120
+ // TODO: enable for production
121
+ // deep: 'deepbook',
122
+ // fud: 'fud-the-pug',
121
123
  };
122
124
 
123
125
  // src/constants/common.ts
@@ -146,9 +148,10 @@ var SUPPORT_POOLS = [
146
148
  "afsui",
147
149
  "hasui",
148
150
  "vsui",
149
- "sca",
150
- "fud",
151
- "deep"
151
+ "sca"
152
+ // TODO: enable for production
153
+ // 'fud',
154
+ // 'deep',
152
155
  ];
153
156
  var SUPPORT_COLLATERALS = [
154
157
  "usdc",
@@ -192,9 +195,10 @@ var SUPPORT_SCOIN = [
192
195
  "ssca",
193
196
  "scetus",
194
197
  "swsol",
195
- "swbtc",
196
- "sdeep",
197
- "sfud"
198
+ "swbtc"
199
+ // TODO: enable for production
200
+ // 'sdeep',
201
+ // 'sfud',
198
202
  ];
199
203
  var SUPPORT_SUI_BRIDGE = ["sbeth"];
200
204
  var SUPPORT_WORMHOLE = [
@@ -218,7 +222,10 @@ var SUPPORT_BORROW_INCENTIVE_POOLS = [
218
222
  "sca",
219
223
  "usdc"
220
224
  ];
221
- var SUPPORT_BORROW_INCENTIVE_REWARDS = ["sui", "sca"];
225
+ var SUPPORT_BORROW_INCENTIVE_REWARDS = [
226
+ ...SUPPORT_POOLS,
227
+ ...SUPPORT_SCOIN
228
+ ];
222
229
  var SUPPORT_ORACLES = ["supra", "switchboard", "pyth"];
223
230
  var SUPPORT_PACKAGES = [
224
231
  "coinDecimalsRegistry",
@@ -251,8 +258,9 @@ var coinDecimals = {
251
258
  hasui: 9,
252
259
  vsui: 9,
253
260
  sca: 9,
254
- deep: 6,
255
- fud: 5,
261
+ // TODO: enable for production
262
+ // deep: 6,
263
+ // fud: 5,
256
264
  susdc: 6,
257
265
  sweth: 8,
258
266
  ssbeth: 8,
@@ -266,9 +274,10 @@ var coinDecimals = {
266
274
  safsui: 9,
267
275
  shasui: 9,
268
276
  svsui: 9,
269
- ssca: 9,
270
- sdeep: 6,
271
- sfud: 5
277
+ ssca: 9
278
+ // TODO: enable for production
279
+ // sdeep: 6,
280
+ // sfud: 5,
272
281
  };
273
282
  var assetCoins = {
274
283
  usdc: "usdc",
@@ -284,9 +293,10 @@ var assetCoins = {
284
293
  afsui: "afsui",
285
294
  hasui: "hasui",
286
295
  vsui: "vsui",
287
- sca: "sca",
288
- deep: "deep",
289
- fud: "fud"
296
+ sca: "sca"
297
+ // TODO: enable for production
298
+ // deep: 'deep',
299
+ // fud: 'fud',
290
300
  };
291
301
  var marketCoins = {
292
302
  susdc: "susdc",
@@ -302,9 +312,10 @@ var marketCoins = {
302
312
  safsui: "safsui",
303
313
  shasui: "shasui",
304
314
  svsui: "svsui",
305
- ssca: "ssca",
306
- sdeep: "sdeep",
307
- sfud: "sfud"
315
+ ssca: "ssca"
316
+ // TODO: enable for production
317
+ // sdeep: 'sdeep',
318
+ // sfud: 'sfud',
308
319
  };
309
320
  var sCoins = {
310
321
  susdc: "susdc",
@@ -319,9 +330,10 @@ var sCoins = {
319
330
  svsui: "svsui",
320
331
  ssca: "ssca",
321
332
  swsol: "swsol",
322
- swbtc: "swbtc",
323
- sfud: "sfud",
324
- sdeep: "sdeep"
333
+ swbtc: "swbtc"
334
+ // TODO: enable for production
335
+ // sfud: 'sfud',
336
+ // sdeep: 'sdeep',
325
337
  };
326
338
  var stakeMarketCoins = {
327
339
  susdc: "susdc",
@@ -349,16 +361,16 @@ var suiBridgeCoins = {
349
361
  sbeth: "sbeth"
350
362
  };
351
363
  var borrowIncentiveRewardCoins = {
352
- usdc: ["sui", "sca"],
353
- sui: ["sui", "sca"],
354
- wusdc: ["sui", "sca"],
355
- wusdt: ["sui", "sca"],
356
- sca: ["sui", "sca"],
357
- afsui: ["sui"],
358
- hasui: ["sui"],
359
- vsui: ["sui"],
360
- weth: ["sui"],
361
- sbeth: ["sui"]
364
+ usdc: ["ssui", "ssca"],
365
+ sui: ["ssui", "ssca"],
366
+ wusdc: ["ssui", "ssca"],
367
+ wusdt: ["ssui", "ssca"],
368
+ sca: ["ssui", "ssca"],
369
+ afsui: ["ssui"],
370
+ hasui: ["ssui"],
371
+ vsui: ["ssui"],
372
+ weth: ["ssui"],
373
+ sbeth: ["ssui"]
362
374
  };
363
375
  var coinIds = {
364
376
  usdc: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7",
@@ -374,10 +386,10 @@ var coinIds = {
374
386
  afsui: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc",
375
387
  hasui: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d",
376
388
  vsui: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55",
377
- sca: IS_VE_SCA_TEST ? "0x6cd813061a3adf3602b76545f076205f0c8e7ec1d3b1eab9a1da7992c18c0524" : "0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6",
389
+ sca: IS_VE_SCA_TEST ? "0x6cd813061a3adf3602b76545f076205f0c8e7ec1d3b1eab9a1da7992c18c0524" : "0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6"
378
390
  // isolated assets
379
- deep: "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270",
380
- fud: "0x76cb819b01abed502bee8a702b4c2d547532c12f25001c9dea795a5e631c26f1"
391
+ // deep: '0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270',
392
+ // fud: '0x76cb819b01abed502bee8a702b4c2d547532c12f25001c9dea795a5e631c26f1',
381
393
  };
382
394
  var wormholeCoinIds = {
383
395
  weth: "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5",
@@ -393,19 +405,28 @@ var voloCoinIds = {
393
405
  var sCoinIds = {
394
406
  susdc: "0x854950aa624b1df59fe64e630b2ba7c550642e9342267a33061d59fb31582da5::scallop_usdc::SCALLOP_USDC",
395
407
  ssbeth: "0xb14f82d8506d139eacef109688d1b71e7236bcce9b2c0ad526abcd6aa5be7de0::scallop_sb_eth::SCALLOP_SB_ETH",
396
- ssui: "0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI",
408
+ // prod values
409
+ // ssui: '0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI',
410
+ // swusdc:
411
+ // '0xad4d71551d31092230db1fd482008ea42867dbf27b286e9c70a79d2a6191d58d::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC',
412
+ // swusdt:
413
+ // '0xe6e5a012ec20a49a3d1d57bd2b67140b96cd4d3400b9d79e541f7bdbab661f95::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT',
414
+ // ssca: '0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA',
415
+ // test values
416
+ ssui: "0xf569919046f19a0c40b519ecfbb6ca0319698cd5908716c29b62ef56541f298b::scallop_sui::SCALLOP_SUI",
417
+ swusdt: "0xac781d9f73058ff5e69f9bf8dde32f2e8c71c66d7fe8497fc83b2d9182254b22::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT",
418
+ swusdc: "0xf5447c4305a486d8c8557559887c2c39449ddb5e748f15d33946d02a1663c158::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC",
419
+ ssca: "0x958428555e778e55918a59eb1c92c77f32b5c554fa3a5e56cd0815086b5072e7::scallop_sca::SCALLOP_SCA",
397
420
  scetus: "0xea346ce428f91ab007210443efcea5f5cdbbb3aae7e9affc0ca93f9203c31f0c::scallop_cetus::SCALLOP_CETUS",
398
- ssca: "0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA",
399
- swusdc: "0xad4d71551d31092230db1fd482008ea42867dbf27b286e9c70a79d2a6191d58d::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC",
400
- swusdt: "0xe6e5a012ec20a49a3d1d57bd2b67140b96cd4d3400b9d79e541f7bdbab661f95::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT",
401
421
  sweth: "0x67540ceb850d418679e69f1fb6b2093d6df78a2a699ffc733f7646096d552e9b::scallop_wormhole_eth::SCALLOP_WORMHOLE_ETH",
402
422
  safsui: "0x00671b1fa2a124f5be8bdae8b91ee711462c5d9e31bda232e70fd9607b523c88::scallop_af_sui::SCALLOP_AF_SUI",
403
423
  shasui: "0x9a2376943f7d22f88087c259c5889925f332ca4347e669dc37d54c2bf651af3c::scallop_ha_sui::SCALLOP_HA_SUI",
404
424
  svsui: "0xe1a1cc6bcf0001a015eab84bcc6713393ce20535f55b8b6f35c142e057a25fbe::scallop_v_sui::SCALLOP_V_SUI",
405
425
  swsol: "0x1392650f2eca9e3f6ffae3ff89e42a3590d7102b80e2b430f674730bc30d3259::scallop_wormhole_sol::SCALLOP_WORMHOLE_SOL",
406
- swbtc: "0x2cf76a9cf5d3337961d1154283234f94da2dcff18544dfe5cbdef65f319591b5::scallop_wormhole_btc::SCALLOP_WORMHOLE_BTC",
407
- sdeep: "0xeb7a05a3224837c5e5503575aed0be73c091d1ce5e43aa3c3e716e0ae614608f::scallop_deep::SCALLOP_DEEP",
408
- sfud: "0xe56d5167f427cbe597da9e8150ef5c337839aaf46891d62468dcf80bdd8e10d1::scallop_fud::SCALLOP_FUD"
426
+ swbtc: "0x2cf76a9cf5d3337961d1154283234f94da2dcff18544dfe5cbdef65f319591b5::scallop_wormhole_btc::SCALLOP_WORMHOLE_BTC"
427
+ // sdeep:
428
+ // '0xeb7a05a3224837c5e5503575aed0be73c091d1ce5e43aa3c3e716e0ae614608f::scallop_deep::SCALLOP_DEEP',
429
+ // sfud: '0xe56d5167f427cbe597da9e8150ef5c337839aaf46891d62468dcf80bdd8e10d1::scallop_fud::SCALLOP_FUD',
409
430
  };
410
431
  var sCoinTypeToName = Object.entries(sCoinIds).reduce(
411
432
  (acc, [coinName, coinType]) => {
@@ -414,6 +435,13 @@ var sCoinTypeToName = Object.entries(sCoinIds).reduce(
414
435
  },
415
436
  {}
416
437
  );
438
+ var sCoinRawNameToName = Object.entries(sCoinIds).reduce(
439
+ (acc, [coinName, coinType]) => {
440
+ acc[coinType.split("::")[2].toLowerCase()] = coinName;
441
+ return acc;
442
+ },
443
+ {}
444
+ );
417
445
 
418
446
  // src/constants/flashloan.ts
419
447
  var FlashLoanFeeObjectMap = {
@@ -488,13 +516,16 @@ var POOL_ADDRESSES = {
488
516
  sca: {
489
517
  lendingPoolAddress: "0x6fc7d4211fc7018b6c75e7b908b88f2e0536443239804a3d32af547637bd28d7",
490
518
  collateralPoolAddress: "0xff677a5d9e9dc8f08f0a8681ebfc7481d1c7d57bc441f2881974adcdd7b13c31"
491
- },
492
- fud: {
493
- lendingPoolAddress: ""
494
- },
495
- deep: {
496
- lendingPoolAddress: ""
497
519
  }
520
+ // TODO: enable for production
521
+ // fud: {
522
+ // lendingPoolAddress:
523
+ // '0x14367ddca30e2860cb89ed4eaca20c7ece260c5d59dd9990d2c85a8321326acb',
524
+ // },
525
+ // deep: {
526
+ // lendingPoolAddress:
527
+ // '0xf4a67ffb43da1e1c61c049f188f19463ea8dbbf2d5ef4722d6df854ff1b1cc03',
528
+ // },
498
529
  };
499
530
 
500
531
  // src/constants/pyth.ts
@@ -516,9 +547,10 @@ var PYTH_FEED_IDS = {
516
547
  afsui: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
517
548
  hasui: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
518
549
  vsui: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
519
- sca: "7e17f0ac105abe9214deb9944c30264f5986bf292869c6bd8e8da3ccd92d79bc",
520
- deep: "29bdd5248234e33bd93d3b81100b5fa32eaa5997843847e2c2cb16d7c6d9f7ff",
521
- fud: "6a4090703da959247727f2b490eb21aea95c8684ecfac675f432008830890c75"
550
+ sca: "7e17f0ac105abe9214deb9944c30264f5986bf292869c6bd8e8da3ccd92d79bc"
551
+ // TODO: enable for production
552
+ // deep: '29bdd5248234e33bd93d3b81100b5fa32eaa5997843847e2c2cb16d7c6d9f7ff',
553
+ // fud: '6a4090703da959247727f2b490eb21aea95c8684ecfac675f432008830890c75',
522
554
  };
523
555
 
524
556
  // src/constants/queryKeys.ts
@@ -1043,7 +1075,7 @@ var TEST_ADDRESSES = {
1043
1075
  };
1044
1076
 
1045
1077
  // src/constants/tokenBucket.ts
1046
- var DEFAULT_TOKENS_PER_INTERVAL = 10;
1078
+ var DEFAULT_TOKENS_PER_INTERVAL = 50;
1047
1079
  var DEFAULT_INTERVAL_IN_MS = 300;
1048
1080
 
1049
1081
  // src/constants/vesca.ts
@@ -2555,15 +2587,21 @@ var queryBorrowIncentivePools = async (address) => {
2555
2587
  };
2556
2588
  var getBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
2557
2589
  ...SUPPORT_BORROW_INCENTIVE_POOLS
2558
- ], indexer = false, coinPrices) => {
2590
+ ], indexer = false, marketPools, coinPrices) => {
2559
2591
  const borrowIncentivePools = {};
2560
- coinPrices = coinPrices ?? await query.utils.getCoinPrices() ?? {};
2592
+ marketPools = marketPools ?? await query.getMarketPools(void 0, false, { coinPrices });
2593
+ coinPrices = coinPrices ?? await query.getAllCoinPrices({ marketPools });
2561
2594
  if (indexer) {
2562
2595
  const borrowIncentivePoolsIndexer = await query.indexer.getBorrowIncentivePools();
2563
2596
  const updateBorrowIncentivePool = (pool) => {
2564
2597
  if (!borrowIncentiveCoinNames.includes(pool.coinName))
2565
2598
  return;
2566
- pool.coinPrice = coinPrices[pool.coinName] ?? pool.coinPrice;
2599
+ pool.coinPrice = coinPrices[pool.coinName] || pool.coinPrice;
2600
+ for (const sCoinName of SUPPORT_BORROW_INCENTIVE_REWARDS) {
2601
+ if (pool.points[sCoinName]) {
2602
+ pool.points[sCoinName].coinPrice = coinPrices[sCoinName] ?? pool.points[sCoinName].coinPrice;
2603
+ }
2604
+ }
2567
2605
  borrowIncentivePools[pool.coinName] = pool;
2568
2606
  };
2569
2607
  Object.values(borrowIncentivePoolsIndexer).forEach(
@@ -2589,12 +2627,15 @@ var getBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
2589
2627
  for (const [coinName, poolPoint] of Object.entries(
2590
2628
  parsedBorrowIncentivePoolData.poolPoints
2591
2629
  )) {
2592
- const rewardCoinType = (0, import_utils3.normalizeStructTag)(poolPoint.pointType);
2593
- const rewardCoinName = query.utils.parseCoinNameFromType(
2630
+ const rewardCoinType = poolPoint.pointType;
2631
+ let rewardCoinName = query.utils.parseCoinNameFromType(
2594
2632
  rewardCoinType
2595
2633
  );
2596
- const rewardCoinPrice = coinPrices?.[rewardCoinName] ?? 0;
2634
+ if (sCoinRawNameToName[rewardCoinName]) {
2635
+ rewardCoinName = sCoinRawNameToName[rewardCoinName];
2636
+ }
2597
2637
  const rewardCoinDecimal = query.utils.getCoinDecimal(rewardCoinName);
2638
+ const rewardCoinPrice = coinPrices?.[rewardCoinName] ?? 0;
2598
2639
  const symbol = query.utils.parseSymbol(rewardCoinName);
2599
2640
  const coinDecimal = query.utils.getCoinDecimal(rewardCoinName);
2600
2641
  const calculatedPoolPoint = calculateBorrowIncentivePoolPointData(
@@ -2740,7 +2781,7 @@ var supplyLimitZod = import_zod.z.object({
2740
2781
  value: import_zod.z.string()
2741
2782
  })
2742
2783
  });
2743
- var supplyLimitKeyType = `0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e::market_dynamic_keys::SupplyLimitKey`;
2784
+ var supplyLimitKeyType = `0x6c23585e940a989588432509107e98bae06dbca4e333f26d0635d401b3c7c76d::market_dynamic_keys::SupplyLimitKey`;
2744
2785
  var getSupplyLimit = async (utils, poolName) => {
2745
2786
  try {
2746
2787
  const poolCoinType = utils.parseCoinType(poolName).slice(2);
@@ -2780,7 +2821,7 @@ var isolatedAssetZod = import_zod2.z.object({
2780
2821
  value: import_zod2.z.boolean()
2781
2822
  })
2782
2823
  });
2783
- var isolatedAssetKeyType = `0xe7dbb371a9595631f7964b7ece42255ad0e738cc85fe6da26c7221b220f01af6::market_dynamic_keys::IsolatedAssetKey`;
2824
+ var isolatedAssetKeyType = `0x6c23585e940a989588432509107e98bae06dbca4e333f26d0635d401b3c7c76d::market_dynamic_keys::IsolatedAssetKey`;
2784
2825
  var getIsolatedAssets = async (address) => {
2785
2826
  try {
2786
2827
  const marketObject = address.get("core.market");
@@ -2860,7 +2901,7 @@ var borrowLimitZod = import_zod3.z.object({
2860
2901
  value: import_zod3.z.string()
2861
2902
  })
2862
2903
  });
2863
- var borrowLimitKeyType = `0xe7dbb371a9595631f7964b7ece42255ad0e738cc85fe6da26c7221b220f01af6::market_dynamic_keys::BorrowLimitKey`;
2904
+ var borrowLimitKeyType = `0xb784ea287d944e478a3ceaa071f8885072cce6b7224cf245914dc2f9963f460e::market_dynamic_keys::BorrowLimitKey`;
2864
2905
  var getBorrowLimit = async (utils, poolName) => {
2865
2906
  try {
2866
2907
  const poolCoinType = utils.parseCoinType(poolName).slice(2);
@@ -3027,7 +3068,7 @@ var getMarketPools = async (query, poolCoinNames = [...SUPPORT_POOLS], indexer =
3027
3068
  const marketObjectResponse = await query.cache.queryGetObject(marketId, {
3028
3069
  showContent: true
3029
3070
  });
3030
- coinPrices = await query.utils.getCoinPrices(poolCoinNames) ?? {};
3071
+ coinPrices = coinPrices ?? await query.utils.getCoinPrices();
3031
3072
  const marketPools = {};
3032
3073
  if (indexer) {
3033
3074
  const marketPoolsIndexer = await query.indexer.getMarketPools();
@@ -3061,7 +3102,7 @@ var getMarketPools = async (query, poolCoinNames = [...SUPPORT_POOLS], indexer =
3061
3102
  };
3062
3103
  var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, coinPrice) => {
3063
3104
  try {
3064
- coinPrice = coinPrice || (await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName];
3105
+ coinPrice = coinPrice ?? (await query.utils.getCoinPrices())?.[poolCoinName];
3065
3106
  if (indexer) {
3066
3107
  const marketPoolIndexer = await query.indexer.getMarketPool(poolCoinName);
3067
3108
  if (!marketPoolIndexer) {
@@ -3207,7 +3248,7 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
3207
3248
  };
3208
3249
  var getMarketCollaterals = async (query, collateralCoinNames = [...SUPPORT_COLLATERALS], indexer = false) => {
3209
3250
  const marketId = query.address.get("core.market");
3210
- const coinPrices = await query.utils.getCoinPrices(collateralCoinNames) ?? {};
3251
+ const coinPrices = await query.utils.getCoinPrices() ?? {};
3211
3252
  const marketCollaterals = {};
3212
3253
  if (indexer) {
3213
3254
  const marketCollateralsIndexer = await query.indexer.getMarketCollaterals();
@@ -3243,7 +3284,7 @@ var getMarketCollaterals = async (query, collateralCoinNames = [...SUPPORT_COLLA
3243
3284
  return marketCollaterals;
3244
3285
  };
3245
3286
  var getMarketCollateral = async (query, collateralCoinName, indexer = false, marketObject, coinPrice) => {
3246
- coinPrice = coinPrice || (await query.utils.getCoinPrices([collateralCoinName]))?.[collateralCoinName];
3287
+ coinPrice = coinPrice ?? (await query.utils.getCoinPrices())?.[collateralCoinName];
3247
3288
  if (indexer) {
3248
3289
  const marketCollateralIndexer = await query.indexer.getMarketCollateral(collateralCoinName);
3249
3290
  marketCollateralIndexer.coinPrice = coinPrice ?? marketCollateralIndexer.coinPrice;
@@ -3559,7 +3600,7 @@ var getLendings = async (query, poolCoinNames = [...SUPPORT_POOLS], ownerAddress
3559
3600
  const stakeMarketCoinNames = marketCoinNames.filter(
3560
3601
  (marketCoinName) => SUPPORT_SPOOLS.includes(marketCoinName)
3561
3602
  );
3562
- const coinPrices = await query.utils.getCoinPrices(poolCoinNames);
3603
+ const coinPrices = await query.utils.getCoinPrices();
3563
3604
  const marketPools = await query.getMarketPools(poolCoinNames, indexer, {
3564
3605
  coinPrices
3565
3606
  });
@@ -3597,7 +3638,7 @@ var getLendings = async (query, poolCoinNames = [...SUPPORT_POOLS], ownerAddress
3597
3638
  };
3598
3639
  var getLending = async (query, poolCoinName, ownerAddress, indexer = false, marketPool, spool, stakeAccounts, coinAmount, marketCoinAmount, coinPrice, sCoinAmount) => {
3599
3640
  const marketCoinName = query.utils.parseMarketCoinName(poolCoinName);
3600
- coinPrice = coinPrice ?? (await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName] ?? 0;
3641
+ coinPrice = coinPrice ?? (await query.utils.getCoinPrices())?.[poolCoinName] ?? 0;
3601
3642
  marketPool = marketPool ?? await query.getMarketPool(poolCoinName, indexer, {
3602
3643
  coinPrice
3603
3644
  });
@@ -3757,8 +3798,8 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
3757
3798
  const collateralAssetCoinNames = [
3758
3799
  ...SUPPORT_COLLATERALS
3759
3800
  ];
3760
- coinPrices = coinPrices ?? await query.utils.getCoinPrices(collateralAssetCoinNames);
3761
- market = market ?? await query.queryMarket(indexer, { coinPrices });
3801
+ market = market ?? await query.queryMarket(indexer);
3802
+ coinPrices = coinPrices ?? await query.getAllCoinPrices({ marketPools: market.pools });
3762
3803
  coinAmounts = coinAmounts || await query.getCoinAmounts(collateralAssetCoinNames, ownerAddress);
3763
3804
  const [obligationQuery, borrowIncentivePools, borrowIncentiveAccounts] = await Promise.all([
3764
3805
  query.queryObligation(obligationId),
@@ -3899,44 +3940,47 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
3899
3940
  const borrowIncentivePool = borrowIncentivePools[coinName];
3900
3941
  if (borrowIncentivePool) {
3901
3942
  const rewards = [];
3902
- for (const rewardCoinName of SUPPORT_BORROW_INCENTIVE_REWARDS) {
3903
- const accountPoint = borrowIncentiveAccount.pointList[rewardCoinName];
3904
- const poolPoint = borrowIncentivePool.points[rewardCoinName];
3905
- if (accountPoint && poolPoint) {
3906
- let availableClaimAmount = (0, import_bignumber5.default)(0);
3907
- let availableClaimCoin = (0, import_bignumber5.default)(0);
3908
- const accountBorrowedAmount = (0, import_bignumber5.default)(accountPoint.weightedAmount);
3909
- const baseIndexRate = 1e9;
3910
- const increasedPointRate = poolPoint.currentPointIndex ? Math.max(
3911
- (0, import_bignumber5.default)(poolPoint.currentPointIndex - accountPoint.index).dividedBy(baseIndexRate).toNumber(),
3912
- 0
3913
- ) : 1;
3914
- availableClaimAmount = availableClaimAmount.plus(
3915
- accountBorrowedAmount.multipliedBy(increasedPointRate).plus(accountPoint.points)
3916
- );
3917
- availableClaimCoin = availableClaimAmount.shiftedBy(
3918
- -1 * poolPoint.coinDecimal
3919
- );
3920
- const weightScale = (0, import_bignumber5.default)(1e12);
3921
- const boostValue = (0, import_bignumber5.default)(accountPoint.weightedAmount).div(
3922
- (0, import_bignumber5.default)(borrowIncentiveAccount.debtAmount).multipliedBy(poolPoint.baseWeight).dividedBy(weightScale)
3923
- ).isFinite() ? (0, import_bignumber5.default)(accountPoint.weightedAmount).div(
3924
- (0, import_bignumber5.default)(borrowIncentiveAccount.debtAmount).multipliedBy(poolPoint.baseWeight).dividedBy(weightScale)
3925
- ).toNumber() : 1;
3926
- if (availableClaimAmount.isGreaterThanOrEqualTo(0)) {
3927
- rewards.push({
3928
- coinName: poolPoint.coinName,
3929
- coinType: poolPoint.coinType,
3930
- symbol: poolPoint.symbol,
3931
- coinDecimal: poolPoint.coinDecimal,
3932
- coinPrice: poolPoint.coinPrice,
3933
- availableClaimAmount: availableClaimAmount.toNumber(),
3934
- availableClaimCoin: availableClaimCoin.toNumber(),
3935
- boostValue
3936
- });
3943
+ Object.entries(borrowIncentiveAccount.pointList).forEach(
3944
+ ([key, accountPoint]) => {
3945
+ const poolPoint = borrowIncentivePool.points[key];
3946
+ if (accountPoint && poolPoint) {
3947
+ let availableClaimAmount = (0, import_bignumber5.default)(0);
3948
+ let availableClaimCoin = (0, import_bignumber5.default)(0);
3949
+ const accountBorrowedAmount = (0, import_bignumber5.default)(
3950
+ accountPoint.weightedAmount
3951
+ );
3952
+ const baseIndexRate = 1e9;
3953
+ const increasedPointRate = poolPoint.currentPointIndex ? Math.max(
3954
+ (0, import_bignumber5.default)(poolPoint.currentPointIndex - accountPoint.index).dividedBy(baseIndexRate).toNumber(),
3955
+ 0
3956
+ ) : 1;
3957
+ availableClaimAmount = availableClaimAmount.plus(
3958
+ accountBorrowedAmount.multipliedBy(increasedPointRate).plus(accountPoint.points)
3959
+ );
3960
+ availableClaimCoin = availableClaimAmount.shiftedBy(
3961
+ -1 * poolPoint.coinDecimal
3962
+ );
3963
+ const weightScale = (0, import_bignumber5.default)(1e12);
3964
+ const boostValue = (0, import_bignumber5.default)(accountPoint.weightedAmount).div(
3965
+ (0, import_bignumber5.default)(borrowIncentiveAccount.debtAmount).multipliedBy(poolPoint.baseWeight).dividedBy(weightScale)
3966
+ ).isFinite() ? (0, import_bignumber5.default)(accountPoint.weightedAmount).div(
3967
+ (0, import_bignumber5.default)(borrowIncentiveAccount.debtAmount).multipliedBy(poolPoint.baseWeight).dividedBy(weightScale)
3968
+ ).toNumber() : 1;
3969
+ if (availableClaimAmount.isGreaterThanOrEqualTo(0)) {
3970
+ rewards.push({
3971
+ coinName: poolPoint.coinName,
3972
+ coinType: poolPoint.coinType,
3973
+ symbol: poolPoint.symbol,
3974
+ coinDecimal: poolPoint.coinDecimal,
3975
+ coinPrice: poolPoint.coinPrice,
3976
+ availableClaimAmount: availableClaimAmount.toNumber(),
3977
+ availableClaimCoin: availableClaimCoin.toNumber(),
3978
+ boostValue
3979
+ });
3980
+ }
3937
3981
  }
3938
3982
  }
3939
- }
3983
+ );
3940
3984
  if (Object.keys(borrowIncentivePool.points).some((coinName2) => {
3941
3985
  const rewardApr = borrowIncentivePool.points[coinName2]?.rewardApr;
3942
3986
  return rewardApr !== Infinity && typeof rewardApr == "number" && rewardApr > 0;
@@ -4080,6 +4124,7 @@ var getTotalValueLocked = async (query, indexer = false) => {
4080
4124
  };
4081
4125
 
4082
4126
  // src/queries/priceQuery.ts
4127
+ var import_bignumber6 = __toESM(require("bignumber.js"));
4083
4128
  var getPythPrice = async ({
4084
4129
  address
4085
4130
  }, assetCoinName, priceFeedObject) => {
@@ -4161,6 +4206,22 @@ var getPythPrices = async ({
4161
4206
  {}
4162
4207
  );
4163
4208
  };
4209
+ var getAllCoinPrices = async (query, marketPools, coinPrices) => {
4210
+ coinPrices = coinPrices ?? await query.utils.getCoinPrices();
4211
+ marketPools = marketPools ?? await query.getMarketPools(void 0, void 0, { coinPrices });
4212
+ if (!marketPools) {
4213
+ throw new Error(`Failed to fetch market pool for getAllCoinPrices`);
4214
+ }
4215
+ const sCoinPrices = {};
4216
+ SUPPORT_SCOIN.forEach((sCoinName) => {
4217
+ const coinName = query.utils.parseCoinName(sCoinName);
4218
+ sCoinPrices[sCoinName] = (0, import_bignumber6.default)(coinPrices[coinName] ?? 0).multipliedBy(marketPools[coinName]?.conversionRate ?? 1).toNumber();
4219
+ });
4220
+ return {
4221
+ ...coinPrices,
4222
+ ...sCoinPrices
4223
+ };
4224
+ };
4164
4225
 
4165
4226
  // src/queries/referralQuery.ts
4166
4227
  var queryVeScaKeyIdFromReferralBindings = async (address, refereeAddress) => {
@@ -4181,7 +4242,7 @@ var queryVeScaKeyIdFromReferralBindings = async (address, refereeAddress) => {
4181
4242
  // src/queries/sCoinQuery.ts
4182
4243
  var import_bcs = require("@mysten/sui/bcs");
4183
4244
  var import_assert = __toESM(require("assert"));
4184
- var import_bignumber6 = __toESM(require("bignumber.js"));
4245
+ var import_bignumber7 = __toESM(require("bignumber.js"));
4185
4246
  var getSCoinTotalSupply = async ({
4186
4247
  utils
4187
4248
  }, sCoinName) => {
@@ -4202,7 +4263,7 @@ var getSCoinTotalSupply = async ({
4202
4263
  const value = Uint8Array.from(results[0].returnValues[0][0]);
4203
4264
  const type = results[0].returnValues[0][1];
4204
4265
  (0, import_assert.default)(type === "u64", "Result type is not u64");
4205
- return (0, import_bignumber6.default)(import_bcs.bcs.u64().parse(value)).shiftedBy(utils.getCoinDecimal(utils.parseCoinName(sCoinName))).toNumber();
4266
+ return (0, import_bignumber7.default)(import_bcs.bcs.u64().parse(value)).shiftedBy(utils.getCoinDecimal(utils.parseCoinName(sCoinName))).toNumber();
4206
4267
  }
4207
4268
  return 0;
4208
4269
  };
@@ -4228,7 +4289,7 @@ var getSCoinAmount = async ({
4228
4289
  owner,
4229
4290
  coinType: sCoinType
4230
4291
  });
4231
- return (0, import_bignumber6.default)(amount).toNumber();
4292
+ return (0, import_bignumber7.default)(amount).toNumber();
4232
4293
  };
4233
4294
  var isSupportStakeCoins = (value) => {
4234
4295
  return SUPPORT_SCOIN.includes(value);
@@ -4258,7 +4319,7 @@ var getSCoinSwapRate = async (query, fromSCoin, toSCoin, underlyingCoinPrice) =>
4258
4319
  const ScoinAToARate = marketPools[0].conversionRate;
4259
4320
  const BtoSCoinBRate = 1 / marketPools[1].conversionRate;
4260
4321
  const calcAtoBRate = async () => {
4261
- const prices = await query.utils.getCoinPrices([fromCoinName, toCoinName]);
4322
+ const prices = await query.utils.getCoinPrices();
4262
4323
  if (!prices[fromCoinName] || !prices[toCoinName]) {
4263
4324
  throw new Error("Failed to fetch the coin prices");
4264
4325
  }
@@ -4268,7 +4329,7 @@ var getSCoinSwapRate = async (query, fromSCoin, toSCoin, underlyingCoinPrice) =>
4268
4329
  return prices[fromCoinName] / prices[toCoinName];
4269
4330
  };
4270
4331
  const AtoBRate = underlyingCoinPrice ?? await calcAtoBRate();
4271
- return (0, import_bignumber6.default)(ScoinAToARate).multipliedBy(AtoBRate).multipliedBy(BtoSCoinBRate).toNumber();
4332
+ return (0, import_bignumber7.default)(ScoinAToARate).multipliedBy(AtoBRate).multipliedBy(BtoSCoinBRate).toNumber();
4272
4333
  };
4273
4334
 
4274
4335
  // src/queries/spoolQuery.ts
@@ -4328,7 +4389,7 @@ var getSpool = async (query, marketCoinName, indexer = false, marketPool, coinPr
4328
4389
  `spool.pools.${marketCoinName}.rewardPoolId`
4329
4390
  );
4330
4391
  let spool = void 0;
4331
- coinPrices = coinPrices || await query.utils.getCoinPrices([coinName]);
4392
+ coinPrices = coinPrices || await query.utils.getCoinPrices();
4332
4393
  if (indexer) {
4333
4394
  const spoolIndexer = await query.indexer.getSpool(marketCoinName);
4334
4395
  const coinName2 = query.utils.parseCoinName(marketCoinName);
@@ -4348,7 +4409,7 @@ var getSpool = async (query, marketCoinName, indexer = false, marketPool, coinPr
4348
4409
  throw new Error("Fail to fetch spoolObjectResponse!");
4349
4410
  }
4350
4411
  const rewardCoinName = query.utils.getSpoolRewardCoinName(marketCoinName);
4351
- coinPrices = coinPrices || await query.utils.getCoinPrices([coinName, rewardCoinName]);
4412
+ coinPrices = coinPrices || await query.utils.getCoinPrices();
4352
4413
  const spoolObject = spoolObjectResponse[0];
4353
4414
  const rewardPoolObject = spoolObjectResponse[1];
4354
4415
  if (spoolObject.content && "fields" in spoolObject.content) {
@@ -4592,7 +4653,7 @@ var getStakeRewardPool = async ({
4592
4653
  };
4593
4654
 
4594
4655
  // src/queries/vescaQuery.ts
4595
- var import_bignumber7 = __toESM(require("bignumber.js"));
4656
+ var import_bignumber8 = __toESM(require("bignumber.js"));
4596
4657
  var import_sui_kit3 = require("@scallop-io/sui-kit");
4597
4658
  var import_bcs2 = require("@mysten/sui/bcs");
4598
4659
  var import_zod5 = require("zod");
@@ -4674,7 +4735,7 @@ var getVeSca = async (utils, veScaKey) => {
4674
4735
  0
4675
4736
  );
4676
4737
  const lockedScaAmount = String(dynamicFields.locked_sca_amount);
4677
- const lockedScaCoin = (0, import_bignumber7.default)(dynamicFields.locked_sca_amount).shiftedBy(-9).toNumber();
4738
+ const lockedScaCoin = (0, import_bignumber8.default)(dynamicFields.locked_sca_amount).shiftedBy(-9).toNumber();
4678
4739
  const currentVeScaBalance = lockedScaCoin * (Math.floor(remainingLockPeriodInMilliseconds / 1e3) / MAX_LOCK_DURATION);
4679
4740
  vesca = {
4680
4741
  id: veScaDynamicFieldObject.objectId,
@@ -4684,7 +4745,7 @@ var getVeSca = async (utils, veScaKey) => {
4684
4745
  lockedScaAmount,
4685
4746
  lockedScaCoin,
4686
4747
  currentVeScaBalance,
4687
- unlockAt: (0, import_bignumber7.default)(dynamicFields.unlock_at * 1e3).toNumber()
4748
+ unlockAt: (0, import_bignumber8.default)(dynamicFields.unlock_at * 1e3).toNumber()
4688
4749
  };
4689
4750
  }
4690
4751
  return vesca;
@@ -4746,10 +4807,10 @@ var getVeScaTreasuryInfo = async (utils) => {
4746
4807
  if (!veScaTreasury || veScaTreasury.data?.content?.dataType !== "moveObject")
4747
4808
  return null;
4748
4809
  const treasuryFields = veScaTreasury.data.content.fields;
4749
- const totalLockedSca = (0, import_bignumber7.default)(
4810
+ const totalLockedSca = (0, import_bignumber8.default)(
4750
4811
  treasuryFields.unlock_schedule.fields.locked_sca_amount
4751
4812
  ).shiftedBy(-9).toNumber();
4752
- const totalVeSca = (0, import_bignumber7.default)(
4813
+ const totalVeSca = (0, import_bignumber8.default)(
4753
4814
  await getTotalVeScaTreasuryAmount(utils, veScaTreasury.data) ?? 0
4754
4815
  ).shiftedBy(-9).toNumber();
4755
4816
  const averageLockingPeriod = totalLockedSca > 0 ? totalVeSca / totalLockedSca * 4 : 0;
@@ -4918,6 +4979,15 @@ var ScallopUtils = class {
4918
4979
  return void 0;
4919
4980
  }
4920
4981
  }
4982
+ /**
4983
+ * Convert sCoin name to coin name.
4984
+ * This function will parse new sCoin name `scallop_...` to its old market coin name which is shorter
4985
+ * e.g: `scallop_sui -> ssui
4986
+ * @return sCoin name
4987
+ */
4988
+ parseCoinNameFromSCoinName(coinName) {
4989
+ return sCoinRawNameToName[coinName];
4990
+ }
4921
4991
  /**
4922
4992
  * Convert sCoin name into sCoin type
4923
4993
  * @param sCoinName
@@ -4969,7 +5039,7 @@ var ScallopUtils = class {
4969
5039
  const coinTypeMatch = coinType.match(coinTypeRegex);
4970
5040
  const isMarketCoinType = coinType.includes("reserve::MarketCoin");
4971
5041
  coinType = coinTypeMatch?.[1] ?? coinType;
4972
- const wormHoleCoinTypeMap = {
5042
+ const wormholeCoinTypeMap = {
4973
5043
  [`${this.address.get("core.coins.wusdc.id") ?? wormholeCoinIds.wusdc}::coin::COIN`]: "wusdc",
4974
5044
  [`${this.address.get("core.coins.wusdt.id") ?? wormholeCoinIds.wusdt}::coin::COIN`]: "wusdt",
4975
5045
  [`${this.address.get("core.coins.weth.id") ?? wormholeCoinIds.weth}::coin::COIN`]: "weth",
@@ -4989,7 +5059,7 @@ var ScallopUtils = class {
4989
5059
  },
4990
5060
  {}
4991
5061
  );
4992
- const assetCoinName = wormHoleCoinTypeMap[coinType] || voloCoinTypeMap[coinType] || suiBridgeTypeMap[coinType] || coinType.split("::")[2].toLowerCase();
5062
+ const assetCoinName = wormholeCoinTypeMap[coinType] || voloCoinTypeMap[coinType] || suiBridgeTypeMap[coinType] || coinType.split("::")[2].toLowerCase();
4993
5063
  return isMarketCoinType ? this.parseMarketCoinName(assetCoinName) : assetCoinName;
4994
5064
  }
4995
5065
  /**
@@ -7372,6 +7442,7 @@ var ScallopQuery = class {
7372
7442
  this,
7373
7443
  coinNames,
7374
7444
  indexer,
7445
+ args?.marketPools,
7375
7446
  args?.coinPrices
7376
7447
  );
7377
7448
  }
@@ -7587,6 +7658,13 @@ var ScallopQuery = class {
7587
7658
  async getCoinPriceByIndexer(poolName) {
7588
7659
  return this.indexer.getCoinPrice(poolName);
7589
7660
  }
7661
+ /**
7662
+ * Get all coin prices, including sCoin
7663
+ * @returns prices data
7664
+ */
7665
+ async getAllCoinPrices(args) {
7666
+ return getAllCoinPrices(this, args?.marketPools, args?.coinPrices);
7667
+ }
7590
7668
  };
7591
7669
 
7592
7670
  // src/models/scallopBuilder.ts
@@ -8575,6 +8653,7 @@ var Scallop = class {
8575
8653
  marketCoins,
8576
8654
  queryKeys,
8577
8655
  sCoinIds,
8656
+ sCoinRawNameToName,
8578
8657
  sCoinTypeToName,
8579
8658
  sCoins,
8580
8659
  spoolRewardCoins,