@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.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",
@@ -256,18 +267,6 @@ var spoolRewardCoins = {
256
267
  var suiBridgeCoins = {
257
268
  sbeth: "sbeth"
258
269
  };
259
- 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"]
270
- };
271
270
  var coinIds = {
272
271
  usdc: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7",
273
272
  sui: "0x0000000000000000000000000000000000000000000000000000000000000002",
@@ -282,10 +281,10 @@ var coinIds = {
282
281
  afsui: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc",
283
282
  hasui: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d",
284
283
  vsui: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55",
285
- sca: IS_VE_SCA_TEST ? "0x6cd813061a3adf3602b76545f076205f0c8e7ec1d3b1eab9a1da7992c18c0524" : "0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6",
284
+ sca: IS_VE_SCA_TEST ? "0x6cd813061a3adf3602b76545f076205f0c8e7ec1d3b1eab9a1da7992c18c0524" : "0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6"
286
285
  // isolated assets
287
- deep: "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270",
288
- fud: "0x76cb819b01abed502bee8a702b4c2d547532c12f25001c9dea795a5e631c26f1"
286
+ // deep: '0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270',
287
+ // fud: '0x76cb819b01abed502bee8a702b4c2d547532c12f25001c9dea795a5e631c26f1',
289
288
  };
290
289
  var wormholeCoinIds = {
291
290
  weth: "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5",
@@ -301,19 +300,28 @@ var voloCoinIds = {
301
300
  var sCoinIds = {
302
301
  susdc: "0x854950aa624b1df59fe64e630b2ba7c550642e9342267a33061d59fb31582da5::scallop_usdc::SCALLOP_USDC",
303
302
  ssbeth: "0xb14f82d8506d139eacef109688d1b71e7236bcce9b2c0ad526abcd6aa5be7de0::scallop_sb_eth::SCALLOP_SB_ETH",
304
- ssui: "0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI",
303
+ // prod values
304
+ // ssui: '0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI',
305
+ // swusdc:
306
+ // '0xad4d71551d31092230db1fd482008ea42867dbf27b286e9c70a79d2a6191d58d::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC',
307
+ // swusdt:
308
+ // '0xe6e5a012ec20a49a3d1d57bd2b67140b96cd4d3400b9d79e541f7bdbab661f95::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT',
309
+ // ssca: '0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA',
310
+ // test values
311
+ ssui: "0xf569919046f19a0c40b519ecfbb6ca0319698cd5908716c29b62ef56541f298b::scallop_sui::SCALLOP_SUI",
312
+ swusdt: "0xac781d9f73058ff5e69f9bf8dde32f2e8c71c66d7fe8497fc83b2d9182254b22::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT",
313
+ swusdc: "0xf5447c4305a486d8c8557559887c2c39449ddb5e748f15d33946d02a1663c158::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC",
314
+ ssca: "0x958428555e778e55918a59eb1c92c77f32b5c554fa3a5e56cd0815086b5072e7::scallop_sca::SCALLOP_SCA",
305
315
  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
316
  sweth: "0x67540ceb850d418679e69f1fb6b2093d6df78a2a699ffc733f7646096d552e9b::scallop_wormhole_eth::SCALLOP_WORMHOLE_ETH",
310
317
  safsui: "0x00671b1fa2a124f5be8bdae8b91ee711462c5d9e31bda232e70fd9607b523c88::scallop_af_sui::SCALLOP_AF_SUI",
311
318
  shasui: "0x9a2376943f7d22f88087c259c5889925f332ca4347e669dc37d54c2bf651af3c::scallop_ha_sui::SCALLOP_HA_SUI",
312
319
  svsui: "0xe1a1cc6bcf0001a015eab84bcc6713393ce20535f55b8b6f35c142e057a25fbe::scallop_v_sui::SCALLOP_V_SUI",
313
320
  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"
321
+ swbtc: "0x2cf76a9cf5d3337961d1154283234f94da2dcff18544dfe5cbdef65f319591b5::scallop_wormhole_btc::SCALLOP_WORMHOLE_BTC"
322
+ // sdeep:
323
+ // '0xeb7a05a3224837c5e5503575aed0be73c091d1ce5e43aa3c3e716e0ae614608f::scallop_deep::SCALLOP_DEEP',
324
+ // sfud: '0xe56d5167f427cbe597da9e8150ef5c337839aaf46891d62468dcf80bdd8e10d1::scallop_fud::SCALLOP_FUD',
317
325
  };
318
326
  var sCoinTypeToName = Object.entries(sCoinIds).reduce(
319
327
  (acc, [coinName, coinType]) => {
@@ -322,6 +330,13 @@ var sCoinTypeToName = Object.entries(sCoinIds).reduce(
322
330
  },
323
331
  {}
324
332
  );
333
+ var sCoinRawNameToName = Object.entries(sCoinIds).reduce(
334
+ (acc, [coinName, coinType]) => {
335
+ acc[coinType.split("::")[2].toLowerCase()] = coinName;
336
+ return acc;
337
+ },
338
+ {}
339
+ );
325
340
 
326
341
  // src/constants/flashloan.ts
327
342
  var FlashLoanFeeObjectMap = {
@@ -396,13 +411,16 @@ var POOL_ADDRESSES = {
396
411
  sca: {
397
412
  lendingPoolAddress: "0x6fc7d4211fc7018b6c75e7b908b88f2e0536443239804a3d32af547637bd28d7",
398
413
  collateralPoolAddress: "0xff677a5d9e9dc8f08f0a8681ebfc7481d1c7d57bc441f2881974adcdd7b13c31"
399
- },
400
- fud: {
401
- lendingPoolAddress: "0x14367ddca30e2860cb89ed4eaca20c7ece260c5d59dd9990d2c85a8321326acb"
402
- },
403
- deep: {
404
- lendingPoolAddress: "0xf4a67ffb43da1e1c61c049f188f19463ea8dbbf2d5ef4722d6df854ff1b1cc03"
405
414
  }
415
+ // TODO: enable for production
416
+ // fud: {
417
+ // lendingPoolAddress:
418
+ // '0x14367ddca30e2860cb89ed4eaca20c7ece260c5d59dd9990d2c85a8321326acb',
419
+ // },
420
+ // deep: {
421
+ // lendingPoolAddress:
422
+ // '0xf4a67ffb43da1e1c61c049f188f19463ea8dbbf2d5ef4722d6df854ff1b1cc03',
423
+ // },
406
424
  };
407
425
 
408
426
  // src/constants/pyth.ts
@@ -424,9 +442,10 @@ var PYTH_FEED_IDS = {
424
442
  afsui: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
425
443
  hasui: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
426
444
  vsui: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
427
- sca: "7e17f0ac105abe9214deb9944c30264f5986bf292869c6bd8e8da3ccd92d79bc",
428
- deep: "29bdd5248234e33bd93d3b81100b5fa32eaa5997843847e2c2cb16d7c6d9f7ff",
429
- fud: "6a4090703da959247727f2b490eb21aea95c8684ecfac675f432008830890c75"
445
+ sca: "7e17f0ac105abe9214deb9944c30264f5986bf292869c6bd8e8da3ccd92d79bc"
446
+ // TODO: enable for production
447
+ // deep: '29bdd5248234e33bd93d3b81100b5fa32eaa5997843847e2c2cb16d7c6d9f7ff',
448
+ // fud: '6a4090703da959247727f2b490eb21aea95c8684ecfac675f432008830890c75',
430
449
  };
431
450
 
432
451
  // src/constants/queryKeys.ts
@@ -2472,15 +2491,21 @@ var queryBorrowIncentivePools = async (address) => {
2472
2491
  };
2473
2492
  var getBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
2474
2493
  ...SUPPORT_BORROW_INCENTIVE_POOLS
2475
- ], indexer = false, coinPrices) => {
2494
+ ], indexer = false, marketPools, coinPrices) => {
2476
2495
  const borrowIncentivePools = {};
2477
- coinPrices = coinPrices ?? await query.utils.getCoinPrices() ?? {};
2496
+ marketPools = marketPools ?? await query.getMarketPools(void 0, { indexer, coinPrices });
2497
+ coinPrices = coinPrices ?? await query.getAllCoinPrices({ marketPools });
2478
2498
  if (indexer) {
2479
2499
  const borrowIncentivePoolsIndexer = await query.indexer.getBorrowIncentivePools();
2480
2500
  const updateBorrowIncentivePool = (pool) => {
2481
2501
  if (!borrowIncentiveCoinNames.includes(pool.coinName))
2482
2502
  return;
2483
- pool.coinPrice = coinPrices[pool.coinName] ?? pool.coinPrice;
2503
+ pool.coinPrice = coinPrices[pool.coinName] || pool.coinPrice;
2504
+ for (const sCoinName of SUPPORT_BORROW_INCENTIVE_REWARDS) {
2505
+ if (pool.points[sCoinName]) {
2506
+ pool.points[sCoinName].coinPrice = coinPrices[sCoinName] ?? pool.points[sCoinName].coinPrice;
2507
+ }
2508
+ }
2484
2509
  borrowIncentivePools[pool.coinName] = pool;
2485
2510
  };
2486
2511
  Object.values(borrowIncentivePoolsIndexer).forEach(
@@ -2506,12 +2531,15 @@ var getBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
2506
2531
  for (const [coinName, poolPoint] of Object.entries(
2507
2532
  parsedBorrowIncentivePoolData.poolPoints
2508
2533
  )) {
2509
- const rewardCoinType = normalizeStructTag3(poolPoint.pointType);
2510
- const rewardCoinName = query.utils.parseCoinNameFromType(
2534
+ const rewardCoinType = poolPoint.pointType;
2535
+ let rewardCoinName = query.utils.parseCoinNameFromType(
2511
2536
  rewardCoinType
2512
2537
  );
2513
- const rewardCoinPrice = coinPrices?.[rewardCoinName] ?? 0;
2538
+ if (sCoinRawNameToName[rewardCoinName]) {
2539
+ rewardCoinName = sCoinRawNameToName[rewardCoinName];
2540
+ }
2514
2541
  const rewardCoinDecimal = query.utils.getCoinDecimal(rewardCoinName);
2542
+ const rewardCoinPrice = coinPrices?.[rewardCoinName] ?? 0;
2515
2543
  const symbol = query.utils.parseSymbol(rewardCoinName);
2516
2544
  const coinDecimal = query.utils.getCoinDecimal(rewardCoinName);
2517
2545
  const calculatedPoolPoint = calculateBorrowIncentivePoolPointData(
@@ -2657,7 +2685,7 @@ var supplyLimitZod = zod.object({
2657
2685
  value: zod.string()
2658
2686
  })
2659
2687
  });
2660
- var supplyLimitKeyType = `0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e::market_dynamic_keys::SupplyLimitKey`;
2688
+ var supplyLimitKeyType = `0x6c23585e940a989588432509107e98bae06dbca4e333f26d0635d401b3c7c76d::market_dynamic_keys::SupplyLimitKey`;
2661
2689
  var getSupplyLimit = async (utils, poolName) => {
2662
2690
  try {
2663
2691
  const poolCoinType = utils.parseCoinType(poolName).slice(2);
@@ -2697,7 +2725,7 @@ var isolatedAssetZod = zod2.object({
2697
2725
  value: zod2.boolean()
2698
2726
  })
2699
2727
  });
2700
- var isolatedAssetKeyType = `0xe7dbb371a9595631f7964b7ece42255ad0e738cc85fe6da26c7221b220f01af6::market_dynamic_keys::IsolatedAssetKey`;
2728
+ var isolatedAssetKeyType = `0x6c23585e940a989588432509107e98bae06dbca4e333f26d0635d401b3c7c76d::market_dynamic_keys::IsolatedAssetKey`;
2701
2729
  var getIsolatedAssets = async (address) => {
2702
2730
  try {
2703
2731
  const marketObject = address.get("core.market");
@@ -2777,7 +2805,7 @@ var borrowLimitZod = zod3.object({
2777
2805
  value: zod3.string()
2778
2806
  })
2779
2807
  });
2780
- var borrowLimitKeyType = `0xe7dbb371a9595631f7964b7ece42255ad0e738cc85fe6da26c7221b220f01af6::market_dynamic_keys::BorrowLimitKey`;
2808
+ var borrowLimitKeyType = `0xb784ea287d944e478a3ceaa071f8885072cce6b7224cf245914dc2f9963f460e::market_dynamic_keys::BorrowLimitKey`;
2781
2809
  var getBorrowLimit = async (utils, poolName) => {
2782
2810
  try {
2783
2811
  const poolCoinType = utils.parseCoinType(poolName).slice(2);
@@ -2944,7 +2972,7 @@ var getMarketPools = async (query, poolCoinNames = [...SUPPORT_POOLS], indexer =
2944
2972
  const marketObjectResponse = await query.cache.queryGetObject(marketId, {
2945
2973
  showContent: true
2946
2974
  });
2947
- coinPrices = await query.utils.getCoinPrices(poolCoinNames) ?? {};
2975
+ coinPrices = coinPrices ?? await query.utils.getCoinPrices();
2948
2976
  const marketPools = {};
2949
2977
  if (indexer) {
2950
2978
  const marketPoolsIndexer = await query.indexer.getMarketPools();
@@ -2977,7 +3005,7 @@ var getMarketPools = async (query, poolCoinNames = [...SUPPORT_POOLS], indexer =
2977
3005
  return marketPools;
2978
3006
  };
2979
3007
  var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, coinPrice) => {
2980
- coinPrice = coinPrice || (await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName];
3008
+ coinPrice = coinPrice ?? (await query.utils.getCoinPrices())?.[poolCoinName];
2981
3009
  if (indexer) {
2982
3010
  const marketPoolIndexer = await query.indexer.getMarketPool(poolCoinName);
2983
3011
  if (!marketPoolIndexer) {
@@ -3120,7 +3148,7 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
3120
3148
  };
3121
3149
  var getMarketCollaterals = async (query, collateralCoinNames = [...SUPPORT_COLLATERALS], indexer = false) => {
3122
3150
  const marketId = query.address.get("core.market");
3123
- const coinPrices = await query.utils.getCoinPrices(collateralCoinNames) ?? {};
3151
+ const coinPrices = await query.utils.getCoinPrices() ?? {};
3124
3152
  const marketCollaterals = {};
3125
3153
  if (indexer) {
3126
3154
  const marketCollateralsIndexer = await query.indexer.getMarketCollaterals();
@@ -3156,7 +3184,7 @@ var getMarketCollaterals = async (query, collateralCoinNames = [...SUPPORT_COLLA
3156
3184
  return marketCollaterals;
3157
3185
  };
3158
3186
  var getMarketCollateral = async (query, collateralCoinName, indexer = false, marketObject, coinPrice) => {
3159
- coinPrice = coinPrice || (await query.utils.getCoinPrices([collateralCoinName]))?.[collateralCoinName];
3187
+ coinPrice = coinPrice ?? (await query.utils.getCoinPrices())?.[collateralCoinName];
3160
3188
  if (indexer) {
3161
3189
  const marketCollateralIndexer = await query.indexer.getMarketCollateral(collateralCoinName);
3162
3190
  marketCollateralIndexer.coinPrice = coinPrice ?? marketCollateralIndexer.coinPrice;
@@ -3472,7 +3500,7 @@ var getLendings = async (query, poolCoinNames = [...SUPPORT_POOLS], ownerAddress
3472
3500
  const stakeMarketCoinNames = marketCoinNames.filter(
3473
3501
  (marketCoinName) => SUPPORT_SPOOLS.includes(marketCoinName)
3474
3502
  );
3475
- const coinPrices = await query.utils.getCoinPrices(poolCoinNames);
3503
+ const coinPrices = await query.utils.getCoinPrices();
3476
3504
  const marketPools = await query.getMarketPools(poolCoinNames, {
3477
3505
  indexer,
3478
3506
  coinPrices
@@ -3512,7 +3540,7 @@ var getLendings = async (query, poolCoinNames = [...SUPPORT_POOLS], ownerAddress
3512
3540
  };
3513
3541
  var getLending = async (query, poolCoinName, ownerAddress, indexer = false, marketPool, spool, stakeAccounts, coinAmount, marketCoinAmount, coinPrice, sCoinAmount) => {
3514
3542
  const marketCoinName = query.utils.parseMarketCoinName(poolCoinName);
3515
- coinPrice = coinPrice ?? (await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName] ?? 0;
3543
+ coinPrice = coinPrice ?? (await query.utils.getCoinPrices())?.[poolCoinName] ?? 0;
3516
3544
  marketPool = marketPool ?? await query.getMarketPool(poolCoinName, {
3517
3545
  indexer,
3518
3546
  coinPrice
@@ -3670,8 +3698,8 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
3670
3698
  const collateralAssetCoinNames = [
3671
3699
  ...SUPPORT_COLLATERALS
3672
3700
  ];
3673
- coinPrices = coinPrices ?? await query.utils.getCoinPrices(collateralAssetCoinNames);
3674
- market = market ?? await query.queryMarket({ indexer, coinPrices });
3701
+ market = market ?? await query.queryMarket({ indexer });
3702
+ coinPrices = coinPrices ?? await query.getAllCoinPrices({ marketPools: market.pools });
3675
3703
  coinAmounts = coinAmounts || await query.getCoinAmounts(collateralAssetCoinNames, ownerAddress);
3676
3704
  const [obligationQuery, borrowIncentivePools, borrowIncentiveAccounts] = await Promise.all([
3677
3705
  query.queryObligation(obligationId),
@@ -3813,44 +3841,47 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
3813
3841
  const borrowIncentivePool = borrowIncentivePools[coinName];
3814
3842
  if (borrowIncentivePool) {
3815
3843
  const rewards = [];
3816
- for (const rewardCoinName of SUPPORT_BORROW_INCENTIVE_REWARDS) {
3817
- const accountPoint = borrowIncentiveAccount.pointList[rewardCoinName];
3818
- const poolPoint = borrowIncentivePool.points[rewardCoinName];
3819
- if (accountPoint && poolPoint) {
3820
- let availableClaimAmount = BigNumber5(0);
3821
- let availableClaimCoin = BigNumber5(0);
3822
- const accountBorrowedAmount = BigNumber5(accountPoint.weightedAmount);
3823
- const baseIndexRate = 1e9;
3824
- const increasedPointRate = poolPoint.currentPointIndex ? Math.max(
3825
- BigNumber5(poolPoint.currentPointIndex - accountPoint.index).dividedBy(baseIndexRate).toNumber(),
3826
- 0
3827
- ) : 1;
3828
- availableClaimAmount = availableClaimAmount.plus(
3829
- accountBorrowedAmount.multipliedBy(increasedPointRate).plus(accountPoint.points)
3830
- );
3831
- availableClaimCoin = availableClaimAmount.shiftedBy(
3832
- -1 * poolPoint.coinDecimal
3833
- );
3834
- const weightScale = BigNumber5(1e12);
3835
- const boostValue = BigNumber5(accountPoint.weightedAmount).div(
3836
- BigNumber5(borrowIncentiveAccount.debtAmount).multipliedBy(poolPoint.baseWeight).dividedBy(weightScale)
3837
- ).isFinite() ? BigNumber5(accountPoint.weightedAmount).div(
3838
- BigNumber5(borrowIncentiveAccount.debtAmount).multipliedBy(poolPoint.baseWeight).dividedBy(weightScale)
3839
- ).toNumber() : 1;
3840
- if (availableClaimAmount.isGreaterThanOrEqualTo(0)) {
3841
- rewards.push({
3842
- coinName: poolPoint.coinName,
3843
- coinType: poolPoint.coinType,
3844
- symbol: poolPoint.symbol,
3845
- coinDecimal: poolPoint.coinDecimal,
3846
- coinPrice: poolPoint.coinPrice,
3847
- availableClaimAmount: availableClaimAmount.toNumber(),
3848
- availableClaimCoin: availableClaimCoin.toNumber(),
3849
- boostValue
3850
- });
3844
+ Object.entries(borrowIncentiveAccount.pointList).forEach(
3845
+ ([key, accountPoint]) => {
3846
+ const poolPoint = borrowIncentivePool.points[key];
3847
+ if (accountPoint && poolPoint) {
3848
+ let availableClaimAmount = BigNumber5(0);
3849
+ let availableClaimCoin = BigNumber5(0);
3850
+ const accountBorrowedAmount = BigNumber5(
3851
+ accountPoint.weightedAmount
3852
+ );
3853
+ const baseIndexRate = 1e9;
3854
+ const increasedPointRate = poolPoint.currentPointIndex ? Math.max(
3855
+ BigNumber5(poolPoint.currentPointIndex - accountPoint.index).dividedBy(baseIndexRate).toNumber(),
3856
+ 0
3857
+ ) : 1;
3858
+ availableClaimAmount = availableClaimAmount.plus(
3859
+ accountBorrowedAmount.multipliedBy(increasedPointRate).plus(accountPoint.points)
3860
+ );
3861
+ availableClaimCoin = availableClaimAmount.shiftedBy(
3862
+ -1 * poolPoint.coinDecimal
3863
+ );
3864
+ const weightScale = BigNumber5(1e12);
3865
+ const boostValue = BigNumber5(accountPoint.weightedAmount).div(
3866
+ BigNumber5(borrowIncentiveAccount.debtAmount).multipliedBy(poolPoint.baseWeight).dividedBy(weightScale)
3867
+ ).isFinite() ? BigNumber5(accountPoint.weightedAmount).div(
3868
+ BigNumber5(borrowIncentiveAccount.debtAmount).multipliedBy(poolPoint.baseWeight).dividedBy(weightScale)
3869
+ ).toNumber() : 1;
3870
+ if (availableClaimAmount.isGreaterThanOrEqualTo(0)) {
3871
+ rewards.push({
3872
+ coinName: poolPoint.coinName,
3873
+ coinType: poolPoint.coinType,
3874
+ symbol: poolPoint.symbol,
3875
+ coinDecimal: poolPoint.coinDecimal,
3876
+ coinPrice: poolPoint.coinPrice,
3877
+ availableClaimAmount: availableClaimAmount.toNumber(),
3878
+ availableClaimCoin: availableClaimCoin.toNumber(),
3879
+ boostValue
3880
+ });
3881
+ }
3851
3882
  }
3852
3883
  }
3853
- }
3884
+ );
3854
3885
  if (Object.keys(borrowIncentivePool.points).some((coinName2) => {
3855
3886
  const rewardApr = borrowIncentivePool.points[coinName2]?.rewardApr;
3856
3887
  return rewardApr !== Infinity && typeof rewardApr == "number" && rewardApr > 0;
@@ -3994,6 +4025,7 @@ var getTotalValueLocked = async (query, indexer = false) => {
3994
4025
  };
3995
4026
 
3996
4027
  // src/queries/priceQuery.ts
4028
+ import BigNumber6 from "bignumber.js";
3997
4029
  var getPythPrice = async ({
3998
4030
  address
3999
4031
  }, assetCoinName, priceFeedObject) => {
@@ -4075,6 +4107,22 @@ var getPythPrices = async ({
4075
4107
  {}
4076
4108
  );
4077
4109
  };
4110
+ var getAllCoinPrices = async (query, marketPools, coinPrices) => {
4111
+ coinPrices = coinPrices ?? await query.utils.getCoinPrices();
4112
+ marketPools = marketPools ?? await query.getMarketPools(void 0, { coinPrices });
4113
+ if (!marketPools) {
4114
+ throw new Error(`Failed to fetch market pool for getAllCoinPrices`);
4115
+ }
4116
+ const sCoinPrices = {};
4117
+ SUPPORT_SCOIN.forEach((sCoinName) => {
4118
+ const coinName = query.utils.parseCoinName(sCoinName);
4119
+ sCoinPrices[sCoinName] = BigNumber6(coinPrices[coinName] ?? 0).multipliedBy(marketPools[coinName]?.conversionRate ?? 1).toNumber();
4120
+ });
4121
+ return {
4122
+ ...coinPrices,
4123
+ ...sCoinPrices
4124
+ };
4125
+ };
4078
4126
 
4079
4127
  // src/queries/referralQuery.ts
4080
4128
  var queryVeScaKeyIdFromReferralBindings = async (address, refereeAddress) => {
@@ -4095,7 +4143,7 @@ var queryVeScaKeyIdFromReferralBindings = async (address, refereeAddress) => {
4095
4143
  // src/queries/sCoinQuery.ts
4096
4144
  import { bcs } from "@mysten/sui/bcs";
4097
4145
  import assert from "assert";
4098
- import BigNumber6 from "bignumber.js";
4146
+ import BigNumber7 from "bignumber.js";
4099
4147
  var getSCoinTotalSupply = async ({
4100
4148
  utils
4101
4149
  }, sCoinName) => {
@@ -4116,7 +4164,7 @@ var getSCoinTotalSupply = async ({
4116
4164
  const value = Uint8Array.from(results[0].returnValues[0][0]);
4117
4165
  const type = results[0].returnValues[0][1];
4118
4166
  assert(type === "u64", "Result type is not u64");
4119
- return BigNumber6(bcs.u64().parse(value)).shiftedBy(utils.getCoinDecimal(utils.parseCoinName(sCoinName))).toNumber();
4167
+ return BigNumber7(bcs.u64().parse(value)).shiftedBy(utils.getCoinDecimal(utils.parseCoinName(sCoinName))).toNumber();
4120
4168
  }
4121
4169
  return 0;
4122
4170
  };
@@ -4142,7 +4190,7 @@ var getSCoinAmount = async ({
4142
4190
  owner,
4143
4191
  coinType: sCoinType
4144
4192
  });
4145
- return BigNumber6(amount).toNumber();
4193
+ return BigNumber7(amount).toNumber();
4146
4194
  };
4147
4195
  var isSupportStakeCoins = (value) => {
4148
4196
  return SUPPORT_SCOIN.includes(value);
@@ -4172,7 +4220,7 @@ var getSCoinSwapRate = async (query, fromSCoin, toSCoin, underlyingCoinPrice) =>
4172
4220
  const ScoinAToARate = marketPools[0].conversionRate;
4173
4221
  const BtoSCoinBRate = 1 / marketPools[1].conversionRate;
4174
4222
  const calcAtoBRate = async () => {
4175
- const prices = await query.utils.getCoinPrices([fromCoinName, toCoinName]);
4223
+ const prices = await query.utils.getCoinPrices();
4176
4224
  if (!prices[fromCoinName] || !prices[toCoinName]) {
4177
4225
  throw new Error("Failed to fetch the coin prices");
4178
4226
  }
@@ -4182,7 +4230,7 @@ var getSCoinSwapRate = async (query, fromSCoin, toSCoin, underlyingCoinPrice) =>
4182
4230
  return prices[fromCoinName] / prices[toCoinName];
4183
4231
  };
4184
4232
  const AtoBRate = underlyingCoinPrice ?? await calcAtoBRate();
4185
- return BigNumber6(ScoinAToARate).multipliedBy(AtoBRate).multipliedBy(BtoSCoinBRate).toNumber();
4233
+ return BigNumber7(ScoinAToARate).multipliedBy(AtoBRate).multipliedBy(BtoSCoinBRate).toNumber();
4186
4234
  };
4187
4235
 
4188
4236
  // src/queries/spoolQuery.ts
@@ -4242,7 +4290,7 @@ var getSpool = async (query, marketCoinName, indexer = false, marketPool, coinPr
4242
4290
  `spool.pools.${marketCoinName}.rewardPoolId`
4243
4291
  );
4244
4292
  let spool = void 0;
4245
- coinPrices = coinPrices || await query.utils.getCoinPrices([coinName]);
4293
+ coinPrices = coinPrices || await query.utils.getCoinPrices();
4246
4294
  if (indexer) {
4247
4295
  const spoolIndexer = await query.indexer.getSpool(marketCoinName);
4248
4296
  const coinName2 = query.utils.parseCoinName(marketCoinName);
@@ -4262,7 +4310,7 @@ var getSpool = async (query, marketCoinName, indexer = false, marketPool, coinPr
4262
4310
  throw new Error("Fail to fetch spoolObjectResponse!");
4263
4311
  }
4264
4312
  const rewardCoinName = query.utils.getSpoolRewardCoinName(marketCoinName);
4265
- coinPrices = coinPrices || await query.utils.getCoinPrices([coinName, rewardCoinName]);
4313
+ coinPrices = coinPrices || await query.utils.getCoinPrices();
4266
4314
  const spoolObject = spoolObjectResponse[0];
4267
4315
  const rewardPoolObject = spoolObjectResponse[1];
4268
4316
  if (spoolObject.content && "fields" in spoolObject.content) {
@@ -4506,7 +4554,7 @@ var getStakeRewardPool = async ({
4506
4554
  };
4507
4555
 
4508
4556
  // src/queries/vescaQuery.ts
4509
- import BigNumber7 from "bignumber.js";
4557
+ import BigNumber8 from "bignumber.js";
4510
4558
  import { SUI_CLOCK_OBJECT_ID, SuiTxBlock as SuiTxBlock2 } from "@scallop-io/sui-kit";
4511
4559
  import { bcs as bcs2 } from "@mysten/sui/bcs";
4512
4560
  import { z as zod5 } from "zod";
@@ -4588,7 +4636,7 @@ var getVeSca = async (utils, veScaKey) => {
4588
4636
  0
4589
4637
  );
4590
4638
  const lockedScaAmount = String(dynamicFields.locked_sca_amount);
4591
- const lockedScaCoin = BigNumber7(dynamicFields.locked_sca_amount).shiftedBy(-9).toNumber();
4639
+ const lockedScaCoin = BigNumber8(dynamicFields.locked_sca_amount).shiftedBy(-9).toNumber();
4592
4640
  const currentVeScaBalance = lockedScaCoin * (Math.floor(remainingLockPeriodInMilliseconds / 1e3) / MAX_LOCK_DURATION);
4593
4641
  vesca = {
4594
4642
  id: veScaDynamicFieldObject.objectId,
@@ -4598,7 +4646,7 @@ var getVeSca = async (utils, veScaKey) => {
4598
4646
  lockedScaAmount,
4599
4647
  lockedScaCoin,
4600
4648
  currentVeScaBalance,
4601
- unlockAt: BigNumber7(dynamicFields.unlock_at * 1e3).toNumber()
4649
+ unlockAt: BigNumber8(dynamicFields.unlock_at * 1e3).toNumber()
4602
4650
  };
4603
4651
  }
4604
4652
  return vesca;
@@ -4660,10 +4708,10 @@ var getVeScaTreasuryInfo = async (utils) => {
4660
4708
  if (!veScaTreasury || veScaTreasury.data?.content?.dataType !== "moveObject")
4661
4709
  return null;
4662
4710
  const treasuryFields = veScaTreasury.data.content.fields;
4663
- const totalLockedSca = BigNumber7(
4711
+ const totalLockedSca = BigNumber8(
4664
4712
  treasuryFields.unlock_schedule.fields.locked_sca_amount
4665
4713
  ).shiftedBy(-9).toNumber();
4666
- const totalVeSca = BigNumber7(
4714
+ const totalVeSca = BigNumber8(
4667
4715
  await getTotalVeScaTreasuryAmount(utils, veScaTreasury.data) ?? 0
4668
4716
  ).shiftedBy(-9).toNumber();
4669
4717
  const averageLockingPeriod = totalLockedSca > 0 ? totalVeSca / totalLockedSca * 4 : 0;
@@ -4699,15 +4747,6 @@ var ScallopUtils = class {
4699
4747
  this.getSpoolRewardCoinName = (stakeMarketCoinName) => {
4700
4748
  return spoolRewardCoins[stakeMarketCoinName];
4701
4749
  };
4702
- /**
4703
- * Get reward type of borrow incentive pool.
4704
- *
4705
- * @param borrowIncentiveCoinName - Support borrow incentive coin.
4706
- * @return Borrow incentive reward coin name.
4707
- */
4708
- this.getBorrowIncentiveRewardCoinName = (borrowIncentiveCoinName) => {
4709
- return borrowIncentiveRewardCoins[borrowIncentiveCoinName];
4710
- };
4711
4750
  this.params = {
4712
4751
  pythEndpoints: params.pythEndpoints ?? PYTH_ENDPOINTS["mainnet"],
4713
4752
  ...params
@@ -4777,7 +4816,10 @@ var ScallopUtils = class {
4777
4816
  * @param coinName - Specific support coin name.
4778
4817
  * @return Coin type.
4779
4818
  */
4780
- parseCoinType(coinName) {
4819
+ parseCoinType(coinName, useOldMarketCoin = false) {
4820
+ if (sCoinIds[coinName] && !useOldMarketCoin) {
4821
+ return sCoinIds[coinName];
4822
+ }
4781
4823
  coinName = isMarketCoin(coinName) ? this.parseCoinName(coinName) : coinName;
4782
4824
  const coinPackageId = this.address.get(`core.coins.${coinName}.id`) || coinIds[coinName] || void 0;
4783
4825
  if (!coinPackageId) {
@@ -4832,6 +4874,15 @@ var ScallopUtils = class {
4832
4874
  return void 0;
4833
4875
  }
4834
4876
  }
4877
+ /**
4878
+ * Convert sCoin name to coin name.
4879
+ * This function will parse new sCoin name `scallop_...` to its old market coin name which is shorter
4880
+ * e.g: `scallop_sui -> ssui
4881
+ * @return sCoin name
4882
+ */
4883
+ parseCoinNameFromSCoinName(coinName) {
4884
+ return sCoinRawNameToName[coinName];
4885
+ }
4835
4886
  /**
4836
4887
  * Convert sCoin name into sCoin type
4837
4888
  * @param sCoinName
@@ -4874,7 +4925,7 @@ var ScallopUtils = class {
4874
4925
  */
4875
4926
  parseMarketCoinType(coinName) {
4876
4927
  const protocolObjectId = this.address.get("core.object") ?? PROTOCOL_OBJECT_ID;
4877
- const coinType = this.parseCoinType(coinName);
4928
+ const coinType = this.parseCoinType(coinName, true);
4878
4929
  return `${protocolObjectId}::reserve::MarketCoin<${coinType}>`;
4879
4930
  }
4880
4931
  parseCoinNameFromType(coinType) {
@@ -4883,7 +4934,7 @@ var ScallopUtils = class {
4883
4934
  const coinTypeMatch = coinType.match(coinTypeRegex);
4884
4935
  const isMarketCoinType = coinType.includes("reserve::MarketCoin");
4885
4936
  coinType = coinTypeMatch?.[1] ?? coinType;
4886
- const wormHoleCoinTypeMap = {
4937
+ const wormholeCoinTypeMap = {
4887
4938
  [`${this.address.get("core.coins.wusdc.id") ?? wormholeCoinIds.wusdc}::coin::COIN`]: "wusdc",
4888
4939
  [`${this.address.get("core.coins.wusdt.id") ?? wormholeCoinIds.wusdt}::coin::COIN`]: "wusdt",
4889
4940
  [`${this.address.get("core.coins.weth.id") ?? wormholeCoinIds.weth}::coin::COIN`]: "weth",
@@ -4903,7 +4954,7 @@ var ScallopUtils = class {
4903
4954
  },
4904
4955
  {}
4905
4956
  );
4906
- const assetCoinName = wormHoleCoinTypeMap[coinType] || voloCoinTypeMap[coinType] || suiBridgeTypeMap[coinType] || coinType.split("::")[2].toLowerCase();
4957
+ const assetCoinName = wormholeCoinTypeMap[coinType] || voloCoinTypeMap[coinType] || suiBridgeTypeMap[coinType] || coinType.split("::")[2].toLowerCase();
4907
4958
  return isMarketCoinType ? this.parseMarketCoinName(assetCoinName) : assetCoinName;
4908
4959
  }
4909
4960
  /**
@@ -6017,11 +6068,7 @@ var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
6017
6068
  ]
6018
6069
  );
6019
6070
  },
6020
- claimBorrowIncentive: (obligationId, obligationKey, coinName, rewardCoinName) => {
6021
- const rewardCoinNames = builder.utils.getBorrowIncentiveRewardCoinName(coinName);
6022
- if (rewardCoinNames.includes(rewardCoinName) === false) {
6023
- throw new Error(`Invalid reward coin name ${rewardCoinName}`);
6024
- }
6071
+ claimBorrowIncentive: (obligationId, obligationKey, rewardCoinName) => {
6025
6072
  const rewardType = builder.utils.parseCoinType(rewardCoinName);
6026
6073
  return txBlock.moveCall(
6027
6074
  `${borrowIncentiveIds.borrowIncentivePkg}::user::redeem_rewards`,
@@ -6114,7 +6161,7 @@ var generateBorrowIncentiveQuickMethod = ({ builder, txBlock }) => {
6114
6161
  txBlock.unstakeObligation(obligationArg, obligationKeyArg);
6115
6162
  }
6116
6163
  },
6117
- claimBorrowIncentiveQuick: async (coinName, rewardCoinName, obligation, obligationKey) => {
6164
+ claimBorrowIncentiveQuick: async (rewardCoinName, obligation, obligationKey) => {
6118
6165
  const { obligationId: obligationArg, obligationKey: obligationKeyArg } = await requireObligationInfo2(
6119
6166
  builder,
6120
6167
  txBlock,
@@ -6124,7 +6171,6 @@ var generateBorrowIncentiveQuickMethod = ({ builder, txBlock }) => {
6124
6171
  return txBlock.claimBorrowIncentive(
6125
6172
  obligationArg,
6126
6173
  obligationKeyArg,
6127
- coinName,
6128
6174
  rewardCoinName
6129
6175
  );
6130
6176
  }
@@ -7302,6 +7348,7 @@ var ScallopQuery = class {
7302
7348
  this,
7303
7349
  coinNames,
7304
7350
  args?.indexer,
7351
+ args?.marketPools,
7305
7352
  args?.coinPrices
7306
7353
  );
7307
7354
  }
@@ -7517,6 +7564,13 @@ var ScallopQuery = class {
7517
7564
  async getCoinPriceByIndexer(poolName) {
7518
7565
  return this.indexer.getCoinPrice(poolName);
7519
7566
  }
7567
+ /**
7568
+ * Get all coin prices, including sCoin
7569
+ * @returns prices data
7570
+ */
7571
+ async getAllCoinPrices(args) {
7572
+ return getAllCoinPrices(this, args?.marketPools, args?.coinPrices);
7573
+ }
7520
7574
  };
7521
7575
 
7522
7576
  // src/models/scallopBuilder.ts
@@ -8166,30 +8220,46 @@ var ScallopClient = class {
8166
8220
  }
8167
8221
  }
8168
8222
  /**
8169
- * unstake market coin from the specific spool.
8223
+ * Claim borrow incentive reward.
8170
8224
  *
8171
- * @param marketCoinName - Types of mak coin.
8225
+ * @param poolName
8172
8226
  * @param amount - The amount of coins would deposit.
8173
8227
  * @param sign - Decide to directly sign the transaction or return the transaction block.
8174
8228
  * @param accountId - The stake account object.
8175
8229
  * @param walletAddress - The wallet address of the owner.
8176
8230
  * @return Transaction block response or transaction block
8177
8231
  */
8178
- async claimBorrowIncentive(coinName, obligationId, obligationKeyId, sign = true, walletAddress) {
8232
+ async claimBorrowIncentive(obligationId, obligationKeyId, sign = true, walletAddress) {
8179
8233
  const txBlock = this.builder.createTxBlock();
8180
8234
  const sender = walletAddress ?? this.walletAddress;
8181
8235
  txBlock.setSender(sender);
8182
- const rewardCoins = [];
8183
- for (const rewardCoinName of SUPPORT_BORROW_INCENTIVE_REWARDS) {
8236
+ const rewardCoinsCollection = {};
8237
+ const obligationAccount = await this.query.getObligationAccount(obligationId);
8238
+ const rewardCoinNames = Object.values(obligationAccount.borrowIncentives).flatMap(
8239
+ ({ rewards }) => rewards.filter(({ availableClaimAmount }) => availableClaimAmount > 0)
8240
+ ).flatMap(({ coinName }) => coinName);
8241
+ for (const rewardCoinName of rewardCoinNames) {
8184
8242
  const rewardCoin = await txBlock.claimBorrowIncentiveQuick(
8185
- coinName,
8186
8243
  rewardCoinName,
8187
8244
  obligationId,
8188
8245
  obligationKeyId
8189
8246
  );
8190
- rewardCoins.push(rewardCoin);
8247
+ if (!rewardCoinsCollection[rewardCoinName]) {
8248
+ rewardCoinsCollection[rewardCoinName] = [rewardCoin];
8249
+ } else {
8250
+ rewardCoinsCollection[rewardCoinName].push(rewardCoin);
8251
+ }
8191
8252
  }
8192
- txBlock.transferObjects(rewardCoins, sender);
8253
+ txBlock.transferObjects(
8254
+ Object.values(rewardCoinsCollection).map((rewardCoins) => {
8255
+ const mergeDest = rewardCoins[0];
8256
+ if (rewardCoins.length > 1) {
8257
+ txBlock.mergeCoins(mergeDest, rewardCoins.slice(1));
8258
+ }
8259
+ return mergeDest;
8260
+ }),
8261
+ sender
8262
+ );
8193
8263
  if (sign) {
8194
8264
  return await this.suiKit.signAndSendTxn(
8195
8265
  txBlock
@@ -8498,12 +8568,12 @@ export {
8498
8568
  UNLOCK_ROUND_DURATION,
8499
8569
  USE_TEST_ADDRESS,
8500
8570
  assetCoins,
8501
- borrowIncentiveRewardCoins,
8502
8571
  coinDecimals,
8503
8572
  coinIds,
8504
8573
  marketCoins,
8505
8574
  queryKeys,
8506
8575
  sCoinIds,
8576
+ sCoinRawNameToName,
8507
8577
  sCoinTypeToName,
8508
8578
  sCoins,
8509
8579
  spoolRewardCoins,