@scallop-io/sui-scallop-sdk 1.3.4-isolated-asset.2 → 1.3.5-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.
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
@@ -33,7 +34,7 @@ var API_BASE_URL = "https://sui.apis.scallop.io";
33
34
  var SDK_API_BASE_URL = "https://sdk.api.scallop.io";
34
35
  var IS_VE_SCA_TEST = false;
35
36
  var USE_TEST_ADDRESS = false;
36
- var ADDRESSES_ID = IS_VE_SCA_TEST || USE_TEST_ADDRESS ? "65fb07c39c845425d71d7b18" : "66f8e7ed9bb9e07fdfb86bbb";
37
+ var ADDRESSES_ID = IS_VE_SCA_TEST || USE_TEST_ADDRESS ? "65fb07c39c845425d71d7b18" : "675c65cd301dd817ea262e76";
37
38
  var PROTOCOL_OBJECT_ID = IS_VE_SCA_TEST ? "0xc9f859f98ca352a11b97a038c4b4162bee437b8df8caa047990fe9cb03d4f778" : "0xefe8b36d5b2e43728cc323298626b83177803521d195cfb11e15b910e892fddf";
38
39
  var BORROW_FEE_PROTOCOL_ID = IS_VE_SCA_TEST ? "0xc9f859f98ca352a11b97a038c4b4162bee437b8df8caa047990fe9cb03d4f778" : "0xc38f849e81cfe46d4e4320f508ea7dda42934a329d5a6571bb4c3cb6ea63f5da";
39
40
  var SCA_COIN_TYPE = IS_VE_SCA_TEST ? `0x6cd813061a3adf3602b76545f076205f0c8e7ec1d3b1eab9a1da7992c18c0524::sca::SCA` : "0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6::sca::SCA";
@@ -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",
@@ -101,6 +103,9 @@ var SUPPORT_SCOIN = [
101
103
  "scetus",
102
104
  "swsol",
103
105
  "swbtc"
106
+ // TODO: enable for production
107
+ // 'sdeep',
108
+ // 'sfud',
104
109
  ];
105
110
  var SUPPORT_SUI_BRIDGE = ["sbeth"];
