@scallop-io/sui-scallop-sdk 1.4.0 → 1.4.1-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/constants/common.d.ts +3 -3
  2. package/dist/constants/enum.d.ts +2 -2
  3. package/dist/index.js +220 -150
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +219 -149
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/models/scallopClient.d.ts +4 -4
  8. package/dist/models/scallopQuery.d.ts +40 -6
  9. package/dist/models/scallopUtils.d.ts +11 -11
  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/test.d.ts +0 -0
  16. package/dist/types/builder/borrowIncentive.d.ts +6 -6
  17. package/dist/types/constant/common.d.ts +1 -1
  18. package/dist/types/utils.d.ts +2 -6
  19. package/package.json +1 -1
  20. package/src/builders/borrowIncentiveBuilder.ts +2 -13
  21. package/src/constants/coinGecko.ts +3 -2
  22. package/src/constants/common.ts +10 -5
  23. package/src/constants/enum.ts +44 -34
  24. package/src/constants/poolAddress.ts +9 -8
  25. package/src/constants/pyth.ts +3 -2
  26. package/src/models/scallopClient.ts +27 -10
  27. package/src/models/scallopQuery.ts +18 -1
  28. package/src/models/scallopUtils.ts +23 -18
  29. package/src/queries/borrowIncentiveQuery.ts +29 -12
  30. package/src/queries/borrowLimitQuery.ts +3 -2
  31. package/src/queries/coreQuery.ts +4 -10
  32. package/src/queries/isolatedAssetQuery.ts +3 -2
  33. package/src/queries/portfolioQuery.ts +65 -62
  34. package/src/queries/priceQuery.ts +35 -2
  35. package/src/queries/sCoinQuery.ts +1 -1
  36. package/src/queries/spoolQuery.ts +2 -4
  37. package/src/queries/supplyLimitQuery.ts +3 -2
  38. package/src/test.ts +20 -0
  39. package/src/types/builder/borrowIncentive.ts +10 -15
  40. package/src/types/constant/common.ts +1 -2
  41. package/src/types/utils.ts +2 -10
  42. package/src/utils/query.ts +0 -87
package/dist/index.js CHANGED
@@ -74,12 +74,12 @@ __export(src_exports, {
74
74
  UNLOCK_ROUND_DURATION: () => UNLOCK_ROUND_DURATION,
75
75
  USE_TEST_ADDRESS: () => USE_TEST_ADDRESS,
76
76
  assetCoins: () => assetCoins,
77
- borrowIncentiveRewardCoins: () => borrowIncentiveRewardCoins,
78
77
  coinDecimals: () => coinDecimals,
79
78
  coinIds: () => coinIds,
80
79
  marketCoins: () => marketCoins,
81
80
  queryKeys: () => queryKeys,
82
81
  sCoinIds: () => sCoinIds,
82
+ sCoinRawNameToName: () => sCoinRawNameToName,
83
83
  sCoinTypeToName: () => sCoinTypeToName,
84
84
  sCoins: () => sCoins,
85
85
  spoolRewardCoins: () => spoolRewardCoins,
@@ -115,9 +115,10 @@ var COIN_GECKGO_IDS = {
115
115
  afsui: "sui",
116
116
  hasui: "sui",
117
117
  vsui: "sui",
118
- sca: "scallop-2",
119
- deep: "deepbook",
120
- fud: "fud-the-pug"
118
+ sca: "scallop-2"
119
+ // TODO: enable for production
120
+ // deep: 'deepbook',
121
+ // fud: 'fud-the-pug',
121
122
  };
122
123
 
123
124
  // src/constants/common.ts
@@ -146,9 +147,10 @@ var SUPPORT_POOLS = [
146
147
  "afsui",
147
148
  "hasui",
148
149
  "vsui",
149
- "sca",
150
- "fud",
151
- "deep"
150
+ "sca"
151
+ // TODO: enable for production
152
+ // 'fud',
153
+ // 'deep',
152
154
  ];
153
155
  var SUPPORT_COLLATERALS = [
154
156
  "usdc",
@@ -192,9 +194,10 @@ var SUPPORT_SCOIN = [
192
194
  "ssca",
193
195
  "scetus",
194
196
  "swsol",
195
- "swbtc",
196
- "sdeep",
197
- "sfud"
197
+ "swbtc"
198
+ // TODO: enable for production
199
+ // 'sdeep',
200
+ // 'sfud',
198
201
  ];
199
202
  var SUPPORT_SUI_BRIDGE = ["sbeth"];
200
203
  var SUPPORT_WORMHOLE = [
@@ -218,7 +221,10 @@ var SUPPORT_BORROW_INCENTIVE_POOLS = [
218
221
  "sca",
219
222
  "usdc"
220
223
  ];
221
- var SUPPORT_BORROW_INCENTIVE_REWARDS = ["sui", "sca"];
224
+ var SUPPORT_BORROW_INCENTIVE_REWARDS = [
225
+ ...SUPPORT_POOLS,
226
+ ...SUPPORT_SCOIN
227
+ ];
222
228
  var SUPPORT_ORACLES = ["supra", "switchboard", "pyth"];
223
229
  var SUPPORT_PACKAGES = [
224
230
  "coinDecimalsRegistry",
@@ -251,8 +257,9 @@ var coinDecimals = {
251
257
  hasui: 9,
252
258
  vsui: 9,
253
259
  sca: 9,
254
- deep: 6,
255
- fud: 5,
260
+ // TODO: enable for production
261
+ // deep: 6,
262
+ // fud: 5,
256
263
  susdc: 6,
257
264
  sweth: 8,
258
265
  ssbeth: 8,
@@ -266,9 +273,10 @@ var coinDecimals = {
266
273
  safsui: 9,
267
274
  shasui: 9,
268
275
  svsui: 9,
269
- ssca: 9,
270
- sdeep: 6,
271
- sfud: 5
276
+ ssca: 9
277
+ // TODO: enable for production
278
+ // sdeep: 6,
279
+ // sfud: 5,
272
280
  };
273
281
  var assetCoins = {
274
282
  usdc: "usdc",
@@ -284,9 +292,10 @@ var assetCoins = {
284
292
  afsui: "afsui",
285
293
  hasui: "hasui",
286
294
  vsui: "vsui",
287
- sca: "sca",
288
- deep: "deep",
289
- fud: "fud"
295
+ sca: "sca"
296
+ // TODO: enable for production
297
+ // deep: 'deep',
298
+ // fud: 'fud',
290
299
  };
291
300
  var marketCoins = {
292
301
  susdc: "susdc",
@@ -302,9 +311,10 @@ var marketCoins = {
302
311
  safsui: "safsui",
303
312
  shasui: "shasui",
304
313
  svsui: "svsui",
305
- ssca: "ssca",
306
- sdeep: "sdeep",
307
- sfud: "sfud"
314
+ ssca: "ssca"
315
+ // TODO: enable for production
316
+ // sdeep: 'sdeep',
317
+ // sfud: 'sfud',
308
318
  };
309
319
  var sCoins = {
310
320
  susdc: "susdc",
@@ -319,9 +329,10 @@ var sCoins = {
319
329
  svsui: "svsui",
320
330
  ssca: "ssca",
321
331
  swsol: "swsol",
322
- swbtc: "swbtc",
323
- sfud: "sfud",
324
- sdeep: "sdeep"
332
+ swbtc: "swbtc"
333
+ // TODO: enable for production
334
+ // sfud: 'sfud',
335
+ // sdeep: 'sdeep',
325
336
  };
326
337
  var stakeMarketCoins = {
327
338
  susdc: "susdc",
@@ -348,18 +359,6 @@ var spoolRewardCoins = {
348
359
  var suiBridgeCoins = {
349
360
  sbeth: "sbeth"
350
361
  };
351
- 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"]
362
- };
363
362
  var coinIds = {
364
363
  usdc: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7",
365
364
  sui: "0x0000000000000000000000000000000000000000000000000000000000000002",
@@ -374,10 +373,10 @@ var coinIds = {
374
373
  afsui: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc",
375
374
  hasui: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d",
376
375
  vsui: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55",
377
- sca: IS_VE_SCA_TEST ? "0x6cd813061a3adf3602b76545f076205f0c8e7ec1d3b1eab9a1da7992c18c0524" : "0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6",
376
+ sca: IS_VE_SCA_TEST ? "0x6cd813061a3adf3602b76545f076205f0c8e7ec1d3b1eab9a1da7992c18c0524" : "0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6"
378
377
  // isolated assets
379
- deep: "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270",
380
- fud: "0x76cb819b01abed502bee8a702b4c2d547532c12f25001c9dea795a5e631c26f1"
378
+ // deep: '0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270',
379
+ // fud: '0x76cb819b01abed502bee8a702b4c2d547532c12f25001c9dea795a5e631c26f1',
381
380
  };
382
381
  var wormholeCoinIds = {
383
382
  weth: "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5",
@@ -393,19 +392,28 @@ var voloCoinIds = {
393
392
  var sCoinIds = {
394
393
  susdc: "0x854950aa624b1df59fe64e630b2ba7c550642e9342267a33061d59fb31582da5::scallop_usdc::SCALLOP_USDC",
395
394
  ssbeth: "0xb14f82d8506d139eacef109688d1b71e7236bcce9b2c0ad526abcd6aa5be7de0::scallop_sb_eth::SCALLOP_SB_ETH",
396
- ssui: "0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI",
395
+ // prod values
396
+ // ssui: '0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI',
397
+ // swusdc:
398
+ // '0xad4d71551d31092230db1fd482008ea42867dbf27b286e9c70a79d2a6191d58d::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC',
399
+ // swusdt:
400
+ // '0xe6e5a012ec20a49a3d1d57bd2b67140b96cd4d3400b9d79e541f7bdbab661f95::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT',
401
+ // ssca: '0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA',
402
+ // test values
403
+ ssui: "0xf569919046f19a0c40b519ecfbb6ca0319698cd5908716c29b62ef56541f298b::scallop_sui::SCALLOP_SUI",
404
+ swusdt: "0xac781d9f73058ff5e69f9bf8dde32f2e8c71c66d7fe8497fc83b2d9182254b22::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT",
405
+ swusdc: "0xf5447c4305a486d8c8557559887c2c39449ddb5e748f15d33946d02a1663c158::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC",
406
+ ssca: "0x958428555e778e55918a59eb1c92c77f32b5c554fa3a5e56cd0815086b5072e7::scallop_sca::SCALLOP_SCA",
397
407
  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
408
  sweth: "0x67540ceb850d418679e69f1fb6b2093d6df78a2a699ffc733f7646096d552e9b::scallop_wormhole_eth::SCALLOP_WORMHOLE_ETH",
402
409
  safsui: "0x00671b1fa2a124f5be8bdae8b91ee711462c5d9e31bda232e70fd9607b523c88::scallop_af_sui::SCALLOP_AF_SUI",
403
410
  shasui: "0x9a2376943f7d22f88087c259c5889925f332ca4347e669dc37d54c2bf651af3c::scallop_ha_sui::SCALLOP_HA_SUI",
404
411
  svsui: "0xe1a1cc6bcf0001a015eab84bcc6713393ce20535f55b8b6f35c142e057a25fbe::scallop_v_sui::SCALLOP_V_SUI",
405
412
  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"
413
+ swbtc: "0x2cf76a9cf5d3337961d1154283234f94da2dcff18544dfe5cbdef65f319591b5::scallop_wormhole_btc::SCALLOP_WORMHOLE_BTC"
414
+ // sdeep:
415
+ // '0xeb7a05a3224837c5e5503575aed0be73c091d1ce5e43aa3c3e716e0ae614608f::scallop_deep::SCALLOP_DEEP',
416
+ // sfud: '0xe56d5167f427cbe597da9e8150ef5c337839aaf46891d62468dcf80bdd8e10d1::scallop_fud::SCALLOP_FUD',
409
417
  };
410
418
  var sCoinTypeToName = Object.entries(sCoinIds).reduce(
411
419
  (acc, [coinName, coinType]) => {
@@ -414,6 +422,13 @@ var sCoinTypeToName = Object.entries(sCoinIds).reduce(
414
422
  },
415
423
  {}
416
424
  );
425
+ var sCoinRawNameToName = Object.entries(sCoinIds).reduce(
426
+ (acc, [coinName, coinType]) => {
427
+ acc[coinType.split("::")[2].toLowerCase()] = coinName;
428
+ return acc;
429
+ },
430
+ {}
431
+ );
417
432
 
418
433
  // src/constants/flashloan.ts
419
434
  var FlashLoanFeeObjectMap = {
@@ -488,13 +503,16 @@ var POOL_ADDRESSES = {
488
503
  sca: {
489
504
  lendingPoolAddress: "0x6fc7d4211fc7018b6c75e7b908b88f2e0536443239804a3d32af547637bd28d7",
490
505
  collateralPoolAddress: "0xff677a5d9e9dc8f08f0a8681ebfc7481d1c7d57bc441f2881974adcdd7b13c31"
491
- },
492
- fud: {
493
- lendingPoolAddress: "0x14367ddca30e2860cb89ed4eaca20c7ece260c5d59dd9990d2c85a8321326acb"
494
- },
495
- deep: {
496
- lendingPoolAddress: "0xf4a67ffb43da1e1c61c049f188f19463ea8dbbf2d5ef4722d6df854ff1b1cc03"
497
506
  }
507
+ // TODO: enable for production
508
+ // fud: {
509
+ // lendingPoolAddress:
510
+ // '0x14367ddca30e2860cb89ed4eaca20c7ece260c5d59dd9990d2c85a8321326acb',
511
+ // },
512
+ // deep: {
513
+ // lendingPoolAddress:
514
+ // '0xf4a67ffb43da1e1c61c049f188f19463ea8dbbf2d5ef4722d6df854ff1b1cc03',
515
+ // },
498
516
  };
499
517
 
500
518
  // src/constants/pyth.ts
@@ -516,9 +534,10 @@ var PYTH_FEED_IDS = {
516
534
  afsui: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
517
535
  hasui: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
518
536
  vsui: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
519
- sca: "7e17f0ac105abe9214deb9944c30264f5986bf292869c6bd8e8da3ccd92d79bc",
520
- deep: "29bdd5248234e33bd93d3b81100b5fa32eaa5997843847e2c2cb16d7c6d9f7ff",
521
- fud: "6a4090703da959247727f2b490eb21aea95c8684ecfac675f432008830890c75"
537
+ sca: "7e17f0ac105abe9214deb9944c30264f5986bf292869c6bd8e8da3ccd92d79bc"
538
+ // TODO: enable for production
539
+ // deep: '29bdd5248234e33bd93d3b81100b5fa32eaa5997843847e2c2cb16d7c6d9f7ff',
540
+ // fud: '6a4090703da959247727f2b490eb21aea95c8684ecfac675f432008830890c75',
522
541
  };
523
542
 
524
543
  // src/constants/queryKeys.ts
@@ -2561,15 +2580,21 @@ var queryBorrowIncentivePools = async (address) => {
2561
2580
  };
2562
2581
  var getBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
2563
2582
  ...SUPPORT_BORROW_INCENTIVE_POOLS
2564
- ], indexer = false, coinPrices) => {
2583
+ ], indexer = false, marketPools, coinPrices) => {
2565
2584
  const borrowIncentivePools = {};
2566
- coinPrices = coinPrices ?? await query.utils.getCoinPrices() ?? {};
2585
+ marketPools = marketPools ?? await query.getMarketPools(void 0, { indexer, coinPrices });
2586
+ coinPrices = coinPrices ?? await query.getAllCoinPrices({ marketPools });
2567
2587
  if (indexer) {
2568
2588
  const borrowIncentivePoolsIndexer = await query.indexer.getBorrowIncentivePools();
2569
2589
  const updateBorrowIncentivePool = (pool) => {
2570
2590
  if (!borrowIncentiveCoinNames.includes(pool.coinName))
2571
2591
  return;
2572
- pool.coinPrice = coinPrices[pool.coinName] ?? pool.coinPrice;
2592
+ pool.coinPrice = coinPrices[pool.coinName] || pool.coinPrice;
2593
+ for (const sCoinName of SUPPORT_BORROW_INCENTIVE_REWARDS) {
2594
+ if (pool.points[sCoinName]) {
2595
+ pool.points[sCoinName].coinPrice = coinPrices[sCoinName] ?? pool.points[sCoinName].coinPrice;
2596
+ }
2597
+ }
2573
2598
  borrowIncentivePools[pool.coinName] = pool;
2574
2599
  };
2575
2600
  Object.values(borrowIncentivePoolsIndexer).forEach(
@@ -2595,12 +2620,15 @@ var getBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
2595
2620
  for (const [coinName, poolPoint] of Object.entries(
2596
2621
  parsedBorrowIncentivePoolData.poolPoints
2597
2622
  )) {
2598
- const rewardCoinType = (0, import_utils3.normalizeStructTag)(poolPoint.pointType);
2599
- const rewardCoinName = query.utils.parseCoinNameFromType(
2623
+ const rewardCoinType = poolPoint.pointType;
2624
+ let rewardCoinName = query.utils.parseCoinNameFromType(
2600
2625
  rewardCoinType
2601
2626
  );
2602
- const rewardCoinPrice = coinPrices?.[rewardCoinName] ?? 0;
2627
+ if (sCoinRawNameToName[rewardCoinName]) {
2628
+ rewardCoinName = sCoinRawNameToName[rewardCoinName];
2629
+ }
2603
2630
  const rewardCoinDecimal = query.utils.getCoinDecimal(rewardCoinName);
2631
+ const rewardCoinPrice = coinPrices?.[rewardCoinName] ?? 0;
2604
2632
  const symbol = query.utils.parseSymbol(rewardCoinName);
2605
2633
  const coinDecimal = query.utils.getCoinDecimal(rewardCoinName);
2606
2634
  const calculatedPoolPoint = calculateBorrowIncentivePoolPointData(
@@ -2746,7 +2774,7 @@ var supplyLimitZod = import_zod.z.object({
2746
2774
  value: import_zod.z.string()
2747
2775
  })
2748
2776
  });
2749
- var supplyLimitKeyType = `0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e::market_dynamic_keys::SupplyLimitKey`;
2777
+ var supplyLimitKeyType = `0x6c23585e940a989588432509107e98bae06dbca4e333f26d0635d401b3c7c76d::market_dynamic_keys::SupplyLimitKey`;
2750
2778
  var getSupplyLimit = async (utils, poolName) => {
2751
2779
  try {
2752
2780
  const poolCoinType = utils.parseCoinType(poolName).slice(2);
@@ -2786,7 +2814,7 @@ var isolatedAssetZod = import_zod2.z.object({
2786
2814
  value: import_zod2.z.boolean()
2787
2815
  })
2788
2816
  });
2789
- var isolatedAssetKeyType = `0xe7dbb371a9595631f7964b7ece42255ad0e738cc85fe6da26c7221b220f01af6::market_dynamic_keys::IsolatedAssetKey`;
2817
+ var isolatedAssetKeyType = `0x6c23585e940a989588432509107e98bae06dbca4e333f26d0635d401b3c7c76d::market_dynamic_keys::IsolatedAssetKey`;
2790
2818
  var getIsolatedAssets = async (address) => {
2791
2819
  try {
2792
2820
  const marketObject = address.get("core.market");
@@ -2866,7 +2894,7 @@ var borrowLimitZod = import_zod3.z.object({
2866
2894
  value: import_zod3.z.string()
2867
2895
  })
2868
2896
  });
2869
- var borrowLimitKeyType = `0xe7dbb371a9595631f7964b7ece42255ad0e738cc85fe6da26c7221b220f01af6::market_dynamic_keys::BorrowLimitKey`;
2897
+ var borrowLimitKeyType = `0xb784ea287d944e478a3ceaa071f8885072cce6b7224cf245914dc2f9963f460e::market_dynamic_keys::BorrowLimitKey`;
2870
2898
  var getBorrowLimit = async (utils, poolName) => {
2871
2899
  try {
2872
2900
  const poolCoinType = utils.parseCoinType(poolName).slice(2);
@@ -3033,7 +3061,7 @@ var getMarketPools = async (query, poolCoinNames = [...SUPPORT_POOLS], indexer =
3033
3061
  const marketObjectResponse = await query.cache.queryGetObject(marketId, {
3034
3062
  showContent: true
3035
3063
  });
3036
- coinPrices = await query.utils.getCoinPrices(poolCoinNames) ?? {};
3064
+ coinPrices = coinPrices ?? await query.utils.getCoinPrices();
3037
3065
  const marketPools = {};
3038
3066
  if (indexer) {
3039
3067
  const marketPoolsIndexer = await query.indexer.getMarketPools();
@@ -3066,7 +3094,7 @@ var getMarketPools = async (query, poolCoinNames = [...SUPPORT_POOLS], indexer =
3066
3094
  return marketPools;
3067
3095
  };
3068
3096
  var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, coinPrice) => {
3069
- coinPrice = coinPrice || (await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName];
3097
+ coinPrice = coinPrice ?? (await query.utils.getCoinPrices())?.[poolCoinName];
3070
3098
  if (indexer) {
3071
3099
  const marketPoolIndexer = await query.indexer.getMarketPool(poolCoinName);
3072
3100
  if (!marketPoolIndexer) {
@@ -3209,7 +3237,7 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
3209
3237
  };
3210
3238
  var getMarketCollaterals = async (query, collateralCoinNames = [...SUPPORT_COLLATERALS], indexer = false) => {
3211
3239
  const marketId = query.address.get("core.market");
3212
- const coinPrices = await query.utils.getCoinPrices(collateralCoinNames) ?? {};
3240
+ const coinPrices = await query.utils.getCoinPrices() ?? {};
3213
3241
  const marketCollaterals = {};
3214
3242
  if (indexer) {
3215
3243
  const marketCollateralsIndexer = await query.indexer.getMarketCollaterals();
@@ -3245,7 +3273,7 @@ var getMarketCollaterals = async (query, collateralCoinNames = [...SUPPORT_COLLA
3245
3273
  return marketCollaterals;
3246
3274
  };
3247
3275
  var getMarketCollateral = async (query, collateralCoinName, indexer = false, marketObject, coinPrice) => {
3248
- coinPrice = coinPrice || (await query.utils.getCoinPrices([collateralCoinName]))?.[collateralCoinName];
3276
+ coinPrice = coinPrice ?? (await query.utils.getCoinPrices())?.[collateralCoinName];
3249
3277
  if (indexer) {
3250
3278
  const marketCollateralIndexer = await query.indexer.getMarketCollateral(collateralCoinName);
3251
3279
  marketCollateralIndexer.coinPrice = coinPrice ?? marketCollateralIndexer.coinPrice;
@@ -3561,7 +3589,7 @@ var getLendings = async (query, poolCoinNames = [...SUPPORT_POOLS], ownerAddress
3561
3589
  const stakeMarketCoinNames = marketCoinNames.filter(
3562
3590
  (marketCoinName) => SUPPORT_SPOOLS.includes(marketCoinName)
3563
3591
  );
3564
- const coinPrices = await query.utils.getCoinPrices(poolCoinNames);
3592
+ const coinPrices = await query.utils.getCoinPrices();
3565
3593
  const marketPools = await query.getMarketPools(poolCoinNames, {
3566
3594
  indexer,
3567
3595
  coinPrices
@@ -3601,7 +3629,7 @@ var getLendings = async (query, poolCoinNames = [...SUPPORT_POOLS], ownerAddress
3601
3629
  };
3602
3630
  var getLending = async (query, poolCoinName, ownerAddress, indexer = false, marketPool, spool, stakeAccounts, coinAmount, marketCoinAmount, coinPrice, sCoinAmount) => {
3603
3631
  const marketCoinName = query.utils.parseMarketCoinName(poolCoinName);
3604
- coinPrice = coinPrice ?? (await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName] ?? 0;
3632
+ coinPrice = coinPrice ?? (await query.utils.getCoinPrices())?.[poolCoinName] ?? 0;
3605
3633
  marketPool = marketPool ?? await query.getMarketPool(poolCoinName, {
3606
3634
  indexer,
3607
3635
  coinPrice
@@ -3759,8 +3787,8 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
3759
3787
  const collateralAssetCoinNames = [
3760
3788
  ...SUPPORT_COLLATERALS
3761
3789
  ];
3762
- coinPrices = coinPrices ?? await query.utils.getCoinPrices(collateralAssetCoinNames);
3763
- market = market ?? await query.queryMarket({ indexer, coinPrices });
3790
+ market = market ?? await query.queryMarket({ indexer });
3791
+ coinPrices = coinPrices ?? await query.getAllCoinPrices({ marketPools: market.pools });
3764
3792
  coinAmounts = coinAmounts || await query.getCoinAmounts(collateralAssetCoinNames, ownerAddress);
3765
3793
  const [obligationQuery, borrowIncentivePools, borrowIncentiveAccounts] = await Promise.all([
3766
3794
  query.queryObligation(obligationId),
@@ -3902,44 +3930,47 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
3902
3930
  const borrowIncentivePool = borrowIncentivePools[coinName];
3903
3931
  if (borrowIncentivePool) {
3904
3932
  const rewards = [];
3905
- for (const rewardCoinName of SUPPORT_BORROW_INCENTIVE_REWARDS) {
3906
- const accountPoint = borrowIncentiveAccount.pointList[rewardCoinName];
3907
- const poolPoint = borrowIncentivePool.points[rewardCoinName];
3908
- if (accountPoint && poolPoint) {
3909
- let availableClaimAmount = (0, import_bignumber5.default)(0);
3910
- let availableClaimCoin = (0, import_bignumber5.default)(0);
3911
- const accountBorrowedAmount = (0, import_bignumber5.default)(accountPoint.weightedAmount);
3912
- const baseIndexRate = 1e9;
3913
- const increasedPointRate = poolPoint.currentPointIndex ? Math.max(
3914
- (0, import_bignumber5.default)(poolPoint.currentPointIndex - accountPoint.index).dividedBy(baseIndexRate).toNumber(),
3915
- 0
3916
- ) : 1;
3917
- availableClaimAmount = availableClaimAmount.plus(
3918
- accountBorrowedAmount.multipliedBy(increasedPointRate).plus(accountPoint.points)
3919
- );
3920
- availableClaimCoin = availableClaimAmount.shiftedBy(
3921
- -1 * poolPoint.coinDecimal
3922
- );
3923
- const weightScale = (0, import_bignumber5.default)(1e12);
3924
- const boostValue = (0, import_bignumber5.default)(accountPoint.weightedAmount).div(
3925
- (0, import_bignumber5.default)(borrowIncentiveAccount.debtAmount).multipliedBy(poolPoint.baseWeight).dividedBy(weightScale)
3926
- ).isFinite() ? (0, import_bignumber5.default)(accountPoint.weightedAmount).div(
3927
- (0, import_bignumber5.default)(borrowIncentiveAccount.debtAmount).multipliedBy(poolPoint.baseWeight).dividedBy(weightScale)
3928
- ).toNumber() : 1;
3929
- if (availableClaimAmount.isGreaterThanOrEqualTo(0)) {
3930
- rewards.push({
3931
- coinName: poolPoint.coinName,
3932
- coinType: poolPoint.coinType,
3933
- symbol: poolPoint.symbol,
3934
- coinDecimal: poolPoint.coinDecimal,
3935
- coinPrice: poolPoint.coinPrice,
3936
- availableClaimAmount: availableClaimAmount.toNumber(),
3937
- availableClaimCoin: availableClaimCoin.toNumber(),
3938
- boostValue
3939
- });
3933
+ Object.entries(borrowIncentiveAccount.pointList).forEach(
3934
+ ([key, accountPoint]) => {
3935
+ const poolPoint = borrowIncentivePool.points[key];
3936
+ if (accountPoint && poolPoint) {
3937
+ let availableClaimAmount = (0, import_bignumber5.default)(0);
3938
+ let availableClaimCoin = (0, import_bignumber5.default)(0);
3939
+ const accountBorrowedAmount = (0, import_bignumber5.default)(
3940
+ accountPoint.weightedAmount
3941
+ );
3942
+ const baseIndexRate = 1e9;
3943
+ const increasedPointRate = poolPoint.currentPointIndex ? Math.max(
3944
+ (0, import_bignumber5.default)(poolPoint.currentPointIndex - accountPoint.index).dividedBy(baseIndexRate).toNumber(),
3945
+ 0
3946
+ ) : 1;
3947
+ availableClaimAmount = availableClaimAmount.plus(
3948
+ accountBorrowedAmount.multipliedBy(increasedPointRate).plus(accountPoint.points)
3949
+ );
3950
+ availableClaimCoin = availableClaimAmount.shiftedBy(
3951
+ -1 * poolPoint.coinDecimal
3952
+ );
3953
+ const weightScale = (0, import_bignumber5.default)(1e12);
3954
+ const boostValue = (0, import_bignumber5.default)(accountPoint.weightedAmount).div(
3955
+ (0, import_bignumber5.default)(borrowIncentiveAccount.debtAmount).multipliedBy(poolPoint.baseWeight).dividedBy(weightScale)
3956
+ ).isFinite() ? (0, import_bignumber5.default)(accountPoint.weightedAmount).div(
3957
+ (0, import_bignumber5.default)(borrowIncentiveAccount.debtAmount).multipliedBy(poolPoint.baseWeight).dividedBy(weightScale)
3958
+ ).toNumber() : 1;
3959
+ if (availableClaimAmount.isGreaterThanOrEqualTo(0)) {
3960
+ rewards.push({
3961
+ coinName: poolPoint.coinName,
3962
+ coinType: poolPoint.coinType,
3963
+ symbol: poolPoint.symbol,
3964
+ coinDecimal: poolPoint.coinDecimal,
3965
+ coinPrice: poolPoint.coinPrice,
3966
+ availableClaimAmount: availableClaimAmount.toNumber(),
3967
+ availableClaimCoin: availableClaimCoin.toNumber(),
3968
+ boostValue
3969
+ });
3970
+ }
3940
3971
  }
3941
3972
  }
3942
- }
3973
+ );
3943
3974
  if (Object.keys(borrowIncentivePool.points).some((coinName2) => {
3944
3975
  const rewardApr = borrowIncentivePool.points[coinName2]?.rewardApr;
3945
3976
  return rewardApr !== Infinity && typeof rewardApr == "number" && rewardApr > 0;
@@ -4083,6 +4114,7 @@ var getTotalValueLocked = async (query, indexer = false) => {
4083
4114
  };
4084
4115
 
4085
4116
  // src/queries/priceQuery.ts
4117
+ var import_bignumber6 = __toESM(require("bignumber.js"));
4086
4118
  var getPythPrice = async ({
4087
4119
  address
4088
4120
  }, assetCoinName, priceFeedObject) => {
@@ -4164,6 +4196,22 @@ var getPythPrices = async ({
4164
4196
  {}
4165
4197
  );
4166
4198
  };
4199
+ var getAllCoinPrices = async (query, marketPools, coinPrices) => {
4200
+ coinPrices = coinPrices ?? await query.utils.getCoinPrices();
4201
+ marketPools = marketPools ?? await query.getMarketPools(void 0, { coinPrices });
4202
+ if (!marketPools) {
4203
+ throw new Error(`Failed to fetch market pool for getAllCoinPrices`);
4204
+ }
4205
+ const sCoinPrices = {};
4206
+ SUPPORT_SCOIN.forEach((sCoinName) => {
4207
+ const coinName = query.utils.parseCoinName(sCoinName);
4208
+ sCoinPrices[sCoinName] = (0, import_bignumber6.default)(coinPrices[coinName] ?? 0).multipliedBy(marketPools[coinName]?.conversionRate ?? 1).toNumber();
4209
+ });
4210
+ return {
4211
+ ...coinPrices,
4212
+ ...sCoinPrices
4213
+ };
4214
+ };
4167
4215
 
4168
4216
  // src/queries/referralQuery.ts
4169
4217
  var queryVeScaKeyIdFromReferralBindings = async (address, refereeAddress) => {
@@ -4184,7 +4232,7 @@ var queryVeScaKeyIdFromReferralBindings = async (address, refereeAddress) => {
4184
4232
  // src/queries/sCoinQuery.ts
4185
4233
  var import_bcs = require("@mysten/sui/bcs");
4186
4234
  var import_assert = __toESM(require("assert"));
4187
- var import_bignumber6 = __toESM(require("bignumber.js"));
4235
+ var import_bignumber7 = __toESM(require("bignumber.js"));
4188
4236
  var getSCoinTotalSupply = async ({
4189
4237
  utils
4190
4238
  }, sCoinName) => {
@@ -4205,7 +4253,7 @@ var getSCoinTotalSupply = async ({
4205
4253
  const value = Uint8Array.from(results[0].returnValues[0][0]);
4206
4254
  const type = results[0].returnValues[0][1];
4207
4255
  (0, import_assert.default)(type === "u64", "Result type is not u64");
4208
- return (0, import_bignumber6.default)(import_bcs.bcs.u64().parse(value)).shiftedBy(utils.getCoinDecimal(utils.parseCoinName(sCoinName))).toNumber();
4256
+ return (0, import_bignumber7.default)(import_bcs.bcs.u64().parse(value)).shiftedBy(utils.getCoinDecimal(utils.parseCoinName(sCoinName))).toNumber();
4209
4257
  }
4210
4258
  return 0;
4211
4259
  };
@@ -4231,7 +4279,7 @@ var getSCoinAmount = async ({
4231
4279
  owner,
4232
4280
  coinType: sCoinType
4233
4281
  });
4234
- return (0, import_bignumber6.default)(amount).toNumber();
4282
+ return (0, import_bignumber7.default)(amount).toNumber();
4235
4283
  };
4236
4284
  var isSupportStakeCoins = (value) => {
4237
4285
  return SUPPORT_SCOIN.includes(value);
@@ -4261,7 +4309,7 @@ var getSCoinSwapRate = async (query, fromSCoin, toSCoin, underlyingCoinPrice) =>
4261
4309
  const ScoinAToARate = marketPools[0].conversionRate;
4262
4310
  const BtoSCoinBRate = 1 / marketPools[1].conversionRate;
4263
4311
  const calcAtoBRate = async () => {
4264
- const prices = await query.utils.getCoinPrices([fromCoinName, toCoinName]);
4312
+ const prices = await query.utils.getCoinPrices();
4265
4313
  if (!prices[fromCoinName] || !prices[toCoinName]) {
4266
4314
  throw new Error("Failed to fetch the coin prices");
4267
4315
  }
@@ -4271,7 +4319,7 @@ var getSCoinSwapRate = async (query, fromSCoin, toSCoin, underlyingCoinPrice) =>
4271
4319
  return prices[fromCoinName] / prices[toCoinName];
4272
4320
  };
4273
4321
  const AtoBRate = underlyingCoinPrice ?? await calcAtoBRate();
4274
- return (0, import_bignumber6.default)(ScoinAToARate).multipliedBy(AtoBRate).multipliedBy(BtoSCoinBRate).toNumber();
4322
+ return (0, import_bignumber7.default)(ScoinAToARate).multipliedBy(AtoBRate).multipliedBy(BtoSCoinBRate).toNumber();
4275
4323
  };
4276
4324
 
4277
4325
  // src/queries/spoolQuery.ts
@@ -4331,7 +4379,7 @@ var getSpool = async (query, marketCoinName, indexer = false, marketPool, coinPr
4331
4379
  `spool.pools.${marketCoinName}.rewardPoolId`
4332
4380
  );
4333
4381
  let spool = void 0;
4334
- coinPrices = coinPrices || await query.utils.getCoinPrices([coinName]);
4382
+ coinPrices = coinPrices || await query.utils.getCoinPrices();
4335
4383
  if (indexer) {
4336
4384
  const spoolIndexer = await query.indexer.getSpool(marketCoinName);
4337
4385
  const coinName2 = query.utils.parseCoinName(marketCoinName);
@@ -4351,7 +4399,7 @@ var getSpool = async (query, marketCoinName, indexer = false, marketPool, coinPr
4351
4399
  throw new Error("Fail to fetch spoolObjectResponse!");
4352
4400
  }
4353
4401
  const rewardCoinName = query.utils.getSpoolRewardCoinName(marketCoinName);
4354
- coinPrices = coinPrices || await query.utils.getCoinPrices([coinName, rewardCoinName]);
4402
+ coinPrices = coinPrices || await query.utils.getCoinPrices();
4355
4403
  const spoolObject = spoolObjectResponse[0];
4356
4404
  const rewardPoolObject = spoolObjectResponse[1];
4357
4405
  if (spoolObject.content && "fields" in spoolObject.content) {
@@ -4595,7 +4643,7 @@ var getStakeRewardPool = async ({
4595
4643
  };
4596
4644
 
4597
4645
  // src/queries/vescaQuery.ts
4598
- var import_bignumber7 = __toESM(require("bignumber.js"));
4646
+ var import_bignumber8 = __toESM(require("bignumber.js"));
4599
4647
  var import_sui_kit3 = require("@scallop-io/sui-kit");
4600
4648
  var import_bcs2 = require("@mysten/sui/bcs");
4601
4649
  var import_zod5 = require("zod");
@@ -4677,7 +4725,7 @@ var getVeSca = async (utils, veScaKey) => {
4677
4725
  0
4678
4726
  );
4679
4727
  const lockedScaAmount = String(dynamicFields.locked_sca_amount);
4680
- const lockedScaCoin = (0, import_bignumber7.default)(dynamicFields.locked_sca_amount).shiftedBy(-9).toNumber();
4728
+ const lockedScaCoin = (0, import_bignumber8.default)(dynamicFields.locked_sca_amount).shiftedBy(-9).toNumber();
4681
4729
  const currentVeScaBalance = lockedScaCoin * (Math.floor(remainingLockPeriodInMilliseconds / 1e3) / MAX_LOCK_DURATION);
4682
4730
  vesca = {
4683
4731
  id: veScaDynamicFieldObject.objectId,
@@ -4687,7 +4735,7 @@ var getVeSca = async (utils, veScaKey) => {
4687
4735
  lockedScaAmount,
4688
4736
  lockedScaCoin,
4689
4737
  currentVeScaBalance,
4690
- unlockAt: (0, import_bignumber7.default)(dynamicFields.unlock_at * 1e3).toNumber()
4738
+ unlockAt: (0, import_bignumber8.default)(dynamicFields.unlock_at * 1e3).toNumber()
4691
4739
  };
4692
4740
  }
4693
4741
  return vesca;
@@ -4749,10 +4797,10 @@ var getVeScaTreasuryInfo = async (utils) => {
4749
4797
  if (!veScaTreasury || veScaTreasury.data?.content?.dataType !== "moveObject")
4750
4798
  return null;
4751
4799
  const treasuryFields = veScaTreasury.data.content.fields;
4752
- const totalLockedSca = (0, import_bignumber7.default)(
4800
+ const totalLockedSca = (0, import_bignumber8.default)(
4753
4801
  treasuryFields.unlock_schedule.fields.locked_sca_amount
4754
4802
  ).shiftedBy(-9).toNumber();
4755
- const totalVeSca = (0, import_bignumber7.default)(
4803
+ const totalVeSca = (0, import_bignumber8.default)(
4756
4804
  await getTotalVeScaTreasuryAmount(utils, veScaTreasury.data) ?? 0
4757
4805
  ).shiftedBy(-9).toNumber();
4758
4806
  const averageLockingPeriod = totalLockedSca > 0 ? totalVeSca / totalLockedSca * 4 : 0;
@@ -4788,15 +4836,6 @@ var ScallopUtils = class {
4788
4836
  this.getSpoolRewardCoinName = (stakeMarketCoinName) => {
4789
4837
  return spoolRewardCoins[stakeMarketCoinName];
4790
4838
  };
4791
- /**
4792
- * Get reward type of borrow incentive pool.
4793
- *
4794
- * @param borrowIncentiveCoinName - Support borrow incentive coin.
4795
- * @return Borrow incentive reward coin name.
4796
- */
4797
- this.getBorrowIncentiveRewardCoinName = (borrowIncentiveCoinName) => {
4798
- return borrowIncentiveRewardCoins[borrowIncentiveCoinName];
4799
- };
4800
4839
  this.params = {
4801
4840
  pythEndpoints: params.pythEndpoints ?? PYTH_ENDPOINTS["mainnet"],
4802
4841
  ...params
@@ -4866,7 +4905,10 @@ var ScallopUtils = class {
4866
4905
  * @param coinName - Specific support coin name.
4867
4906
  * @return Coin type.
4868
4907
  */
4869
- parseCoinType(coinName) {
4908
+ parseCoinType(coinName, useOldMarketCoin = false) {
4909
+ if (sCoinIds[coinName] && !useOldMarketCoin) {
4910
+ return sCoinIds[coinName];
4911
+ }
4870
4912
  coinName = isMarketCoin(coinName) ? this.parseCoinName(coinName) : coinName;
4871
4913
  const coinPackageId = this.address.get(`core.coins.${coinName}.id`) || coinIds[coinName] || void 0;
4872
4914
  if (!coinPackageId) {
@@ -4921,6 +4963,15 @@ var ScallopUtils = class {
4921
4963
  return void 0;
4922
4964
  }
4923
4965
  }
4966
+ /**
4967
+ * Convert sCoin name to coin name.
4968
+ * This function will parse new sCoin name `scallop_...` to its old market coin name which is shorter
4969
+ * e.g: `scallop_sui -> ssui
4970
+ * @return sCoin name
4971
+ */
4972
+ parseCoinNameFromSCoinName(coinName) {
4973
+ return sCoinRawNameToName[coinName];
4974
+ }
4924
4975
  /**
4925
4976
  * Convert sCoin name into sCoin type
4926
4977
  * @param sCoinName
@@ -4963,7 +5014,7 @@ var ScallopUtils = class {
4963
5014
  */
4964
5015
  parseMarketCoinType(coinName) {
4965
5016
  const protocolObjectId = this.address.get("core.object") ?? PROTOCOL_OBJECT_ID;
4966
- const coinType = this.parseCoinType(coinName);
5017
+ const coinType = this.parseCoinType(coinName, true);
4967
5018
  return `${protocolObjectId}::reserve::MarketCoin<${coinType}>`;
4968
5019
  }
4969
5020
  parseCoinNameFromType(coinType) {
@@ -4972,7 +5023,7 @@ var ScallopUtils = class {
4972
5023
  const coinTypeMatch = coinType.match(coinTypeRegex);
4973
5024
  const isMarketCoinType = coinType.includes("reserve::MarketCoin");
4974
5025
  coinType = coinTypeMatch?.[1] ?? coinType;
4975
- const wormHoleCoinTypeMap = {
5026
+ const wormholeCoinTypeMap = {
4976
5027
  [`${this.address.get("core.coins.wusdc.id") ?? wormholeCoinIds.wusdc}::coin::COIN`]: "wusdc",
4977
5028
  [`${this.address.get("core.coins.wusdt.id") ?? wormholeCoinIds.wusdt}::coin::COIN`]: "wusdt",
4978
5029
  [`${this.address.get("core.coins.weth.id") ?? wormholeCoinIds.weth}::coin::COIN`]: "weth",
@@ -4992,7 +5043,7 @@ var ScallopUtils = class {
4992
5043
  },
4993
5044
  {}
4994
5045
  );
4995
- const assetCoinName = wormHoleCoinTypeMap[coinType] || voloCoinTypeMap[coinType] || suiBridgeTypeMap[coinType] || coinType.split("::")[2].toLowerCase();
5046
+ const assetCoinName = wormholeCoinTypeMap[coinType] || voloCoinTypeMap[coinType] || suiBridgeTypeMap[coinType] || coinType.split("::")[2].toLowerCase();
4996
5047
  return isMarketCoinType ? this.parseMarketCoinName(assetCoinName) : assetCoinName;
4997
5048
  }
4998
5049
  /**
@@ -6103,11 +6154,7 @@ var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
6103
6154
  ]
6104
6155
  );
6105
6156
  },
6106
- claimBorrowIncentive: (obligationId, obligationKey, coinName, rewardCoinName) => {
6107
- const rewardCoinNames = builder.utils.getBorrowIncentiveRewardCoinName(coinName);
6108
- if (rewardCoinNames.includes(rewardCoinName) === false) {
6109
- throw new Error(`Invalid reward coin name ${rewardCoinName}`);
6110
- }
6157
+ claimBorrowIncentive: (obligationId, obligationKey, rewardCoinName) => {
6111
6158
  const rewardType = builder.utils.parseCoinType(rewardCoinName);
6112
6159
  return txBlock.moveCall(
6113
6160
  `${borrowIncentiveIds.borrowIncentivePkg}::user::redeem_rewards`,
@@ -6200,7 +6247,7 @@ var generateBorrowIncentiveQuickMethod = ({ builder, txBlock }) => {
6200
6247
  txBlock.unstakeObligation(obligationArg, obligationKeyArg);
6201
6248
  }
6202
6249
  },
6203
- claimBorrowIncentiveQuick: async (coinName, rewardCoinName, obligation, obligationKey) => {
6250
+ claimBorrowIncentiveQuick: async (rewardCoinName, obligation, obligationKey) => {
6204
6251
  const { obligationId: obligationArg, obligationKey: obligationKeyArg } = await requireObligationInfo2(
6205
6252
  builder,
6206
6253
  txBlock,
@@ -6210,7 +6257,6 @@ var generateBorrowIncentiveQuickMethod = ({ builder, txBlock }) => {
6210
6257
  return txBlock.claimBorrowIncentive(
6211
6258
  obligationArg,
6212
6259
  obligationKeyArg,
6213
- coinName,
6214
6260
  rewardCoinName
6215
6261
  );
6216
6262
  }
@@ -7380,6 +7426,7 @@ var ScallopQuery = class {
7380
7426
  this,
7381
7427
  coinNames,
7382
7428
  args?.indexer,
7429
+ args?.marketPools,
7383
7430
  args?.coinPrices
7384
7431
  );
7385
7432
  }
@@ -7595,6 +7642,13 @@ var ScallopQuery = class {
7595
7642
  async getCoinPriceByIndexer(poolName) {
7596
7643
  return this.indexer.getCoinPrice(poolName);
7597
7644
  }
7645
+ /**
7646
+ * Get all coin prices, including sCoin
7647
+ * @returns prices data
7648
+ */
7649
+ async getAllCoinPrices(args) {
7650
+ return getAllCoinPrices(this, args?.marketPools, args?.coinPrices);
7651
+ }
7598
7652
  };
7599
7653
 
7600
7654
  // src/models/scallopBuilder.ts
@@ -8244,30 +8298,46 @@ var ScallopClient = class {
8244
8298
  }
8245
8299
  }
8246
8300
  /**
8247
- * unstake market coin from the specific spool.
8301
+ * Claim borrow incentive reward.
8248
8302
  *
8249
- * @param marketCoinName - Types of mak coin.
8303
+ * @param poolName
8250
8304
  * @param amount - The amount of coins would deposit.
8251
8305
  * @param sign - Decide to directly sign the transaction or return the transaction block.
8252
8306
  * @param accountId - The stake account object.
8253
8307
  * @param walletAddress - The wallet address of the owner.
8254
8308
  * @return Transaction block response or transaction block
8255
8309
  */
8256
- async claimBorrowIncentive(coinName, obligationId, obligationKeyId, sign = true, walletAddress) {
8310
+ async claimBorrowIncentive(obligationId, obligationKeyId, sign = true, walletAddress) {
8257
8311
  const txBlock = this.builder.createTxBlock();
8258
8312
  const sender = walletAddress ?? this.walletAddress;
8259
8313
  txBlock.setSender(sender);
8260
- const rewardCoins = [];
8261
- for (const rewardCoinName of SUPPORT_BORROW_INCENTIVE_REWARDS) {
8314
+ const rewardCoinsCollection = {};
8315
+ const obligationAccount = await this.query.getObligationAccount(obligationId);
8316
+ const rewardCoinNames = Object.values(obligationAccount.borrowIncentives).flatMap(
8317
+ ({ rewards }) => rewards.filter(({ availableClaimAmount }) => availableClaimAmount > 0)
8318
+ ).flatMap(({ coinName }) => coinName);
8319
+ for (const rewardCoinName of rewardCoinNames) {
8262
8320
  const rewardCoin = await txBlock.claimBorrowIncentiveQuick(
8263
- coinName,
8264
8321
  rewardCoinName,
8265
8322
  obligationId,
8266
8323
  obligationKeyId
8267
8324
  );
8268
- rewardCoins.push(rewardCoin);
8325
+ if (!rewardCoinsCollection[rewardCoinName]) {
8326
+ rewardCoinsCollection[rewardCoinName] = [rewardCoin];
8327
+ } else {
8328
+ rewardCoinsCollection[rewardCoinName].push(rewardCoin);
8329
+ }
8269
8330
  }
8270
- txBlock.transferObjects(rewardCoins, sender);
8331
+ txBlock.transferObjects(
8332
+ Object.values(rewardCoinsCollection).map((rewardCoins) => {
8333
+ const mergeDest = rewardCoins[0];
8334
+ if (rewardCoins.length > 1) {
8335
+ txBlock.mergeCoins(mergeDest, rewardCoins.slice(1));
8336
+ }
8337
+ return mergeDest;
8338
+ }),
8339
+ sender
8340
+ );
8271
8341
  if (sign) {
8272
8342
  return await this.suiKit.signAndSendTxn(
8273
8343
  txBlock
@@ -8577,12 +8647,12 @@ var Scallop = class {
8577
8647
  UNLOCK_ROUND_DURATION,
8578
8648
  USE_TEST_ADDRESS,
8579
8649
  assetCoins,
8580
- borrowIncentiveRewardCoins,
8581
8650
  coinDecimals,
8582
8651
  coinIds,
8583
8652
  marketCoins,
8584
8653
  queryKeys,
8585
8654
  sCoinIds,
8655
+ sCoinRawNameToName,
8586
8656
  sCoinTypeToName,
8587
8657
  sCoins,
8588
8658
  spoolRewardCoins,