106
111
  var SUPPORT_WORMHOLE = [
@@ -124,7 +129,10 @@ var SUPPORT_BORROW_INCENTIVE_POOLS = [
124
129
  "sca",
125
130
  "usdc"
126
131
  ];
127
- var SUPPORT_BORROW_INCENTIVE_REWARDS = ["sui", "sca"];
132
+ var SUPPORT_BORROW_INCENTIVE_REWARDS = [
133
+ ...SUPPORT_POOLS,
134
+ ...SUPPORT_SCOIN
135
+ ];
128
136
  var SUPPORT_ORACLES = ["supra", "switchboard", "pyth"];
129
137
  var SUPPORT_PACKAGES = [
130
138
  "coinDecimalsRegistry",
@@ -157,8 +165,9 @@ var coinDecimals = {
157
165
  hasui: 9,
158
166
  vsui: 9,
159
167
  sca: 9,
160
- deep: 6,
161
- fud: 5,
168
+ // TODO: enable for production
169
+ // deep: 6,
170
+ // fud: 5,
162
171
  susdc: 6,
163
172
  sweth: 8,
164
173
  ssbeth: 8,
@@ -172,9 +181,10 @@ var coinDecimals = {
172
181
  safsui: 9,
173
182
  shasui: 9,
174
183
  svsui: 9,
175
- ssca: 9,
176
- sdeep: 6,
177
- sfud: 5
184
+ ssca: 9
185
+ // TODO: enable for production
186
+ // sdeep: 6,
187
+ // sfud: 5,
178
188
  };
179
189
  var assetCoins = {
180
190
  usdc: "usdc",
@@ -190,9 +200,10 @@ var assetCoins = {
190
200
  afsui: "afsui",
191
201
  hasui: "hasui",
192
202
  vsui: "vsui",
193
- sca: "sca",
194
- deep: "deep",
195
- fud: "fud"
203
+ sca: "sca"
204
+ // TODO: enable for production
205
+ // deep: 'deep',
206
+ // fud: 'fud',
196
207
  };
197
208
  var marketCoins = {
198
209
  susdc: "susdc",
@@ -208,9 +219,10 @@ var marketCoins = {
208
219
  safsui: "safsui",
209
220
  shasui: "shasui",
210
221
  svsui: "svsui",
211
- ssca: "ssca",
212
- sdeep: "sdeep",
213
- sfud: "sfud"
222
+ ssca: "ssca"
223
+ // TODO: enable for production
224
+ // sdeep: 'sdeep',
225
+ // sfud: 'sfud',
214
226
  };
215
227
  var sCoins = {
216
228
  susdc: "susdc",
@@ -226,6 +238,9 @@ var sCoins = {
226
238
  ssca: "ssca",
227
239
  swsol: "swsol",
228
240
  swbtc: "swbtc"
241
+ // TODO: enable for production
242
+ // sfud: 'sfud',
243
+ // sdeep: 'sdeep',
229
244
  };
230
245
  var stakeMarketCoins = {
231
246
  susdc: "susdc",
@@ -253,16 +268,16 @@ var suiBridgeCoins = {
253
268
  sbeth: "sbeth"
254
269
  };
255
270
  var borrowIncentiveRewardCoins = {
256
- usdc: ["sui", "sca"],
257
- sui: ["sui", "sca"],
258
- wusdc: ["sui", "sca"],
259
- wusdt: ["sui", "sca"],
260
- sca: ["sui", "sca"],
261
- afsui: ["sui"],
262
- hasui: ["sui"],
263
- vsui: ["sui"],
264
- weth: ["sui"],
265
- sbeth: ["sui"]
271
+ usdc: ["ssui", "ssca"],
272
+ sui: ["ssui", "ssca"],
273
+ wusdc: ["ssui", "ssca"],
274
+ wusdt: ["ssui", "ssca"],
275
+ sca: ["ssui", "ssca"],
276
+ afsui: ["ssui"],
277
+ hasui: ["ssui"],
278
+ vsui: ["ssui"],
279
+ weth: ["ssui"],
280
+ sbeth: ["ssui"]
266
281
  };
267
282
  var coinIds = {
268
283
  usdc: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7",
@@ -278,10 +293,10 @@ var coinIds = {
278
293
  afsui: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc",
279
294
  hasui: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d",
280
295
  vsui: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55",
281
- sca: IS_VE_SCA_TEST ? "0x6cd813061a3adf3602b76545f076205f0c8e7ec1d3b1eab9a1da7992c18c0524" : "0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6",
296
+ sca: IS_VE_SCA_TEST ? "0x6cd813061a3adf3602b76545f076205f0c8e7ec1d3b1eab9a1da7992c18c0524" : "0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6"
282
297
  // isolated assets
283
- deep: "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP",
284
- fud: "0x76cb819b01abed502bee8a702b4c2d547532c12f25001c9dea795a5e631c26f1::fud::FUD"
298
+ // deep: '0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270',
299
+ // fud: '0x76cb819b01abed502bee8a702b4c2d547532c12f25001c9dea795a5e631c26f1',
285
300
  };
286
301
  var wormholeCoinIds = {
287
302
  weth: "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5",
@@ -297,33 +312,28 @@ var voloCoinIds = {
297
312
  var sCoinIds = {
298
313
  susdc: "0x854950aa624b1df59fe64e630b2ba7c550642e9342267a33061d59fb31582da5::scallop_usdc::SCALLOP_USDC",
299
314
  ssbeth: "0xb14f82d8506d139eacef109688d1b71e7236bcce9b2c0ad526abcd6aa5be7de0::scallop_sb_eth::SCALLOP_SB_ETH",
300
- ssui: (
301
- // TODO: use prod value
302
- // '0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI',
303
- "0xf569919046f19a0c40b519ecfbb6ca0319698cd5908716c29b62ef56541f298b::scallop_sui::SCALLOP_SUI"
304
- ),
315
+ // prod values
316
+ // ssui: '0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI',
317
+ // swusdc:
318
+ // '0xad4d71551d31092230db1fd482008ea42867dbf27b286e9c70a79d2a6191d58d::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC',
319
+ // swusdt:
320
+ // '0xe6e5a012ec20a49a3d1d57bd2b67140b96cd4d3400b9d79e541f7bdbab661f95::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT',
321
+ // ssca: '0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA',
322
+ // test values
323
+ ssui: "0xf569919046f19a0c40b519ecfbb6ca0319698cd5908716c29b62ef56541f298b::scallop_sui::SCALLOP_SUI",
324
+ swusdt: "0xac781d9f73058ff5e69f9bf8dde32f2e8c71c66d7fe8497fc83b2d9182254b22::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT",
325
+ swusdc: "0xf5447c4305a486d8c8557559887c2c39449ddb5e748f15d33946d02a1663c158::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC",
326
+ ssca: "0x958428555e778e55918a59eb1c92c77f32b5c554fa3a5e56cd0815086b5072e7::scallop_sca::SCALLOP_SCA",
305
327
  scetus: "0xea346ce428f91ab007210443efcea5f5cdbbb3aae7e9affc0ca93f9203c31f0c::scallop_cetus::SCALLOP_CETUS",
306
- ssca: (
307
- // TODO: use prod value
308
- // '0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA',
309
- "0x958428555e778e55918a59eb1c92c77f32b5c554fa3a5e56cd0815086b5072e7::scallop_sca::SCALLOP_SCA"
310
- ),
311
- swusdc: (
312
- // TODO: use prod value
313
- // '0xad4d71551d31092230db1fd482008ea42867dbf27b286e9c70a79d2a6191d58d::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC',
314
- "0xf5447c4305a486d8c8557559887c2c39449ddb5e748f15d33946d02a1663c158::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC"
315
- ),
316
- swusdt: (
317
- // TODO: use prod value
318
- // '0xe6e5a012ec20a49a3d1d57bd2b67140b96cd4d3400b9d79e541f7bdbab661f95::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT',
319
- "0xac781d9f73058ff5e69f9bf8dde32f2e8c71c66d7fe8497fc83b2d9182254b22::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT"
320
- ),
321
328
  sweth: "0x67540ceb850d418679e69f1fb6b2093d6df78a2a699ffc733f7646096d552e9b::scallop_wormhole_eth::SCALLOP_WORMHOLE_ETH",
322
329
  safsui: "0x00671b1fa2a124f5be8bdae8b91ee711462c5d9e31bda232e70fd9607b523c88::scallop_af_sui::SCALLOP_AF_SUI",
323
330
  shasui: "0x9a2376943f7d22f88087c259c5889925f332ca4347e669dc37d54c2bf651af3c::scallop_ha_sui::SCALLOP_HA_SUI",
324
331
  svsui: "0xe1a1cc6bcf0001a015eab84bcc6713393ce20535f55b8b6f35c142e057a25fbe::scallop_v_sui::SCALLOP_V_SUI",
325
332
  swsol: "0x1392650f2eca9e3f6ffae3ff89e42a3590d7102b80e2b430f674730bc30d3259::scallop_wormhole_sol::SCALLOP_WORMHOLE_SOL",
326
333
  swbtc: "0x2cf76a9cf5d3337961d1154283234f94da2dcff18544dfe5cbdef65f319591b5::scallop_wormhole_btc::SCALLOP_WORMHOLE_BTC"
334
+ // sdeep:
335
+ // '0xeb7a05a3224837c5e5503575aed0be73c091d1ce5e43aa3c3e716e0ae614608f::scallop_deep::SCALLOP_DEEP',
336
+ // sfud: '0xe56d5167f427cbe597da9e8150ef5c337839aaf46891d62468dcf80bdd8e10d1::scallop_fud::SCALLOP_FUD',
327
337
  };
328
338
  var sCoinTypeToName = Object.entries(sCoinIds).reduce(
329
339
  (acc, [coinName, coinType]) => {
@@ -332,6 +342,13 @@ var sCoinTypeToName = Object.entries(sCoinIds).reduce(
332
342
  },
333
343
  {}
334
344
  );
345
+ var sCoinRawNameToName = Object.entries(sCoinIds).reduce(
346
+ (acc, [coinName, coinType]) => {
347
+ acc[coinType.split("::")[2].toLowerCase()] = coinName;
348
+ return acc;
349
+ },
350
+ {}
351
+ );
335
352
 
336
353
  // src/constants/flashloan.ts
337
354
  var FlashLoanFeeObjectMap = {
@@ -406,13 +423,16 @@ var POOL_ADDRESSES = {
406
423
  sca: {
407
424
  lendingPoolAddress: "0x6fc7d4211fc7018b6c75e7b908b88f2e0536443239804a3d32af547637bd28d7",
408
425
  collateralPoolAddress: "0xff677a5d9e9dc8f08f0a8681ebfc7481d1c7d57bc441f2881974adcdd7b13c31"
409
- },
410
- fud: {
411
- lendingPoolAddress: ""
412
- },
413
- deep: {
414
- lendingPoolAddress: ""
415
426
  }
427
+ // TODO: enable for production
428
+ // fud: {
429
+ // lendingPoolAddress:
430
+ // '0x14367ddca30e2860cb89ed4eaca20c7ece260c5d59dd9990d2c85a8321326acb',
431
+ // },
432
+ // deep: {
433
+ // lendingPoolAddress:
434
+ // '0xf4a67ffb43da1e1c61c049f188f19463ea8dbbf2d5ef4722d6df854ff1b1cc03',
435
+ // },
416
436
  };
417
437
 
418
438
  // src/constants/pyth.ts
@@ -434,9 +454,10 @@ var PYTH_FEED_IDS = {
434
454
  afsui: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
435
455
  hasui: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
436
456
  vsui: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
437
- sca: "7e17f0ac105abe9214deb9944c30264f5986bf292869c6bd8e8da3ccd92d79bc",
438
- deep: "29bdd5248234e33bd93d3b81100b5fa32eaa5997843847e2c2cb16d7c6d9f7ff",
439
- fud: "6a4090703da959247727f2b490eb21aea95c8684ecfac675f432008830890c75"
457
+ sca: "7e17f0ac105abe9214deb9944c30264f5986bf292869c6bd8e8da3ccd92d79bc"
458
+ // TODO: enable for production
459
+ // deep: '29bdd5248234e33bd93d3b81100b5fa32eaa5997843847e2c2cb16d7c6d9f7ff',
460
+ // fud: '6a4090703da959247727f2b490eb21aea95c8684ecfac675f432008830890c75',
440
461
  };
441
462
 
442
463
  // src/constants/queryKeys.ts
@@ -961,7 +982,7 @@ var TEST_ADDRESSES = {
961
982
  };
962
983
 
963
984
  // src/constants/tokenBucket.ts
964
- var DEFAULT_TOKENS_PER_INTERVAL = 10;
985
+ var DEFAULT_TOKENS_PER_INTERVAL = 50;
965
986
  var DEFAULT_INTERVAL_IN_MS = 300;
966
987
 
967
988
  // src/constants/vesca.ts
@@ -2476,15 +2497,22 @@ var queryBorrowIncentivePools = async (address) => {
2476
2497
  };
2477
2498
  var getBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
2478
2499
  ...SUPPORT_BORROW_INCENTIVE_POOLS
2479
- ], indexer = false, coinPrices) => {
2500
+ ], indexer = false, marketPools, coinPrices) => {
2480
2501
  const borrowIncentivePools = {};
2481
- coinPrices = coinPrices ?? await query.utils.getCoinPrices() ?? {};
2502
+ marketPools = marketPools ?? await query.getMarketPools(void 0, false, { coinPrices });
2503
+ coinPrices = coinPrices ?? await query.getAllCoinPrices({ marketPools });
2504
+ console.log({ coinPrices });
2482
2505
  if (indexer) {
2483
2506
  const borrowIncentivePoolsIndexer = await query.indexer.getBorrowIncentivePools();
2484
2507
  const updateBorrowIncentivePool = (pool) => {
2485
2508
  if (!borrowIncentiveCoinNames.includes(pool.coinName))
2486
2509
  return;
2487
- pool.coinPrice = coinPrices[pool.coinName] ?? pool.coinPrice;
2510
+ pool.coinPrice = coinPrices[pool.coinName] || pool.coinPrice;
2511
+ for (const sCoinName of SUPPORT_BORROW_INCENTIVE_REWARDS) {
2512
+ if (pool.points[sCoinName]) {
2513
+ pool.points[sCoinName].coinPrice = coinPrices[sCoinName] ?? pool.points[sCoinName].coinPrice;
2514
+ }
2515
+ }
2488
2516
  borrowIncentivePools[pool.coinName] = pool;
2489
2517
  };
2490
2518
  Object.values(borrowIncentivePoolsIndexer).forEach(
@@ -2510,12 +2538,15 @@ var getBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
2510
2538
  for (const [coinName, poolPoint] of Object.entries(
2511
2539
  parsedBorrowIncentivePoolData.poolPoints
2512
2540
  )) {
2513
- const rewardCoinType = normalizeStructTag3(poolPoint.pointType);
2514
- const rewardCoinName = query.utils.parseCoinNameFromType(
2541
+ const rewardCoinType = poolPoint.pointType;
2542
+ let rewardCoinName = query.utils.parseCoinNameFromType(
2515
2543
  rewardCoinType
2516
2544
  );
2517
- const rewardCoinPrice = coinPrices?.[rewardCoinName] ?? 0;
2545
+ if (sCoinRawNameToName[rewardCoinName]) {
2546
+ rewardCoinName = sCoinRawNameToName[rewardCoinName];
2547
+ }
2518
2548
  const rewardCoinDecimal = query.utils.getCoinDecimal(rewardCoinName);
2549
+ const rewardCoinPrice = coinPrices?.[rewardCoinName] ?? 0;
2519
2550
  const symbol = query.utils.parseSymbol(rewardCoinName);
2520
2551
  const coinDecimal = query.utils.getCoinDecimal(rewardCoinName);
2521
2552
  const calculatedPoolPoint = calculateBorrowIncentivePoolPointData(
@@ -2948,7 +2979,7 @@ var getMarketPools = async (query, poolCoinNames = [...SUPPORT_POOLS], indexer =
2948
2979
  const marketObjectResponse = await query.cache.queryGetObject(marketId, {
2949
2980
  showContent: true
2950
2981
  });
2951
- coinPrices = await query.utils.getCoinPrices(poolCoinNames) ?? {};
2982
+ coinPrices = coinPrices ?? await query.utils.getCoinPrices();
2952
2983
  const marketPools = {};
2953
2984
  if (indexer) {
2954
2985
  const marketPoolsIndexer = await query.indexer.getMarketPools();
@@ -2982,7 +3013,7 @@ var getMarketPools = async (query, poolCoinNames = [...SUPPORT_POOLS], indexer =
2982
3013
  };
2983
3014
  var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, coinPrice) => {
2984
3015
  try {
2985
- coinPrice = coinPrice || (await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName];
3016
+ coinPrice = coinPrice ?? (await query.utils.getCoinPrices())?.[poolCoinName];
2986
3017
  if (indexer) {
2987
3018
  const marketPoolIndexer = await query.indexer.getMarketPool(poolCoinName);
2988
3019
  if (!marketPoolIndexer) {
@@ -3128,7 +3159,7 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
3128
3159
  };
3129
3160
  var getMarketCollaterals = async (query, collateralCoinNames = [...SUPPORT_COLLATERALS], indexer = false) => {
3130
3161
  const marketId = query.address.get("core.market");
3131
- const coinPrices = await query.utils.getCoinPrices(collateralCoinNames) ?? {};
3162
+ const coinPrices = await query.utils.getCoinPrices() ?? {};
3132
3163
  const marketCollaterals = {};
3133
3164
  if (indexer) {
3134
3165
  const marketCollateralsIndexer = await query.indexer.getMarketCollaterals();
@@ -3164,7 +3195,7 @@ var getMarketCollaterals = async (query, collateralCoinNames = [...SUPPORT_COLLA
3164
3195
  return marketCollaterals;
3165
3196
  };
3166
3197
  var getMarketCollateral = async (query, collateralCoinName, indexer = false, marketObject, coinPrice) => {
3167
- coinPrice = coinPrice || (await query.utils.getCoinPrices([collateralCoinName]))?.[collateralCoinName];
3198
+ coinPrice = coinPrice ?? (await query.utils.getCoinPrices())?.[collateralCoinName];
3168
3199
  if (indexer) {
3169
3200
  const marketCollateralIndexer = await query.indexer.getMarketCollateral(collateralCoinName);
3170
3201
  marketCollateralIndexer.coinPrice = coinPrice ?? marketCollateralIndexer.coinPrice;
@@ -3480,7 +3511,7 @@ var getLendings = async (query, poolCoinNames = [...SUPPORT_POOLS], ownerAddress
3480
3511
  const stakeMarketCoinNames = marketCoinNames.filter(
3481
3512
  (marketCoinName) => SUPPORT_SPOOLS.includes(marketCoinName)
3482
3513
  );
3483
- const coinPrices = await query.utils.getCoinPrices(poolCoinNames);
3514
+ const coinPrices = await query.utils.getCoinPrices();
3484
3515
  const marketPools = await query.getMarketPools(poolCoinNames, indexer, {
3485
3516
  coinPrices
3486
3517
  });
@@ -3518,7 +3549,7 @@ var getLendings = async (query, poolCoinNames = [...SUPPORT_POOLS], ownerAddress
3518
3549
  };
3519
3550
  var getLending = async (query, poolCoinName, ownerAddress, indexer = false, marketPool, spool, stakeAccounts, coinAmount, marketCoinAmount, coinPrice, sCoinAmount) => {
3520
3551
  const marketCoinName = query.utils.parseMarketCoinName(poolCoinName);
3521
- coinPrice = coinPrice ?? (await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName] ?? 0;
3552
+ coinPrice = coinPrice ?? (await query.utils.getCoinPrices())?.[poolCoinName] ?? 0;
3522
3553
  marketPool = marketPool ?? await query.getMarketPool(poolCoinName, indexer, {
3523
3554
  coinPrice
3524
3555
  });
@@ -3678,7 +3709,7 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
3678
3709
  const collateralAssetCoinNames = [
3679
3710
  ...SUPPORT_COLLATERALS
3680
3711
  ];
3681
- coinPrices = coinPrices ?? await query.utils.getCoinPrices(collateralAssetCoinNames);
3712
+ coinPrices = coinPrices ?? await query.utils.getCoinPrices();
3682
3713
  market = market ?? await query.queryMarket(indexer, { coinPrices });
3683
3714
  coinAmounts = coinAmounts || await query.getCoinAmounts(collateralAssetCoinNames, ownerAddress);
3684
3715
  const [obligationQuery, borrowIncentivePools, borrowIncentiveAccounts] = await Promise.all([
@@ -4001,6 +4032,7 @@ var getTotalValueLocked = async (query, indexer = false) => {
4001
4032
  };
4002
4033
 
4003
4034
  // src/queries/priceQuery.ts
4035
+ import BigNumber6 from "bignumber.js";
4004
4036
  var getPythPrice = async ({
4005
4037
  address
4006
4038
  }, assetCoinName, priceFeedObject) => {
@@ -4039,10 +4071,12 @@ var getPythPrices = async ({
4039
4071
  const pythPriceFeed = address.get(
4040
4072
  `core.coins.${assetCoinName}.oracle.pyth.feedObject`
4041
4073
  );
4042
- if (!prev[pythPriceFeed]) {
4043
- prev[pythPriceFeed] = [assetCoinName];
4044
- } else {
4045
- prev[pythPriceFeed].push(assetCoinName);
4074
+ if (pythPriceFeed) {
4075
+ if (!prev[pythPriceFeed]) {
4076
+ prev[pythPriceFeed] = [assetCoinName];
4077
+ } else {
4078
+ prev[pythPriceFeed].push(assetCoinName);
4079
+ }
4046
4080
  }
4047
4081
  return prev;
4048
4082
  },
@@ -4080,6 +4114,22 @@ var getPythPrices = async ({
4080
4114
  {}
4081
4115
  );
4082
4116
  };
4117
+ var getAllCoinPrices = async (query, marketPools, coinPrices) => {
4118
+ coinPrices = coinPrices ?? await query.utils.getCoinPrices();
4119
+ marketPools = marketPools ?? await query.getMarketPools(void 0, void 0, { coinPrices });
4120
+ if (!marketPools) {
4121
+ throw new Error(`Failed to fetch market pool for getAllCoinPrices`);
4122
+ }
4123
+ const sCoinPrices = {};
4124
+ SUPPORT_SCOIN.forEach((sCoinName) => {
4125
+ const coinName = query.utils.parseCoinName(sCoinName);
4126
+ sCoinPrices[sCoinName] = BigNumber6(coinPrices[coinName] ?? 0).multipliedBy(marketPools[coinName]?.conversionRate ?? 1).toNumber();
4127
+ });
4128
+ return {
4129
+ ...coinPrices,
4130
+ ...sCoinPrices
4131
+ };
4132
+ };
4083
4133
 
4084
4134
  // src/queries/referralQuery.ts
4085
4135
  var queryVeScaKeyIdFromReferralBindings = async (address, refereeAddress) => {
@@ -4100,7 +4150,7 @@ var queryVeScaKeyIdFromReferralBindings = async (address, refereeAddress) => {
4100
4150
  // src/queries/sCoinQuery.ts
4101
4151
  import { bcs } from "@mysten/sui/bcs";
4102
4152
  import assert from "assert";
4103
- import BigNumber6 from "bignumber.js";
4153
+ import BigNumber7 from "bignumber.js";
4104
4154
  var getSCoinTotalSupply = async ({
4105
4155
  utils
4106
4156
  }, sCoinName) => {
@@ -4121,7 +4171,7 @@ var getSCoinTotalSupply = async ({
4121
4171
  const value = Uint8Array.from(results[0].returnValues[0][0]);
4122
4172
  const type = results[0].returnValues[0][1];
4123
4173
  assert(type === "u64", "Result type is not u64");
4124
- return BigNumber6(bcs.u64().parse(value)).shiftedBy(utils.getCoinDecimal(utils.parseCoinName(sCoinName))).toNumber();
4174
+ return BigNumber7(bcs.u64().parse(value)).shiftedBy(utils.getCoinDecimal(utils.parseCoinName(sCoinName))).toNumber();
4125
4175
  }
4126
4176
  return 0;
4127
4177
  };
@@ -4147,7 +4197,7 @@ var getSCoinAmount = async ({
4147
4197
  owner,
4148
4198
  coinType: sCoinType
4149
4199
  });
4150
- return BigNumber6(amount).toNumber();
4200
+ return BigNumber7(amount).toNumber();
4151
4201
  };
4152
4202
  var isSupportStakeCoins = (value) => {
4153
4203
  return SUPPORT_SCOIN.includes(value);
@@ -4177,7 +4227,7 @@ var getSCoinSwapRate = async (query, fromSCoin, toSCoin, underlyingCoinPrice) =>
4177
4227
  const ScoinAToARate = marketPools[0].conversionRate;
4178
4228
  const BtoSCoinBRate = 1 / marketPools[1].conversionRate;
4179
4229
  const calcAtoBRate = async () => {
4180
- const prices = await query.utils.getCoinPrices([fromCoinName, toCoinName]);
4230
+ const prices = await query.utils.getCoinPrices();
4181
4231
  if (!prices[fromCoinName] || !prices[toCoinName]) {
4182
4232
  throw new Error("Failed to fetch the coin prices");
4183
4233
  }
@@ -4187,7 +4237,7 @@ var getSCoinSwapRate = async (query, fromSCoin, toSCoin, underlyingCoinPrice) =>
4187
4237
  return prices[fromCoinName] / prices[toCoinName];
4188
4238
  };
4189
4239
  const AtoBRate = underlyingCoinPrice ?? await calcAtoBRate();
4190
- return BigNumber6(ScoinAToARate).multipliedBy(AtoBRate).multipliedBy(BtoSCoinBRate).toNumber();
4240
+ return BigNumber7(ScoinAToARate).multipliedBy(AtoBRate).multipliedBy(BtoSCoinBRate).toNumber();
4191
4241
  };
4192
4242
 
4193
4243
  // src/queries/spoolQuery.ts
@@ -4247,7 +4297,7 @@ var getSpool = async (query, marketCoinName, indexer = false, marketPool, coinPr
4247
4297
  `spool.pools.${marketCoinName}.rewardPoolId`
4248
4298
  );
4249
4299
  let spool = void 0;
4250
- coinPrices = coinPrices || await query.utils.getCoinPrices([coinName]);
4300
+ coinPrices = coinPrices || await query.utils.getCoinPrices();
4251
4301
  if (indexer) {
4252
4302
  const spoolIndexer = await query.indexer.getSpool(marketCoinName);
4253
4303
  const coinName2 = query.utils.parseCoinName(marketCoinName);
@@ -4267,7 +4317,7 @@ var getSpool = async (query, marketCoinName, indexer = false, marketPool, coinPr
4267
4317
  throw new Error("Fail to fetch spoolObjectResponse!");
4268
4318
  }
4269
4319
  const rewardCoinName = query.utils.getSpoolRewardCoinName(marketCoinName);
4270
- coinPrices = coinPrices || await query.utils.getCoinPrices([coinName, rewardCoinName]);
4320
+ coinPrices = coinPrices || await query.utils.getCoinPrices();
4271
4321
  const spoolObject = spoolObjectResponse[0];
4272
4322
  const rewardPoolObject = spoolObjectResponse[1];
4273
4323
  if (spoolObject.content && "fields" in spoolObject.content) {
@@ -4511,7 +4561,7 @@ var getStakeRewardPool = async ({
4511
4561
  };
4512
4562
 
4513
4563
  // src/queries/vescaQuery.ts
4514
- import BigNumber7 from "bignumber.js";
4564
+ import BigNumber8 from "bignumber.js";
4515
4565
  import { SUI_CLOCK_OBJECT_ID, SuiTxBlock as SuiTxBlock2 } from "@scallop-io/sui-kit";
4516
4566
  import { bcs as bcs2 } from "@mysten/sui/bcs";
4517
4567
  import { z as zod5 } from "zod";
@@ -4593,7 +4643,7 @@ var getVeSca = async (utils, veScaKey) => {
4593
4643
  0
4594
4644
  );
4595
4645
  const lockedScaAmount = String(dynamicFields.locked_sca_amount);
4596
- const lockedScaCoin = BigNumber7(dynamicFields.locked_sca_amount).shiftedBy(-9).toNumber();
4646
+ const lockedScaCoin = BigNumber8(dynamicFields.locked_sca_amount).shiftedBy(-9).toNumber();
4597
4647
  const currentVeScaBalance = lockedScaCoin * (Math.floor(remainingLockPeriodInMilliseconds / 1e3) / MAX_LOCK_DURATION);
4598
4648
  vesca = {
4599
4649
  id: veScaDynamicFieldObject.objectId,
@@ -4603,7 +4653,7 @@ var getVeSca = async (utils, veScaKey) => {
4603
4653
  lockedScaAmount,
4604
4654
  lockedScaCoin,
4605
4655
  currentVeScaBalance,
4606
- unlockAt: BigNumber7(dynamicFields.unlock_at * 1e3).toNumber()
4656
+ unlockAt: BigNumber8(dynamicFields.unlock_at * 1e3).toNumber()
4607
4657
  };
4608
4658
  }
4609
4659
  return vesca;
@@ -4665,10 +4715,10 @@ var getVeScaTreasuryInfo = async (utils) => {
4665
4715
  if (!veScaTreasury || veScaTreasury.data?.content?.dataType !== "moveObject")
4666
4716
  return null;
4667
4717
  const treasuryFields = veScaTreasury.data.content.fields;
4668
- const totalLockedSca = BigNumber7(
4718
+ const totalLockedSca = BigNumber8(
4669
4719
  treasuryFields.unlock_schedule.fields.locked_sca_amount
4670
4720
  ).shiftedBy(-9).toNumber();
4671
- const totalVeSca = BigNumber7(
4721
+ const totalVeSca = BigNumber8(
4672
4722
  await getTotalVeScaTreasuryAmount(utils, veScaTreasury.data) ?? 0
4673
4723
  ).shiftedBy(-9).toNumber();
4674
4724
  const averageLockingPeriod = totalLockedSca > 0 ? totalVeSca / totalLockedSca * 4 : 0;
@@ -4837,6 +4887,15 @@ var ScallopUtils = class {
4837
4887
  return void 0;
4838
4888
  }
4839
4889
  }
4890
+ /**
4891
+ * Convert sCoin name to coin name.
4892
+ * This function will parse new sCoin name `scallop_...` to its old market coin name which is shorter
4893
+ * e.g: `scallop_sui -> ssui
4894
+ * @return sCoin name
4895
+ */
4896
+ parseCoinNameFromSCoinName(coinName) {
4897
+ return sCoinRawNameToName[coinName];
4898
+ }
4840
4899
  /**
4841
4900
  * Convert sCoin name into sCoin type
4842
4901
  * @param sCoinName
@@ -4888,7 +4947,7 @@ var ScallopUtils = class {
4888
4947
  const coinTypeMatch = coinType.match(coinTypeRegex);
4889
4948
  const isMarketCoinType = coinType.includes("reserve::MarketCoin");
4890
4949
  coinType = coinTypeMatch?.[1] ?? coinType;
4891
- const wormHoleCoinTypeMap = {
4950
+ const wormholeCoinTypeMap = {
4892
4951
  [`${this.address.get("core.coins.wusdc.id") ?? wormholeCoinIds.wusdc}::coin::COIN`]: "wusdc",
4893
4952
  [`${this.address.get("core.coins.wusdt.id") ?? wormholeCoinIds.wusdt}::coin::COIN`]: "wusdt",
4894
4953
  [`${this.address.get("core.coins.weth.id") ?? wormholeCoinIds.weth}::coin::COIN`]: "weth",
@@ -4908,7 +4967,7 @@ var ScallopUtils = class {
4908
4967
  },
4909
4968
  {}
4910
4969
  );
4911
- const assetCoinName = wormHoleCoinTypeMap[coinType] || voloCoinTypeMap[coinType] || suiBridgeTypeMap[coinType] || coinType.split("::")[2].toLowerCase();
4970
+ const assetCoinName = wormholeCoinTypeMap[coinType] || voloCoinTypeMap[coinType] || suiBridgeTypeMap[coinType] || coinType.split("::")[2].toLowerCase();
4912
4971
  return isMarketCoinType ? this.parseMarketCoinName(assetCoinName) : assetCoinName;
4913
4972
  }
4914
4973
  /**
@@ -7302,6 +7361,7 @@ var ScallopQuery = class {
7302
7361
  this,
7303
7362
  coinNames,
7304
7363
  indexer,
7364
+ args?.marketPools,
7305
7365
  args?.coinPrices
7306
7366
  );
7307
7367
  }
@@ -7517,6 +7577,13 @@ var ScallopQuery = class {
7517
7577
  async getCoinPriceByIndexer(poolName) {
7518
7578
  return this.indexer.getCoinPrice(poolName);
7519
7579
  }
7580
+ /**
7581
+ * Get all coin prices, including sCoin
7582
+ * @returns prices data
7583
+ */
7584
+ async getAllCoinPrices(args) {
7585
+ return getAllCoinPrices(this, args?.marketPools, args?.coinPrices);
7586
+ }
7520
7587
  };
7521
7588
 
7522
7589
  // src/models/scallopBuilder.ts
@@ -8504,6 +8571,7 @@ export {
8504
8571
  marketCoins,
8505
8572
  queryKeys,
8506
8573
  sCoinIds,
8574
+ sCoinRawNameToName,
8507
8575
  sCoinTypeToName,
8508
8576
  sCoins,
8509
8577
  spoolRewardCoins,