@scallop-io/sui-scallop-sdk 0.46.39 → 0.46.41

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 (66) hide show
  1. package/dist/builders/loyaltyProgramBuilder.d.ts +1 -1
  2. package/dist/builders/sCoinBuilder.d.ts +4 -0
  3. package/dist/constants/common.d.ts +3 -1
  4. package/dist/constants/enum.d.ts +12 -10
  5. package/dist/constants/flashloan.d.ts +2 -0
  6. package/dist/constants/index.d.ts +1 -0
  7. package/dist/index.js +742 -97
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.mjs +739 -92
  10. package/dist/index.mjs.map +1 -1
  11. package/dist/models/scallopBuilder.d.ts +16 -1
  12. package/dist/models/scallopClient.d.ts +5 -0
  13. package/dist/models/scallopQuery.d.ts +24 -1
  14. package/dist/models/scallopUtils.d.ts +32 -2
  15. package/dist/queries/coreQuery.d.ts +7 -0
  16. package/dist/queries/portfolioQuery.d.ts +1 -1
  17. package/dist/queries/sCoinQuery.d.ts +27 -0
  18. package/dist/test.d.ts +1 -0
  19. package/dist/types/address.d.ts +8 -1
  20. package/dist/types/builder/core.d.ts +12 -4
  21. package/dist/types/builder/index.d.ts +6 -1
  22. package/dist/types/builder/sCoin.d.ts +37 -0
  23. package/dist/types/builder/spool.d.ts +2 -1
  24. package/dist/types/constant/common.d.ts +3 -2
  25. package/dist/types/constant/enum.d.ts +13 -1
  26. package/dist/types/query/core.d.ts +2 -1
  27. package/dist/types/query/index.d.ts +1 -0
  28. package/dist/types/query/portfolio.d.ts +1 -0
  29. package/dist/types/query/sCoin.d.ts +1 -0
  30. package/package.json +3 -3
  31. package/src/builders/coreBuilder.ts +72 -17
  32. package/src/builders/index.ts +5 -1
  33. package/src/builders/loyaltyProgramBuilder.ts +1 -1
  34. package/src/builders/referralBuilder.ts +1 -1
  35. package/src/builders/sCoinBuilder.ts +119 -0
  36. package/src/builders/spoolBuilder.ts +1 -1
  37. package/src/builders/vescaBuilder.ts +3 -3
  38. package/src/constants/common.ts +19 -5
  39. package/src/constants/enum.ts +98 -20
  40. package/src/constants/flashloan.ts +18 -0
  41. package/src/constants/index.ts +1 -0
  42. package/src/constants/testAddress.ts +115 -21
  43. package/src/models/scallopAddress.ts +44 -3
  44. package/src/models/scallopBuilder.ts +43 -7
  45. package/src/models/scallopCache.ts +32 -4
  46. package/src/models/scallopClient.ts +121 -0
  47. package/src/models/scallopQuery.ts +57 -1
  48. package/src/models/scallopUtils.ts +56 -2
  49. package/src/queries/coreQuery.ts +102 -4
  50. package/src/queries/portfolioQuery.ts +25 -3
  51. package/src/queries/sCoinQuery.ts +94 -0
  52. package/src/queries/vescaQuery.ts +0 -1
  53. package/src/test.ts +19 -0
  54. package/src/types/address.ts +13 -0
  55. package/src/types/builder/core.ts +19 -4
  56. package/src/types/builder/index.ts +11 -3
  57. package/src/types/builder/sCoin.ts +61 -0
  58. package/src/types/builder/spool.ts +2 -0
  59. package/src/types/constant/common.ts +4 -1
  60. package/src/types/constant/enum.ts +17 -0
  61. package/src/types/query/core.ts +3 -0
  62. package/src/types/query/index.ts +1 -0
  63. package/src/types/query/portfolio.ts +1 -0
  64. package/src/types/query/sCoin.ts +1 -0
  65. package/src/utils/builder.ts +1 -1
  66. package/src/utils/util.ts +13 -17
package/dist/index.js CHANGED
@@ -33,6 +33,7 @@ __export(src_exports, {
33
33
  ADDRESSES_ID: () => ADDRESSES_ID,
34
34
  API_BASE_URL: () => API_BASE_URL,
35
35
  BORROW_FEE_PROTOCOL_ID: () => BORROW_FEE_PROTOCOL_ID,
36
+ FlashLoanFeeObjectMap: () => FlashLoanFeeObjectMap,
36
37
  IS_VE_SCA_TEST: () => IS_VE_SCA_TEST,
37
38
  MAX_LOCK_DURATION: () => MAX_LOCK_DURATION,
38
39
  MAX_LOCK_ROUNDS: () => MAX_LOCK_ROUNDS,
@@ -48,6 +49,7 @@ __export(src_exports, {
48
49
  SUPPORT_ORACLES: () => SUPPORT_ORACLES,
49
50
  SUPPORT_PACKAGES: () => SUPPORT_PACKAGES,
50
51
  SUPPORT_POOLS: () => SUPPORT_POOLS,
52
+ SUPPORT_SCOIN: () => SUPPORT_SCOIN,
51
53
  SUPPORT_SPOOLS: () => SUPPORT_SPOOLS,
52
54
  SUPPORT_SPOOLS_REWARDS: () => SUPPORT_SPOOLS_REWARDS,
53
55
  Scallop: () => Scallop,
@@ -59,11 +61,14 @@ __export(src_exports, {
59
61
  ScallopQuery: () => ScallopQuery,
60
62
  ScallopUtils: () => ScallopUtils,
61
63
  UNLOCK_ROUND_DURATION: () => UNLOCK_ROUND_DURATION,
64
+ USE_TEST_ADDRESS: () => USE_TEST_ADDRESS,
62
65
  assetCoins: () => assetCoins,
63
66
  borrowIncentiveRewardCoins: () => borrowIncentiveRewardCoins,
64
67
  coinDecimals: () => coinDecimals,
65
68
  coinIds: () => coinIds,
66
69
  marketCoins: () => marketCoins,
70
+ sCoinIds: () => sCoinIds,
71
+ sCoins: () => sCoins,
67
72
  spoolRewardCoins: () => spoolRewardCoins,
68
73
  stakeMarketCoins: () => stakeMarketCoins,
69
74
  voloCoinIds: () => voloCoinIds,
@@ -72,13 +77,11 @@ __export(src_exports, {
72
77
  module.exports = __toCommonJS(src_exports);
73
78
 
74
79
  // src/constants/common.ts
75
- var API_BASE_URL = "https://sui.api.scallop.io";
80
+ var API_BASE_URL = "https://sui.apis.scallop.io";
76
81
  var SDK_API_BASE_URL = "https://sdk.api.scallop.io";
77
82
  var IS_VE_SCA_TEST = false;
78
- var ADDRESSES_ID = IS_VE_SCA_TEST ? (
79
- // ? ('65fb07c39c845425d71d7b18' as const)
80
- "65fb07c39c845425d71d7b18"
81
- ) : "664dfe22898c36c159e28bc8";
83
+ var USE_TEST_ADDRESS = false;
84
+ var ADDRESSES_ID = IS_VE_SCA_TEST || USE_TEST_ADDRESS ? "65fb07c39c845425d71d7b18" : "664dfe22898c36c159e28bc8";
82
85
  var PROTOCOL_OBJECT_ID = IS_VE_SCA_TEST ? "0xc9f859f98ca352a11b97a038c4b4162bee437b8df8caa047990fe9cb03d4f778" : "0xefe8b36d5b2e43728cc323298626b83177803521d195cfb11e15b910e892fddf";
83
86
  var BORROW_FEE_PROTOCOL_ID = IS_VE_SCA_TEST ? "0xc9f859f98ca352a11b97a038c4b4162bee437b8df8caa047990fe9cb03d4f778" : "0xc38f849e81cfe46d4e4320f508ea7dda42934a329d5a6571bb4c3cb6ea63f5da";
84
87
  var SCA_COIN_TYPE = IS_VE_SCA_TEST ? `0x6cd813061a3adf3602b76545f076205f0c8e7ec1d3b1eab9a1da7992c18c0524::sca::SCA` : "0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6::sca::SCA";
@@ -121,6 +124,17 @@ var SUPPORT_SPOOLS = [
121
124
  "shasui",
122
125
  "svsui"
123
126
  ];
127
+ var SUPPORT_SCOIN = [
128
+ "ssui",
129
+ "susdc",
130
+ "susdt",
131
+ "safsui",
132
+ "shasui",
133
+ "svsui",
134
+ "seth",
135
+ "ssca",
136
+ "scetus"
137
+ ];
124
138
  var SUPPORT_SPOOLS_REWARDS = ["sui"];
125
139
  var SUPPORT_BORROW_INCENTIVE_POOLS = [
126
140
  "sui",
@@ -204,6 +218,17 @@ var marketCoins = {
204
218
  svsui: "svsui",
205
219
  ssca: "ssca"
206
220
  };
221
+ var sCoins = {
222
+ seth: "seth",
223
+ susdc: "susdc",
224
+ susdt: "susdt",
225
+ ssui: "ssui",
226
+ scetus: "scetus",
227
+ safsui: "safsui",
228
+ shasui: "shasui",
229
+ svsui: "svsui",
230
+ ssca: "ssca"
231
+ };
207
232
  var stakeMarketCoins = {
208
233
  seth: "seth",
209
234
  ssui: "ssui",
@@ -259,6 +284,17 @@ var wormholeCoinIds = {
259
284
  var voloCoinIds = {
260
285
  vsui: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55"
261
286
  };
287
+ var sCoinIds = {
288
+ ssui: "0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI",
289
+ scetus: "0xea346ce428f91ab007210443efcea5f5cdbbb3aae7e9affc0ca93f9203c31f0c::scallop_cetus::SCALLOP_CETUS",
290
+ ssca: "0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA",
291
+ susdc: "0xad4d71551d31092230db1fd482008ea42867dbf27b286e9c70a79d2a6191d58d::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC",
292
+ susdt: "0xe6e5a012ec20a49a3d1d57bd2b67140b96cd4d3400b9d79e541f7bdbab661f95::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT",
293
+ seth: "0x67540ceb850d418679e69f1fb6b2093d6df78a2a699ffc733f7646096d552e9b::scallop_wormhole_eth::SCALLOP_WORMHOLE_ETH",
294
+ safsui: "0x00671b1fa2a124f5be8bdae8b91ee711462c5d9e31bda232e70fd9607b523c88::scallop_af_sui::SCALLOP_AF_SUI",
295
+ shasui: "0x9a2376943f7d22f88087c259c5889925f332ca4347e669dc37d54c2bf651af3c::scallop_ha_sui::SCALLOP_HA_SUI",
296
+ svsui: "0xe1a1cc6bcf0001a015eab84bcc6713393ce20535f55b8b6f35c142e057a25fbe::scallop_v_sui::SCALLOP_V_SUI"
297
+ };
262
298
 
263
299
  // src/constants/vesca.ts
264
300
  var UNLOCK_ROUND_DURATION = 60 * 60 * 24;
@@ -267,8 +303,24 @@ var MAX_LOCK_DURATION = MAX_LOCK_ROUNDS * UNLOCK_ROUND_DURATION;
267
303
  var MIN_INITIAL_LOCK_AMOUNT = 1e10;
268
304
  var MIN_TOP_UP_AMOUNT = 1e9;
269
305
 
306
+ // src/constants/flashloan.ts
307
+ var FlashLoanFeeObjectMap = {
308
+ vsui: "0x0069cddee7a5c0b1d34beb5ef0620f978096525f1830b055f38b110f40d73fbb",
309
+ btc: "0x2078490aa37d8fb42b511e5c95e217cb957d141267e16980bc802d76b42719f7",
310
+ sui: "0x27614284a8f0a699ffd35aae8f2572c937ec76771cb21b0d7930ec4491a76ed4",
311
+ usdt: "0x5b61983a19b5159ca348d291e4b595f42db70ccda32852a2ed85528aa65171e4",
312
+ apt: "0x9d5898edcd1e4abcb044273242293a9d036f6a977bf3fe57ab71f5a87c505ee6",
313
+ afsui: "0xac87fde83d434554ec300c1334c9a622aa5b59e82a04334dc99e1cc1f75d4eae",
314
+ hasui: "0xb9f505d532de1d6c9f3a8522a2d16f2958b75c0ed939d4f80b96f584a2a8ed5e",
315
+ usdc: "0xd241d6a7e44ac11a6689370ed9a98eec389b98b8a6695c61fddede9fa7567b90",
316
+ eth: "0xd252acb058e77877810c1290564e290a8f9fcab5bc9aca2884ede8a38810cf34",
317
+ sca: "0xe04e46471754b6f48d81c549ecfec09de02733715a63bec02364c6ac7c4dd2dc",
318
+ cetus: "0xe65a73d11c31b2d323ad2b9f6b4bb0a3c0df9c1b212eef66c854941186a5ddc7",
319
+ sol: "0xe84bdb35b790fc7bdd1645122ac6ac0fc904531d6772c9e25904fece322c5f34"
320
+ };
321
+
270
322
  // src/models/scallop.ts
271
- var import_sui_kit13 = require("@scallop-io/sui-kit");
323
+ var import_sui_kit14 = require("@scallop-io/sui-kit");
272
324
 
273
325
  // src/models/scallopCache.ts
274
326
  var import_query_core = require("@tanstack/query-core");
@@ -388,6 +440,8 @@ var ScallopCache = class {
388
440
  * @returns Promise<SuiObjectData[]>
389
441
  */
390
442
  async queryGetObjects(objectIds, options) {
443
+ if (objectIds.length === 0)
444
+ return [];
391
445
  const queryKey = [
392
446
  "getObjects",
393
447
  JSON.stringify(objectIds),
@@ -464,7 +518,7 @@ var ScallopCache = class {
464
518
  queryKey,
465
519
  queryFn: async () => {
466
520
  const allBalances = await this.suiKit.client().getAllBalances({ owner });
467
- return allBalances.reduce(
521
+ const balances = allBalances.reduce(
468
522
  (acc, coinBalance) => {
469
523
  if (coinBalance.totalBalance !== "0") {
470
524
  acc[(0, import_sui_kit.normalizeStructTag)(coinBalance.coinType)] = coinBalance.totalBalance;
@@ -473,11 +527,30 @@ var ScallopCache = class {
473
527
  },
474
528
  {}
475
529
  );
476
- }
530
+ for (const coinType in balances) {
531
+ const coinBalanceQueryKey = [
532
+ "getCoinBalance",
533
+ (0, import_sui_kit.normalizeSuiAddress)(owner),
534
+ (0, import_sui_kit.normalizeStructTag)(coinType)
535
+ ];
536
+ this.queryClient.setQueryData(
537
+ coinBalanceQueryKey,
538
+ balances[coinType]
539
+ );
540
+ }
541
+ return balances;
542
+ },
543
+ staleTime: 5e3
477
544
  });
478
545
  }
479
546
  async queryGetCoinBalance(input) {
480
- const queryKey = ["getCoinBalance", input.owner, input.coinType];
547
+ if (!input.coinType)
548
+ return "0";
549
+ const queryKey = [
550
+ "getCoinBalance",
551
+ (0, import_sui_kit.normalizeSuiAddress)(input.owner),
552
+ (0, import_sui_kit.normalizeStructTag)(input.coinType)
553
+ ];
481
554
  return this.queryClient.fetchQuery({
482
555
  queryKey,
483
556
  queryFn: async () => {
@@ -495,13 +568,21 @@ var import_axios = __toESM(require("axios"));
495
568
  // src/constants/testAddress.ts
496
569
  var TEST_ADDRESSES = {
497
570
  core: {
498
- version: "0x07871c4b3c847a0f674510d4978d5cf6f960452795e8ff6f189fd2088a3f6ac7",
571
+ // version:
572
+ // '0x07871c4b3c847a0f674510d4978d5cf6f960452795e8ff6f189fd2088a3f6ac7',
573
+ version: "0x6156d5cd1538bec8a167a40fe1209a4ec9cf8137921fe0a697f191ac561f0b09",
499
574
  versionCap: "0x590a4011cb649b3878f3ea14b3a78674642a9548d79b7e091ef679574b158a07",
500
- object: "0xefe8b36d5b2e43728cc323298626b83177803521d195cfb11e15b910e892fddf",
501
- market: "0xa757975255146dc9686aa823b7838b507f315d704f428cbadad2f4ea061939d9",
575
+ // object:
576
+ // '0xefe8b36d5b2e43728cc323298626b83177803521d195cfb11e15b910e892fddf',
577
+ object: "0x87ddec2984645dbbe2403a509cc6edf393a43acdba9b77d45da2bcbefcf733c1",
578
+ // market:
579
+ // '0xa757975255146dc9686aa823b7838b507f315d704f428cbadad2f4ea061939d9',
580
+ market: "0x8606ed145cc887985b8ed793f7753ff5dc762a42c379dac035f568e1bac58490",
502
581
  adminCap: "0x09689d018e71c337d9db6d67cbca06b74ed92196103624028ccc3ecea411777c",
503
582
  coinDecimalsRegistry: "0x200abe9bf19751cc566ae35aa58e2b7e4ff688fc1130f8d8909ea09bc137d668",
504
- obligationAccessStore: "0x733e30b7c94d619d78cb8f5bc4bfbb759ced9a531239028caabb2474e5be59c9",
583
+ // obligationAccessStore:
584
+ // '0x733e30b7c94d619d78cb8f5bc4bfbb759ced9a531239028caabb2474e5be59c9',
585
+ obligationAccessStore: "0x48b472d68ca910c45f7f3b6c26836b6aa6d2569810d94b1b939023da05ae0a23",
505
586
  coins: {
506
587
  cetus: {
507
588
  id: "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b",
@@ -691,15 +772,25 @@ var TEST_ADDRESSES = {
691
772
  upgradeCap: "0x3f203f6fff6a69d151e4f1cd931f22b68c489ef2759765662fc7baf673943c9e"
692
773
  },
693
774
  protocol: {
694
- id: "0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e",
775
+ id: "0x87ddec2984645dbbe2403a509cc6edf393a43acdba9b77d45da2bcbefcf733c1",
695
776
  upgradeCap: "0x38527d154618d1fd5a644b90717fe07cf0e9f26b46b63e9568e611a3f86d5c1a"
696
777
  },
778
+ // protocol: {
779
+ // id: '0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e',
780
+ // upgradeCap:
781
+ // '0x38527d154618d1fd5a644b90717fe07cf0e9f26b46b63e9568e611a3f86d5c1a',
782
+ // },
697
783
  protocolWhitelist: {
698
784
  id: "0x4c262d9343dac53ecb28f482a2a3f62c73d0ebac5b5f03d57383d56ff219acdf",
699
785
  upgradeCap: "0x4a5e88a75039b00988f633f811f58117f31b8627a46bf822aa114d9010049449"
700
786
  },
787
+ // query: {
788
+ // id: '0xb8d603a39114a5efef3dd0bf84df0bed1be1fbd39b78b7dd6e8a61ccc5e6006f',
789
+ // upgradeCap:
790
+ // '0x0d535c35f608b9b01b7ccce11acf43b1dd80c1b72bf8b541744a6e28e8d2745f',
791
+ // },
701
792
  query: {
702
- id: "0xb8d603a39114a5efef3dd0bf84df0bed1be1fbd39b78b7dd6e8a61ccc5e6006f",
793
+ id: "0xe4f9d62d17746d5b9dbf0d5557747430021a71575780b515161210cdba0a4c1c",
703
794
  upgradeCap: "0x0d535c35f608b9b01b7ccce11acf43b1dd80c1b72bf8b541744a6e28e8d2745f"
704
795
  },
705
796
  supra: { id: "", upgradeCap: "" },
@@ -716,41 +807,68 @@ var TEST_ADDRESSES = {
716
807
  }
717
808
  },
718
809
  spool: {
719
- id: "0x7c4fdabe81c31b19a45d1e572a52a539997a90903fbb5bfab71480abe0fa62c3",
810
+ // id: '0x7c4fdabe81c31b19a45d1e572a52a539997a90903fbb5bfab71480abe0fa62c3',
811
+ id: "0x1742655fe5872dfa6456673f9e38612a4965e6979e6cd7696a7f1225f28bae21",
720
812
  adminCap: "0xdd8a047cbbf802bfcde5288b8ef1910965d789cc614da11d39af05fca0bd020a",
721
- object: "0xe87f1b2d498106a2c61421cec75b7b5c5e348512b0dc263949a0e7a3c256571a",
813
+ // object:
814
+ // '0xe87f1b2d498106a2c61421cec75b7b5c5e348512b0dc263949a0e7a3c256571a',
815
+ object: "0x1742655fe5872dfa6456673f9e38612a4965e6979e6cd7696a7f1225f28bae21",
722
816
  pools: {
723
817
  seth: {
724
818
  id: "0xeec40beccb07c575bebd842eeaabb835f77cd3dab73add433477e57f583a6787",
725
819
  rewardPoolId: "0x957de68a18d87817de8309b30c1ec269a4d87ae513abbeed86b5619cb9ce1077"
726
820
  },
727
821
  ssui: {
728
- id: "0x4f0ba970d3c11db05c8f40c64a15b6a33322db3702d634ced6536960ab6f3ee4",
729
- rewardPoolId: "0x162250ef72393a4ad3d46294c4e1bdfcb03f04c869d390e7efbfc995353a7ee9"
822
+ // id: '0x4f0ba970d3c11db05c8f40c64a15b6a33322db3702d634ced6536960ab6f3ee4',
823
+ id: "0xb9617f83c06ebdeac0a8834782b1015e1cc7ea23739e30c132c4bfb95c37a579",
824
+ rewardPoolId: (
825
+ // '0x162250ef72393a4ad3d46294c4e1bdfcb03f04c869d390e7efbfc995353a7ee9',
826
+ "0xc3206071a8d43212efb6e3b5504f2321f8df97ab122b466c0bc7cfdf398dc13a"
827
+ )
730
828
  },
731
829
  susdc: {
732
- id: "0x4ace6648ddc64e646ba47a957c562c32c9599b3bba8f5ac1aadb2ae23a2f8ca0",
733
- rewardPoolId: "0xf4268cc9b9413b9bfe09e8966b8de650494c9e5784bf0930759cfef4904daff8"
830
+ // id: '0x4ace6648ddc64e646ba47a957c562c32c9599b3bba8f5ac1aadb2ae23a2f8ca0',
831
+ id: "0xf1b383b9cf2e9f515fc69567df1053098f273849d09cd84b0278a773429bd2b2",
832
+ rewardPoolId: (
833
+ // '0xf4268cc9b9413b9bfe09e8966b8de650494c9e5784bf0930759cfef4904daff8',
834
+ "0xc71c53ee6505d928ba15bea4fe4f45d98c9c31eced94b72d00a7827d4b7ba3ff"
835
+ )
734
836
  },
735
837
  susdt: {
736
- id: "0xcb328f7ffa7f9342ed85af3fdb2f22919e1a06dfb2f713c04c73543870d7548f",
737
- rewardPoolId: "0x2c9f934d67a5baa586ceec2cc24163a2f049a6af3d5ba36b84d8ac40f25c4080"
838
+ // id: '0xcb328f7ffa7f9342ed85af3fdb2f22919e1a06dfb2f713c04c73543870d7548f',
839
+ id: "0xb5567dfa5c7fc17a249e959732664c50713dd8c23db1a11376b27df800c17418",
840
+ rewardPoolId: (
841
+ // '0x2c9f934d67a5baa586ceec2cc24163a2f049a6af3d5ba36b84d8ac40f25c4080',
842
+ "0x60768b0687ff0235e376a039709a683e4c436098785e473b67b32dbab47b69ab"
843
+ )
738
844
  },
739
845
  scetus: {
740
846
  id: "0xac1bb13bf4472a637c18c2415fb0e3c1227ea2bcf35242e50563c98215bd298e",
741
847
  rewardPoolId: "0x6835c1224126a45086fc6406adc249e3f30df18d779ca4f4e570e38716a17f3f"
742
848
  },
743
849
  safsui: {
744
- id: "0xeedf438abcaa6ce4d9625ffca110920592d5867e4c5637d84ad9f466c4feb800",
745
- rewardPoolId: "0x89255a2f86ed7fbfef35ab8b7be48cc7667015975be2685dd9a55a9a64baf76e"
850
+ // id: '0xeedf438abcaa6ce4d9625ffca110920592d5867e4c5637d84ad9f466c4feb800',
851
+ id: "0xc568bb4c991258e839aa54802ecda04fcd9838c826bc3b42b40af81b23c458c8",
852
+ rewardPoolId: (
853
+ // '0x89255a2f86ed7fbfef35ab8b7be48cc7667015975be2685dd9a55a9a64baf76e',
854
+ "0x389a3cbeda742b918941bb24fd00e077bad3367484394d6234f8209b9a6aa03d"
855
+ )
746
856
  },
747
857
  shasui: {
748
- id: "0xa6148bc1b623e936d39a952ceb5bea79e8b37228a8f595067bf1852efd3c34aa",
749
- rewardPoolId: "0x6f3563644d3e2ef13176dbf9d865bd93479df60ccbe07b7e66db57f6309f5a66"
858
+ // id: '0xa6148bc1b623e936d39a952ceb5bea79e8b37228a8f595067bf1852efd3c34aa',
859
+ id: "0x93f3f4499bf89f2d05ddc1f8b15f51701a7c6c4d0ac0b9c3bc99462cbbd8e321",
860
+ rewardPoolId: (
861
+ // '0x6f3563644d3e2ef13176dbf9d865bd93479df60ccbe07b7e66db57f6309f5a66',
862
+ "0x94cee1be7f5ff34193f3aabef0b14142cb28af4d905fe487a9a7d85a15edb6aa"
863
+ )
750
864
  },
751
865
  svsui: {
752
- id: "0x69ce8e537e750a95381e6040794afa5ab1758353a1a2e1de7760391b01f91670",
753
- rewardPoolId: "0xbca914adce058ad0902c7f3cfcd698392a475f00dcfdc3f76001d0370b98777a"
866
+ // id: '0x69ce8e537e750a95381e6040794afa5ab1758353a1a2e1de7760391b01f91670',
867
+ id: "0xa970e9087f80cb59e9299b8e7af7175d977ad6c9af0322aa4440e138fbd7ae00",
868
+ rewardPoolId: (
869
+ // '0xbca914adce058ad0902c7f3cfcd698392a475f00dcfdc3f76001d0370b98777a',
870
+ "0x38eee9699c4fc132a6623e54b865f047df4fc6eb83af807300f44e8f4b235ff0"
871
+ )
754
872
  }
755
873
  },
756
874
  config: ""
@@ -774,7 +892,9 @@ var TEST_ADDRESSES = {
774
892
  revenueTableId: "0x595baa3654c297bff84ab7786a2d250f019cefc66e8df8e89fd9d41e02bd30dd",
775
893
  referralTiers: "0x962cb903d8d7346190c5204785ccbb91b61086aa764f674c8145df82335cf83e",
776
894
  tiersTableId: "0xeac755a7a8b7798530905ac79e8c114f19d0f130f6eab012954f08faac29c75d",
777
- authorizedWitnessList: "0xf21b0ed043c9bb70842c0129159f4943dbcc3c9ef2f2f808af65f8be25cfd20e",
895
+ // authorizedWitnessList:
896
+ // '0xf21b0ed043c9bb70842c0129159f4943dbcc3c9ef2f2f808af65f8be25cfd20e',
897
+ authorizedWitnessList: "0x9d6223dc52015b8a3986a573590ef2af8f1b8f3e4685513888c052f001b87e7f",
778
898
  version: "0x1bd4b7285f72e11c316b828c7c47b3f4da18dcec9f9b3dba6d8629cbb6f93e5e"
779
899
  },
780
900
  vesca: {
@@ -791,6 +911,47 @@ var TEST_ADDRESSES = {
791
911
  object: "0xd17bcf8b5a59652c36225d478564a8593ae0ed7d650bcacdda1d6fe179127907",
792
912
  rewardPool: "0xf9c090492ef476bd542109d0913ffe871cbfa28578b7114eca2a8c0e5671786f",
793
913
  userRewardTableId: "0x748a80395849ed37db1b0e14f2ab5d1d96458d2359ab3a84eb079d0f4ac7cf2e"
914
+ },
915
+ scoin: {
916
+ id: "0xad2ca2aa5089df94bb2d444d5eb3520378c2f2dfb3a0bd2a2c994145ac4b0a53",
917
+ coins: {
918
+ ssui: {
919
+ coinType: "0xfac769100bccc0caebcf4f4e2d00ac2f8883f07f724be28940df90605f5e7e9a::scallop_sui::SCALLOP_SUI",
920
+ treasury: "0x9cb4551b36c17d37e19d700147fa819ea1c487ff8bcf18374de2cceb2e9d4845"
921
+ },
922
+ scetus: {
923
+ coinType: "0x8b71e6d323ed78515af2bead13bf3d0da1562ba4a99234eb7c4f14fd39ef0427::scallop_cetus::SCALLOP_CETUS",
924
+ treasury: "0xd786f4b2d26278cc7911a3445b1b085eab60f269ef9dbb6b87e803d52f155003"
925
+ },
926
+ ssca: {
927
+ coinType: "0x0a9d3c6c9af9f6e8def82921541bcbd17f73ed31bed3adcb684f2a4c267e42f0::scallop_sca::SCALLOP_SCA",
928
+ treasury: "0xe818636d1d6c46d6ea1a2dce9d94696d7cbc18ce27451b603eeaa47aba8d75e0"
929
+ },
930
+ susdc: {
931
+ coinType: "0xaedc3ab75db8680b81a755015fa90124d217be93457b893c05bac033817defaf::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC",
932
+ treasury: "0xfc6971648f867f7fd6928d1b873af71577e2eaf2c7543ef8bc82c431d833ae78"
933
+ },
934
+ susdt: {
935
+ coinType: "0xbf02fc87ddc104b342ad8414c85ceadf5b0c823c055a06fb0ed776272c01a52a::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT",
936
+ treasury: "0xb9593e2c3a0ba796ee815012b75ae46468ea78cda0188b9ac6816efe65503521"
937
+ },
938
+ seth: {
939
+ coinType: "0x27d54f43e3eda701be56b82e5756e41c84467cd202f5cf713d5f9e45a9f1b6bc::scallop_wormhole_eth::SCALLOP_WORMHOLE_ETH",
940
+ treasury: "0x032b4c8fac94c038dbe986f7587e9b1e4ef580b5ee06d2ef249d85459b7ef05d"
941
+ },
942
+ safsui: {
943
+ coinType: "0xb75b46d975d8d80670b53a6bee90baaa8ce2e0b7d397f079447d641eef6b44ad::scallop_af_sui::SCALLOP_AF_SUI",
944
+ treasury: "0x21450ef0570ef3d224ffa3b873ab802e439ece7b93cc7efad10ae0c1e3b3fcfe"
945
+ },
946
+ shasui: {
947
+ coinType: "0xd973a723874e2c7cde196602a79155a1343a933f8cf87d9b1bb7408bc1acbc58::scallop_ha_sui::SCALLOP_HA_SUI",
948
+ treasury: "0xf822fc1402207e47d2e3ba8ff6e1e594bf1de777dc5ebd2744619cd2726e3b0d"
949
+ },
950
+ svsui: {
951
+ coinType: "0x97023a317320c4498cc4cd239dd02fd30c28246e5e8f81325d63f2bd8d70f6b3::scallop_v_sui::SCALLOP_V_SUI",
952
+ treasury: "0x327114f0bf3559d7e2de10282147ed76a236c7c6775029165c4db09a6062ead6\u0192"
953
+ }
954
+ }
794
955
  }
795
956
  };
796
957
 
@@ -1093,6 +1254,47 @@ var EMPTY_ADDRESSES = {
1093
1254
  object: "",
1094
1255
  rewardPool: "",
1095
1256
  userRewardTableId: ""
1257
+ },
1258
+ scoin: {
1259
+ id: "",
1260
+ coins: {
1261
+ ssui: {
1262
+ coinType: "",
1263
+ treasury: ""
1264
+ },
1265
+ scetus: {
1266
+ coinType: "",
1267
+ treasury: ""
1268
+ },
1269
+ ssca: {
1270
+ coinType: "",
1271
+ treasury: ""
1272
+ },
1273
+ susdc: {
1274
+ coinType: "",
1275
+ treasury: ""
1276
+ },
1277
+ susdt: {
1278
+ coinType: "",
1279
+ treasury: ""
1280
+ },
1281
+ seth: {
1282
+ coinType: "",
1283
+ treasury: ""
1284
+ },
1285
+ safsui: {
1286
+ coinType: "",
1287
+ treasury: ""
1288
+ },
1289
+ shasui: {
1290
+ coinType: "",
1291
+ treasury: ""
1292
+ },
1293
+ svsui: {
1294
+ coinType: "",
1295
+ treasury: ""
1296
+ }
1297
+ }
1096
1298
  }
1097
1299
  };
1098
1300
  var ScallopAddress = class {
@@ -1111,8 +1313,8 @@ var ScallopAddress = class {
1111
1313
  this._auth = auth;
1112
1314
  this._id = id;
1113
1315
  this._network = network || "mainnet";
1114
- this._addressesMap = IS_VE_SCA_TEST ? /* @__PURE__ */ new Map([["mainnet", TEST_ADDRESSES]]) : /* @__PURE__ */ new Map();
1115
- if (IS_VE_SCA_TEST)
1316
+ this._addressesMap = USE_TEST_ADDRESS ? /* @__PURE__ */ new Map([["mainnet", TEST_ADDRESSES]]) : /* @__PURE__ */ new Map();
1317
+ if (USE_TEST_ADDRESS)
1116
1318
  this._currentAddresses = TEST_ADDRESSES;
1117
1319
  }
1118
1320
  /**
@@ -1401,8 +1603,8 @@ var ScallopAddress = class {
1401
1603
  };
1402
1604
 
1403
1605
  // src/models/scallopClient.ts
1404
- var import_utils22 = require("@mysten/sui.js/utils");
1405
- var import_sui_kit12 = require("@scallop-io/sui-kit");
1606
+ var import_utils23 = require("@mysten/sui.js/utils");
1607
+ var import_sui_kit13 = require("@scallop-io/sui-kit");
1406
1608
 
1407
1609
  // src/models/scallopUtils.ts
1408
1610
  var import_utils9 = require("@mysten/sui.js/utils");
@@ -1445,7 +1647,6 @@ var checkExtendLockPeriod = (lockPeriodInDays, newUnlockAtInSecondTimestamp, pre
1445
1647
  const availableLockPeriodInDays = Math.floor(
1446
1648
  (newUnlockAtInSecondTimestamp - prevUnlockAtInSecondTimestamp) / UNLOCK_ROUND_DURATION
1447
1649
  );
1448
- console.log("availableLockPeriodInDays", availableLockPeriodInDays);
1449
1650
  if (lockPeriodInDays > availableLockPeriodInDays) {
1450
1651
  throw new Error(
1451
1652
  `Cannot extend lock period by ${lockPeriodInDays} days, maximum lock period is ~4 years (${MAX_LOCK_ROUNDS} days), remaining lock period is ${MAX_LOCK_ROUNDS - availableLockPeriodInDays}`
@@ -1904,16 +2105,18 @@ var estimatedFactor = (amount, scaleStep, type) => {
1904
2105
  };
1905
2106
 
1906
2107
  // src/utils/util.ts
2108
+ var COIN_SET = Array.from(
2109
+ /* @__PURE__ */ new Set([
2110
+ ...SUPPORT_POOLS,
2111
+ ...SUPPORT_COLLATERALS,
2112
+ ...SUPPORT_SPOOLS_REWARDS,
2113
+ ...SUPPORT_BORROW_INCENTIVE_REWARDS,
2114
+ ...SUPPORT_SCOIN
2115
+ ])
2116
+ );
1907
2117
  var isMarketCoin = (coinName) => {
1908
2118
  const assetCoinName = coinName.slice(1).toLowerCase();
1909
- return coinName.charAt(0).toLowerCase() === "s" && [
1910
- .../* @__PURE__ */ new Set([
1911
- ...SUPPORT_POOLS,
1912
- ...SUPPORT_COLLATERALS,
1913
- ...SUPPORT_SPOOLS_REWARDS,
1914
- ...SUPPORT_BORROW_INCENTIVE_REWARDS
1915
- ])
1916
- ].includes(assetCoinName);
2119
+ return coinName.charAt(0).toLowerCase() === "s" && COIN_SET.includes(assetCoinName);
1917
2120
  };
1918
2121
  var parseAssetSymbol = (coinName) => {
1919
2122
  switch (coinName) {
@@ -1928,14 +2131,7 @@ var parseAssetSymbol = (coinName) => {
1928
2131
  }
1929
2132
  };
1930
2133
  var parseDataFromPythPriceFeed = (feed, address) => {
1931
- const assetCoinNames = [
1932
- .../* @__PURE__ */ new Set([
1933
- ...SUPPORT_POOLS,
1934
- ...SUPPORT_COLLATERALS,
1935
- ...SUPPORT_SPOOLS_REWARDS,
1936
- ...SUPPORT_BORROW_INCENTIVE_REWARDS
1937
- ])
1938
- ];
2134
+ const assetCoinNames = COIN_SET;
1939
2135
  const assetCoinName = assetCoinNames.find((assetCoinName2) => {
1940
2136
  return address.get(`core.coins.${assetCoinName2}.oracle.pyth.feed`) === feed.id;
1941
2137
  });
@@ -2209,7 +2405,7 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
2209
2405
  }
2210
2406
  }
2211
2407
  }
2212
- if (balanceSheet && borrowIndex && interestModel && borrowFeeRate) {
2408
+ if (balanceSheet && borrowIndex && interestModel && (USE_TEST_ADDRESS || borrowFeeRate)) {
2213
2409
  const parsedMarketPoolData = parseOriginMarketPoolData({
2214
2410
  type: interestModel.type.fields,
2215
2411
  maxBorrowRate: interestModel.max_borrow_rate.fields,
@@ -2223,7 +2419,7 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
2223
2419
  reserve: balanceSheet.revenue,
2224
2420
  reserveFactor: interestModel.revenue_factor.fields,
2225
2421
  borrowWeight: interestModel.borrow_weight.fields,
2226
- borrowFeeRate,
2422
+ borrowFeeRate: borrowFeeRate || { value: "0" },
2227
2423
  baseBorrowRatePerSec: interestModel.base_borrow_rate_per_sec.fields,
2228
2424
  borrowRateOnHighKink: interestModel.borrow_rate_on_high_kink.fields,
2229
2425
  borrowRateOnMidKink: interestModel.borrow_rate_on_mid_kink.fields,
@@ -2259,10 +2455,10 @@ var getMarketCollaterals = async (query, collateralCoinNames, indexer = false) =
2259
2455
  collateralCoinNames = collateralCoinNames || [...SUPPORT_COLLATERALS];
2260
2456
  const marketId = query.address.get("core.market");
2261
2457
  const [marketObjectResponse, coinPrices] = await Promise.all([
2262
- query.cache.queryGetObject(marketId, {
2458
+ await query.cache.queryGetObject(marketId, {
2263
2459
  showContent: true
2264
2460
  }),
2265
- query.utils.getCoinPrices(collateralCoinNames ?? [])
2461
+ await query.utils.getCoinPrices(collateralCoinNames ?? [])
2266
2462
  ]);
2267
2463
  const marketCollaterals = {};
2268
2464
  if (indexer) {
@@ -2489,6 +2685,64 @@ var getMarketCoinAmount = async (query, marketCoinName, ownerAddress) => {
2489
2685
  });
2490
2686
  return (0, import_bignumber2.default)(amount).toNumber();
2491
2687
  };
2688
+ var getFlashLoanFees = async (query, assetNames) => {
2689
+ const FEE_RATE = 1e4;
2690
+ const missingAssets = [];
2691
+ const assetTypeMap = assetNames.reduce(
2692
+ (prev, curr) => {
2693
+ const assetType = query.utils.parseCoinType(curr).slice(2);
2694
+ prev[assetType] = curr;
2695
+ return prev;
2696
+ },
2697
+ {}
2698
+ );
2699
+ const objIds = assetNames.map((assetName) => {
2700
+ if (!FlashLoanFeeObjectMap[assetName]) {
2701
+ missingAssets.push(assetName);
2702
+ return null;
2703
+ } else {
2704
+ return FlashLoanFeeObjectMap[assetName];
2705
+ }
2706
+ }).filter((t) => !!t);
2707
+ const flashloanFeeObjects = await query.cache.queryGetObjects(objIds, {
2708
+ showContent: true
2709
+ });
2710
+ if (missingAssets.length > 0) {
2711
+ const marketObjectId = query.address.get("core.market");
2712
+ const marketObjectRes = await query.cache.queryGetObject(marketObjectId, {
2713
+ showContent: true
2714
+ });
2715
+ if (marketObjectRes.data?.content?.dataType !== "moveObject")
2716
+ throw new Error("Failed to get market object");
2717
+ const vault = marketObjectRes.data.content.fields.vault;
2718
+ const flashloanFeesTableId = vault.fields.flash_loan_fees.fields.table.fields.id.id;
2719
+ const balanceSheetDynamicFields = await query.cache.queryGetDynamicFields({
2720
+ parentId: flashloanFeesTableId,
2721
+ limit: 50
2722
+ });
2723
+ const dynamicFieldObjectIds = balanceSheetDynamicFields.data.filter((field) => {
2724
+ const assetType = field.name.value.name;
2725
+ return !!assetTypeMap[assetType];
2726
+ }).map((field) => field.objectId);
2727
+ flashloanFeeObjects.push(
2728
+ ...await query.cache.queryGetObjects(dynamicFieldObjectIds, {
2729
+ showContent: true
2730
+ })
2731
+ );
2732
+ }
2733
+ return flashloanFeeObjects.reduce(
2734
+ (prev, curr) => {
2735
+ if (curr.content?.dataType === "moveObject") {
2736
+ const objectFields = curr.content.fields;
2737
+ const assetType = curr.content.fields.name.fields.name;
2738
+ const feeNumerator = +objectFields.value;
2739
+ prev[assetTypeMap[assetType]] = feeNumerator / FEE_RATE;
2740
+ }
2741
+ return prev;
2742
+ },
2743
+ {}
2744
+ );
2745
+ };
2492
2746
 
2493
2747
  // src/queries/spoolQuery.ts
2494
2748
  var import_utils4 = require("@mysten/sui.js/utils");
@@ -3143,7 +3397,7 @@ var getLendings = async (query, poolCoinNames, ownerAddress, indexer = false) =>
3143
3397
  );
3144
3398
  return lendings;
3145
3399
  };
3146
- var getLending = async (query, poolCoinName, ownerAddress, indexer = false, marketPool, spool, stakeAccounts, coinAmount, marketCoinAmount, coinPrice) => {
3400
+ var getLending = async (query, poolCoinName, ownerAddress, indexer = false, marketPool, spool, stakeAccounts, coinAmount, marketCoinAmount, sCoinAmount, coinPrice) => {
3147
3401
  const marketCoinName = query.utils.parseMarketCoinName(poolCoinName);
3148
3402
  marketPool = marketPool || await query.getMarketPool(poolCoinName, indexer);
3149
3403
  spool = spool || SUPPORT_SPOOLS.includes(marketCoinName) ? await query.getSpool(marketCoinName, indexer) : void 0;
@@ -3153,6 +3407,7 @@ var getLending = async (query, poolCoinName, ownerAddress, indexer = false, mark
3153
3407
  ) : [];
3154
3408
  coinAmount = coinAmount || await query.getCoinAmount(poolCoinName, ownerAddress);
3155
3409
  marketCoinAmount = marketCoinAmount || await query.getMarketCoinAmount(marketCoinName, ownerAddress);
3410
+ sCoinAmount = sCoinAmount || await query.getSCoinAmount(marketCoinName, ownerAddress);
3156
3411
  coinPrice = coinPrice || (await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName];
3157
3412
  const coinDecimal = query.utils.getCoinDecimal(poolCoinName);
3158
3413
  let stakedMarketAmount = (0, import_bignumber4.default)(0);
@@ -3204,9 +3459,7 @@ var getLending = async (query, poolCoinName, ownerAddress, indexer = false, mark
3204
3459
  );
3205
3460
  }
3206
3461
  }
3207
- const suppliedAmount = (0, import_bignumber4.default)(marketCoinAmount).multipliedBy(
3208
- marketPool?.conversionRate ?? 1
3209
- );
3462
+ const suppliedAmount = (0, import_bignumber4.default)(marketCoinAmount).plus((0, import_bignumber4.default)(sCoinAmount)).multipliedBy(marketPool?.conversionRate ?? 1);
3210
3463
  const suppliedCoin = suppliedAmount.shiftedBy(-1 * coinDecimal);
3211
3464
  const suppliedValue = suppliedCoin.multipliedBy(coinPrice ?? 0);
3212
3465
  const marketCoinPrice = (0, import_bignumber4.default)(coinPrice ?? 0).multipliedBy(
@@ -3308,6 +3561,7 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
3308
3561
  let totalBorrowCapacityValue = (0, import_bignumber4.default)(0);
3309
3562
  let totalRequiredCollateralValue = (0, import_bignumber4.default)(0);
3310
3563
  let totalBorrowedPools = 0;
3564
+ let totalRewardedPools = 0;
3311
3565
  let totalBorrowedValue = (0, import_bignumber4.default)(0);
3312
3566
  let totalBorrowedValueWithWeight = (0, import_bignumber4.default)(0);
3313
3567
  for (const assetCoinName of collateralAssetCoinNames) {
@@ -3469,6 +3723,12 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
3469
3723
  }
3470
3724
  }
3471
3725
  }
3726
+ if (Object.keys(borrowIncentivePool.points).some((coinName2) => {
3727
+ const rewardApr = borrowIncentivePool.points[coinName2]?.rewardApr;
3728
+ return rewardApr !== Infinity && typeof rewardApr == "number" && rewardApr > 0;
3729
+ }) && borrowIncentiveAccount.debtAmount > 0) {
3730
+ totalRewardedPools++;
3731
+ }
3472
3732
  borrowIncentives[coinName] = {
3473
3733
  coinName: borrowIncentivePool.coinName,
3474
3734
  coinType: borrowIncentivePool.coinType,
@@ -3506,6 +3766,7 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
3506
3766
  totalRiskLevel: riskLevel.toNumber(),
3507
3767
  totalDepositedPools,
3508
3768
  totalBorrowedPools,
3769
+ totalRewardedPools,
3509
3770
  collaterals,
3510
3771
  debts,
3511
3772
  borrowIncentives
@@ -3748,7 +4009,6 @@ var getVeScaTreasuryInfo = async (query) => {
3748
4009
  if (!veScaTreasury || veScaTreasury.data?.content?.dataType !== "moveObject")
3749
4010
  return null;
3750
4011
  const treasuryFields = veScaTreasury.data.content.fields;
3751
- console.log(treasuryFields);
3752
4012
  const totalLockedSca = (0, import_bignumber5.default)(
3753
4013
  treasuryFields.unlock_schedule.fields.locked_sca_amount
3754
4014
  ).shiftedBy(-9).toNumber();
@@ -4000,6 +4260,56 @@ var ScallopIndexer = class {
4000
4260
  }
4001
4261
  };
4002
4262
 
4263
+ // src/queries/sCoinQuery.ts
4264
+ var import_bcs2 = require("@mysten/sui.js/bcs");
4265
+ var import_assert = __toESM(require("assert"));
4266
+ var import_bignumber7 = __toESM(require("bignumber.js"));
4267
+ var getSCoinTotalSupply = async (query, sCoinName) => {
4268
+ const sCoinPkgId = query.address.get("scoin.id");
4269
+ const args = [query.utils.getSCoinTreasury(sCoinName)];
4270
+ const typeArgs = [
4271
+ query.utils.parseSCoinType(sCoinName),
4272
+ query.utils.parseUnderlyingSCoinType(sCoinName)
4273
+ ];
4274
+ const queryTarget = `${sCoinPkgId}::s_coin_converter::total_supply`;
4275
+ const queryResults = await query.cache.queryInspectTxn({
4276
+ queryTarget,
4277
+ args,
4278
+ typeArgs
4279
+ });
4280
+ const results = queryResults.results;
4281
+ if (results && results[0].returnValues) {
4282
+ const value = Uint8Array.from(results[0].returnValues[0][0]);
4283
+ const type = results[0].returnValues[0][1];
4284
+ (0, import_assert.default)(type === "u64", "Result type is not u64");
4285
+ return (0, import_bignumber7.default)(import_bcs2.bcs.de(type, value)).shiftedBy(
4286
+ query.utils.getCoinDecimal(query.utils.parseCoinName(sCoinName))
4287
+ ).toNumber();
4288
+ }
4289
+ return 0;
4290
+ };
4291
+ var getSCoinAmounts = async (query, sCoinNames, ownerAddress) => {
4292
+ sCoinNames = sCoinNames || [...SUPPORT_SCOIN];
4293
+ const owner = ownerAddress || query.suiKit.currentAddress();
4294
+ const sCoins2 = {};
4295
+ await Promise.allSettled(
4296
+ sCoinNames.map(async (sCoinName) => {
4297
+ const sCoin = await getSCoinAmount(query, sCoinName, owner);
4298
+ sCoins2[sCoinName] = sCoin;
4299
+ })
4300
+ );
4301
+ return sCoins2;
4302
+ };
4303
+ var getSCoinAmount = async (query, sCoinName, ownerAddress) => {
4304
+ const owner = ownerAddress || query.suiKit.currentAddress();
4305
+ const sCoinType = query.utils.parseSCoinType(sCoinName);
4306
+ const amount = await query.cache.queryGetCoinBalance({
4307
+ owner,
4308
+ coinType: sCoinType
4309
+ });
4310
+ return (0, import_bignumber7.default)(amount).toNumber();
4311
+ };
4312
+
4003
4313
  // src/models/scallopQuery.ts
4004
4314
  var ScallopQuery = class {
4005
4315
  constructor(params, instance) {
@@ -4415,6 +4725,41 @@ var ScallopQuery = class {
4415
4725
  async getLoyaltyProgramInfos(veScaKey) {
4416
4726
  return await getLoyaltyProgramInformations(this, veScaKey);
4417
4727
  }
4728
+ /**
4729
+ * Get total supply of sCoin
4730
+ * @param sCoinName - Supported sCoin name
4731
+ * @returns Total Supply
4732
+ */
4733
+ async getSCoinTotalSupply(sCoinName) {
4734
+ return await getSCoinTotalSupply(this, sCoinName);
4735
+ }
4736
+ /**
4737
+ * Get all sCoin amounts.
4738
+ *
4739
+ * @param sCoinNames - Specific an array of support sCoin name.
4740
+ * @param ownerAddress - The owner address.
4741
+ * @return All market sCoin amounts.
4742
+ */
4743
+ async getSCoinAmounts(sCoinNames, ownerAddress) {
4744
+ return await getSCoinAmounts(this, sCoinNames, ownerAddress);
4745
+ }
4746
+ /**
4747
+ * Get sCoin amount.
4748
+ *
4749
+ * @param coinNames - Specific support sCoin name.
4750
+ * @param ownerAddress - The owner address.
4751
+ * @return sCoin amount.
4752
+ */
4753
+ async getSCoinAmount(sCoinName, ownerAddress) {
4754
+ const parsedSCoinName = this.utils.parseSCoinName(sCoinName);
4755
+ return parsedSCoinName ? await getSCoinAmount(this, parsedSCoinName, ownerAddress) : 0;
4756
+ }
4757
+ /*
4758
+ * Get flashloan fee for specified assets
4759
+ */
4760
+ async getFlashLoanFees(assetCoinNames = [...SUPPORT_POOLS]) {
4761
+ return await getFlashLoanFees(this, assetCoinNames);
4762
+ }
4418
4763
  };
4419
4764
 
4420
4765
  // src/constants/pyth.ts
@@ -4530,6 +4875,48 @@ var ScallopUtils = class {
4530
4875
  return `${coinPackageId}::${coinName}::${coinName.toUpperCase()}`;
4531
4876
  }
4532
4877
  }
4878
+ /**
4879
+ * Convert coin name to sCoin name.
4880
+ *
4881
+ * @param coinName - Specific support coin name.
4882
+ * @return sCoin name.
4883
+ */
4884
+ parseSCoinName(coinName) {
4885
+ if (isMarketCoin(coinName) && SUPPORT_SCOIN.includes(coinName)) {
4886
+ return coinName;
4887
+ } else {
4888
+ const marketCoinName = `s${coinName}`;
4889
+ if (SUPPORT_SCOIN.includes(marketCoinName)) {
4890
+ return marketCoinName;
4891
+ }
4892
+ return void 0;
4893
+ }
4894
+ }
4895
+ /**
4896
+ * Convert sCoin name into sCoin type
4897
+ * @param sCoinName
4898
+ * @returns sCoin type
4899
+ */
4900
+ parseSCoinType(sCoinName) {
4901
+ return sCoinIds[sCoinName];
4902
+ }
4903
+ /**
4904
+ * Convert sCoin name into its underlying coin type
4905
+ * @param sCoinName
4906
+ * @returns coin type
4907
+ */
4908
+ parseUnderlyingSCoinType(sCoinName) {
4909
+ const coinName = this.parseCoinName(sCoinName);
4910
+ return this.parseCoinType(coinName);
4911
+ }
4912
+ /**
4913
+ * Get sCoin treasury id from sCoin name
4914
+ * @param sCoinName
4915
+ * @returns sCoin treasury id
4916
+ */
4917
+ getSCoinTreasury(sCoinName) {
4918
+ return this._address.get(`scoin.coins.${sCoinName}.treasury`);
4919
+ }
4533
4920
  /**
4534
4921
  * Convert coin name to market coin type.
4535
4922
  *
@@ -4607,14 +4994,14 @@ var ScallopUtils = class {
4607
4994
  * @param coinType - The coin type, default is 0x2::SUI::SUI.
4608
4995
  * @return The selected transaction coin arguments.
4609
4996
  */
4610
- async selectCoinIds(amount, coinType = import_utils9.SUI_TYPE_ARG, ownerAddress) {
4997
+ async selectCoins(amount, coinType = import_utils9.SUI_TYPE_ARG, ownerAddress) {
4611
4998
  ownerAddress = ownerAddress || this._suiKit.currentAddress();
4612
4999
  const coins = await this._suiKit.suiInteractor.selectCoins(
4613
5000
  ownerAddress,
4614
5001
  amount,
4615
5002
  coinType
4616
5003
  );
4617
- return coins.map((c) => c.objectId);
5004
+ return coins;
4618
5005
  }
4619
5006
  /**
4620
5007
  * Get all asset coin names in the obligation record by obligation id.
@@ -4788,8 +5175,8 @@ var ScallopUtils = class {
4788
5175
  };
4789
5176
 
4790
5177
  // src/models/scallopBuilder.ts
4791
- var import_utils21 = require("@mysten/sui.js/utils");
4792
- var import_sui_kit11 = require("@scallop-io/sui-kit");
5178
+ var import_utils22 = require("@mysten/sui.js/utils");
5179
+ var import_sui_kit12 = require("@scallop-io/sui-kit");
4793
5180
 
4794
5181
  // src/builders/coreBuilder.ts
4795
5182
  var import_transactions = require("@mysten/sui.js/transactions");
@@ -4967,10 +5354,13 @@ var generateCoreNormalMethod = ({
4967
5354
  const referralPkgId = builder.address.get("referral.id");
4968
5355
  const referralWitnessType = `${referralPkgId}::scallop_referral_program::REFERRAL_WITNESS`;
4969
5356
  return {
4970
- openObligation: () => txBlock.moveCall(
4971
- `${coreIds.protocolPkg}::open_obligation::open_obligation`,
4972
- [coreIds.version]
4973
- ),
5357
+ openObligation: () => {
5358
+ const [obligation, obligationKey, obligationHotPotato] = txBlock.moveCall(
5359
+ `${coreIds.protocolPkg}::open_obligation::open_obligation`,
5360
+ [coreIds.version]
5361
+ );
5362
+ return [obligation, obligationKey, obligationHotPotato];
5363
+ },
4974
5364
  returnObligation: (obligation, obligationHotPotato) => txBlock.moveCall(
4975
5365
  `${coreIds.protocolPkg}::open_obligation::return_obligation`,
4976
5366
  [coreIds.version, obligation, obligationHotPotato]
@@ -5164,11 +5554,12 @@ var generateCoreQuickMethod = ({
5164
5554
  collateralCoinName
5165
5555
  );
5166
5556
  },
5167
- depositQuick: async (amount, poolCoinName) => {
5557
+ depositQuick: async (amount, poolCoinName, returnSCoin = true) => {
5168
5558
  const sender = requireSender(txBlock);
5559
+ let marketCoinDeposit;
5169
5560
  if (poolCoinName === "sui") {
5170
5561
  const [suiCoin] = txBlock.splitSUIFromGas([amount]);
5171
- return txBlock.deposit(suiCoin, poolCoinName);
5562
+ marketCoinDeposit = txBlock.deposit(suiCoin, poolCoinName);
5172
5563
  } else {
5173
5564
  const { leftCoin, takeCoin } = await builder.selectCoin(
5174
5565
  txBlock,
@@ -5177,20 +5568,56 @@ var generateCoreQuickMethod = ({
5177
5568
  sender
5178
5569
  );
5179
5570
  txBlock.transferObjects([leftCoin], sender);
5180
- return txBlock.deposit(takeCoin, poolCoinName);
5571
+ marketCoinDeposit = txBlock.deposit(takeCoin, poolCoinName);
5181
5572
  }
5573
+ return returnSCoin ? txBlock.mintSCoin(
5574
+ builder.utils.parseMarketCoinName(poolCoinName),
5575
+ marketCoinDeposit
5576
+ ) : marketCoinDeposit;
5182
5577
  },
5183
5578
  withdrawQuick: async (amount, poolCoinName) => {
5184
5579
  const sender = requireSender(txBlock);
5185
5580
  const marketCoinName = builder.utils.parseMarketCoinName(poolCoinName);
5186
- const { leftCoin, takeCoin } = await builder.selectMarketCoin(
5187
- txBlock,
5188
- marketCoinName,
5189
- amount,
5190
- sender
5191
- );
5192
- txBlock.transferObjects([leftCoin], sender);
5193
- return txBlock.withdraw(takeCoin, poolCoinName);
5581
+ try {
5582
+ const sCoinName = builder.utils.parseSCoinName(poolCoinName);
5583
+ if (!sCoinName)
5584
+ throw new Error(`No sCoin for ${poolCoinName}`);
5585
+ const { leftCoin, takeCoin, totalAmount } = await builder.selectSCoin(
5586
+ txBlock,
5587
+ sCoinName,
5588
+ amount,
5589
+ sender
5590
+ );
5591
+ txBlock.transferObjects([leftCoin], sender);
5592
+ const marketCoin = txBlock.burnSCoin(sCoinName, takeCoin);
5593
+ const txResult = txBlock.withdraw(marketCoin, poolCoinName);
5594
+ amount -= totalAmount;
5595
+ try {
5596
+ if (amount > 0) {
5597
+ const { leftCoin: leftCoin2, takeCoin: takeCoin2 } = await builder.selectMarketCoin(
5598
+ txBlock,
5599
+ marketCoinName,
5600
+ amount,
5601
+ sender
5602
+ );
5603
+ txBlock.transferObjects([leftCoin2], sender);
5604
+ txBlock.mergeCoins(txResult, [
5605
+ txBlock.withdraw(takeCoin2, poolCoinName)
5606
+ ]);
5607
+ }
5608
+ } catch (e) {
5609
+ }
5610
+ return txResult;
5611
+ } catch (e) {
5612
+ const { leftCoin, takeCoin } = await builder.selectMarketCoin(
5613
+ txBlock,
5614
+ marketCoinName,
5615
+ amount,
5616
+ sender
5617
+ );
5618
+ txBlock.transferObjects([leftCoin], sender);
5619
+ return txBlock.withdraw(takeCoin, poolCoinName);
5620
+ }
5194
5621
  },
5195
5622
  borrowQuick: async (amount, poolCoinName, obligationId, obligationKey) => {
5196
5623
  const obligationInfo = await requireObligationInfo(
@@ -5394,7 +5821,7 @@ var generateSpoolQuickMethod = ({
5394
5821
  );
5395
5822
  const marketCoinType = builder.utils.parseMarketCoinType(stakeMarketCoinName);
5396
5823
  if (typeof amountOrMarketCoin === "number") {
5397
- const coins = await builder.utils.selectCoinIds(
5824
+ const coins = await builder.utils.selectCoins(
5398
5825
  amountOrMarketCoin,
5399
5826
  marketCoinType,
5400
5827
  sender
@@ -5605,7 +6032,7 @@ var generateQuickVeScaMethod = ({
5605
6032
  let scaCoin = void 0;
5606
6033
  const transferObjects = [];
5607
6034
  if (amountOrCoin !== void 0 && typeof amountOrCoin === "number") {
5608
- const coins = await builder.utils.selectCoinIds(
6035
+ const coins = await builder.utils.selectCoins(
5609
6036
  amountOrCoin,
5610
6037
  SCA_COIN_TYPE,
5611
6038
  sender
@@ -5677,7 +6104,7 @@ var generateQuickVeScaMethod = ({
5677
6104
  if (autoCheck)
5678
6105
  checkExtendLockAmount(scaAmount, veSca?.unlockAt);
5679
6106
  if (veSca) {
5680
- const scaCoins = await builder.utils.selectCoinIds(
6107
+ const scaCoins = await builder.utils.selectCoins(
5681
6108
  scaAmount,
5682
6109
  SCA_COIN_TYPE,
5683
6110
  sender
@@ -5705,7 +6132,7 @@ var generateQuickVeScaMethod = ({
5705
6132
  const unlockedSca = txBlock.redeemSca(veSca.keyId);
5706
6133
  transferObjects.push(unlockedSca);
5707
6134
  }
5708
- const scaCoins = await builder.utils.selectCoinIds(
6135
+ const scaCoins = await builder.utils.selectCoins(
5709
6136
  scaAmount,
5710
6137
  SCA_COIN_TYPE,
5711
6138
  sender
@@ -6089,7 +6516,7 @@ var generateReferralQuickMethod = ({
6089
6516
  Infinity,
6090
6517
  builder.utils.parseCoinType(coinName)
6091
6518
  );
6092
- txBlock.mergeCoins(rewardCoin, coins);
6519
+ txBlock.mergeCoins(rewardCoin, coins.slice(0, 500));
6093
6520
  } catch (e) {
6094
6521
  } finally {
6095
6522
  objToTransfer.push(rewardCoin);
@@ -6207,6 +6634,95 @@ var newLoyaltyProgramTxBlock = (builder, initTxBlock) => {
6207
6634
  });
6208
6635
  };
6209
6636
 
6637
+ // src/builders/sCoinBuilder.ts
6638
+ var import_sui_kit11 = require("@scallop-io/sui-kit");
6639
+ var generateSCoinNormalMethod = ({
6640
+ builder,
6641
+ txBlock
6642
+ }) => {
6643
+ const sCoinPkgIds = {
6644
+ pkgId: builder.address.get("scoin.id")
6645
+ };
6646
+ return {
6647
+ mintSCoin: (marketCoinName, marketCoin) => {
6648
+ return txBlock.moveCall(
6649
+ `${sCoinPkgIds.pkgId}::s_coin_converter::mint_s_coin`,
6650
+ [builder.utils.getSCoinTreasury(marketCoinName), marketCoin],
6651
+ [
6652
+ builder.utils.parseSCoinType(marketCoinName),
6653
+ builder.utils.parseUnderlyingSCoinType(marketCoinName)
6654
+ ]
6655
+ );
6656
+ },
6657
+ burnSCoin: (sCoinName, sCoin) => {
6658
+ return txBlock.moveCall(
6659
+ `${sCoinPkgIds.pkgId}::s_coin_converter::burn_s_coin`,
6660
+ [builder.utils.getSCoinTreasury(sCoinName), sCoin],
6661
+ [
6662
+ builder.utils.parseSCoinType(sCoinName),
6663
+ builder.utils.parseUnderlyingSCoinType(sCoinName)
6664
+ ]
6665
+ );
6666
+ }
6667
+ };
6668
+ };
6669
+ var generateSCoinQuickMethod = ({
6670
+ builder,
6671
+ txBlock
6672
+ }) => {
6673
+ return {
6674
+ mintSCoinQuick: async (marketCoinName, amount) => {
6675
+ const sender = requireSender(txBlock);
6676
+ const { leftCoin, takeCoin } = await builder.selectMarketCoin(
6677
+ txBlock,
6678
+ marketCoinName,
6679
+ amount,
6680
+ sender
6681
+ );
6682
+ txBlock.transferObjects([leftCoin], sender);
6683
+ return txBlock.mintSCoin(marketCoinName, takeCoin);
6684
+ },
6685
+ burnSCoinQuick: async (sCoinName, amount) => {
6686
+ const sender = requireSender(txBlock);
6687
+ const { leftCoin, takeCoin } = await builder.selectSCoin(
6688
+ txBlock,
6689
+ sCoinName,
6690
+ amount,
6691
+ sender
6692
+ );
6693
+ txBlock.transferObjects([leftCoin], sender);
6694
+ return txBlock.burnSCoin(sCoinName, takeCoin);
6695
+ }
6696
+ };
6697
+ };
6698
+ var newSCoinTxBlock = (builder, initTxBlock) => {
6699
+ const txBlock = initTxBlock instanceof import_sui_kit11.TransactionBlock ? new import_sui_kit11.SuiTxBlock(initTxBlock) : initTxBlock ? initTxBlock : new import_sui_kit11.SuiTxBlock();
6700
+ const normalMethod = generateSCoinNormalMethod({
6701
+ builder,
6702
+ txBlock
6703
+ });
6704
+ const normalTxBlock = new Proxy(txBlock, {
6705
+ get: (target, prop) => {
6706
+ if (prop in normalMethod) {
6707
+ return Reflect.get(normalMethod, prop);
6708
+ }
6709
+ return Reflect.get(target, prop);
6710
+ }
6711
+ });
6712
+ const quickMethod = generateSCoinQuickMethod({
6713
+ builder,
6714
+ txBlock: normalTxBlock
6715
+ });
6716
+ return new Proxy(normalTxBlock, {
6717
+ get: (target, prop) => {
6718
+ if (prop in quickMethod) {
6719
+ return Reflect.get(quickMethod, prop);
6720
+ }
6721
+ return Reflect.get(target, prop);
6722
+ }
6723
+ });
6724
+ };
6725
+
6210
6726
  // src/builders/index.ts
6211
6727
  var newScallopTxBlock = (builder, initTxBlock) => {
6212
6728
  const vescaTxBlock = newVeScaTxBlock(builder, initTxBlock);
@@ -6217,7 +6733,8 @@ var newScallopTxBlock = (builder, initTxBlock) => {
6217
6733
  );
6218
6734
  const referralTxBlock = newReferralTxBlock(builder, borrowIncentiveTxBlock);
6219
6735
  const spoolTxBlock = newSpoolTxBlock(builder, referralTxBlock);
6220
- const coreTxBlock = newCoreTxBlock(builder, spoolTxBlock);
6736
+ const sCoinTxBlock = newSCoinTxBlock(builder, spoolTxBlock);
6737
+ const coreTxBlock = newCoreTxBlock(builder, sCoinTxBlock);
6221
6738
  return new Proxy(coreTxBlock, {
6222
6739
  get: (target, prop) => {
6223
6740
  if (prop in vescaTxBlock) {
@@ -6230,6 +6747,8 @@ var newScallopTxBlock = (builder, initTxBlock) => {
6230
6747
  return Reflect.get(spoolTxBlock, prop);
6231
6748
  } else if (prop in loyaltyTxBlock) {
6232
6749
  return Reflect.get(loyaltyTxBlock, prop);
6750
+ } else if (prop in sCoinTxBlock) {
6751
+ return Reflect.get(sCoinTxBlock, prop);
6233
6752
  }
6234
6753
  return Reflect.get(target, prop);
6235
6754
  }
@@ -6240,7 +6759,7 @@ var newScallopTxBlock = (builder, initTxBlock) => {
6240
6759
  var ScallopBuilder = class {
6241
6760
  constructor(params, instance) {
6242
6761
  this.params = params;
6243
- this.suiKit = instance?.suiKit ?? new import_sui_kit11.SuiKit(params);
6762
+ this.suiKit = instance?.suiKit ?? new import_sui_kit12.SuiKit(params);
6244
6763
  this.cache = instance?.cache ?? new ScallopCache(DEFAULT_CACHE_OPTIONS, this.suiKit);
6245
6764
  this.address = instance?.address ?? new ScallopAddress(
6246
6765
  {
@@ -6260,7 +6779,7 @@ var ScallopBuilder = class {
6260
6779
  query: this.query,
6261
6780
  cache: this.cache
6262
6781
  });
6263
- this.walletAddress = (0, import_utils21.normalizeSuiAddress)(
6782
+ this.walletAddress = (0, import_utils22.normalizeSuiAddress)(
6264
6783
  params?.walletAddress || this.suiKit.currentAddress()
6265
6784
  );
6266
6785
  this.isTestnet = params.networkType ? params.networkType === "testnet" : false;
@@ -6300,7 +6819,7 @@ var ScallopBuilder = class {
6300
6819
  */
6301
6820
  async selectCoin(txBlock, assetCoinName, amount, sender) {
6302
6821
  const coinType = this.utils.parseCoinType(assetCoinName);
6303
- const coins = await this.utils.selectCoinIds(amount, coinType, sender);
6822
+ const coins = await this.utils.selectCoins(amount, coinType, sender);
6304
6823
  const [takeCoin, leftCoin] = txBlock.takeAmountFromCoins(coins, amount);
6305
6824
  return { takeCoin, leftCoin };
6306
6825
  }
@@ -6315,13 +6834,42 @@ var ScallopBuilder = class {
6315
6834
  */
6316
6835
  async selectMarketCoin(txBlock, marketCoinName, amount, sender) {
6317
6836
  const marketCoinType = this.utils.parseMarketCoinType(marketCoinName);
6318
- const coins = await this.utils.selectCoinIds(
6319
- amount,
6320
- marketCoinType,
6321
- sender
6837
+ const coins = await this.utils.selectCoins(amount, marketCoinType, sender);
6838
+ const totalAmount = coins.reduce((prev, coin) => {
6839
+ prev += Number(coin.balance);
6840
+ return prev;
6841
+ }, 0);
6842
+ const [takeCoin, leftCoin] = txBlock.takeAmountFromCoins(
6843
+ coins,
6844
+ Math.min(amount, totalAmount)
6322
6845
  );
6323
- const [takeCoin, leftCoin] = txBlock.takeAmountFromCoins(coins, amount);
6324
- return { takeCoin, leftCoin };
6846
+ return { takeCoin, leftCoin, totalAmount };
6847
+ }
6848
+ /**
6849
+ * Specifying the sender's amount of sCoins to get coins args from transaction result.
6850
+ *
6851
+ * @param txBlock - Scallop txBlock or txBlock created by SuiKit .
6852
+ * @param marketCoinName - Specific support sCoin name.
6853
+ * @param amount - Amount of coins to be selected.
6854
+ * @param sender - Sender address.
6855
+ * @return Take coin and left coin.
6856
+ */
6857
+ async selectSCoin(txBlock, sCoinName, amount, sender) {
6858
+ const sCoinType = this.utils.parseSCoinType(sCoinName);
6859
+ const coins = await this.utils.selectCoins(amount, sCoinType, sender);
6860
+ const totalAmount = coins.reduce((prev, coin) => {
6861
+ prev += Number(coin.balance);
6862
+ return prev;
6863
+ }, 0);
6864
+ const [takeCoin, leftCoin] = txBlock.takeAmountFromCoins(
6865
+ coins,
6866
+ Math.min(totalAmount, amount)
6867
+ );
6868
+ return {
6869
+ takeCoin,
6870
+ leftCoin,
6871
+ totalAmount
6872
+ };
6325
6873
  }
6326
6874
  /**
6327
6875
  * Execute Scallop txBlock using the `signAndSendTxn` methods in suikit.
@@ -6339,7 +6887,7 @@ var ScallopBuilder = class {
6339
6887
  var ScallopClient = class {
6340
6888
  constructor(params, instance) {
6341
6889
  this.params = params;
6342
- this.suiKit = instance?.suiKit ?? new import_sui_kit12.SuiKit(params);
6890
+ this.suiKit = instance?.suiKit ?? new import_sui_kit13.SuiKit(params);
6343
6891
  this.cache = instance?.cache ?? new ScallopCache(DEFAULT_CACHE_OPTIONS, this.suiKit);
6344
6892
  this.address = instance?.address ?? new ScallopAddress(
6345
6893
  {
@@ -6366,7 +6914,7 @@ var ScallopClient = class {
6366
6914
  utils: this.utils,
6367
6915
  cache: this.cache
6368
6916
  });
6369
- this.walletAddress = (0, import_utils22.normalizeSuiAddress)(
6917
+ this.walletAddress = (0, import_utils23.normalizeSuiAddress)(
6370
6918
  params?.walletAddress || this.suiKit.currentAddress()
6371
6919
  );
6372
6920
  }
@@ -6846,6 +7394,98 @@ var ScallopClient = class {
6846
7394
  return txBlock.txBlock;
6847
7395
  }
6848
7396
  }
7397
+ /* ==================== Migrate market coin to sCoin method ==================== */
7398
+ /**
7399
+ * Function to migrate all market coin in user wallet into sCoin
7400
+ * @returns Transaction response
7401
+ */
7402
+ async migrateAllMarketCoin(sign = true) {
7403
+ const txBlock = this.builder.createTxBlock();
7404
+ txBlock.setSender(this.walletAddress);
7405
+ const toTransfer = [];
7406
+ await Promise.all(
7407
+ SUPPORT_SCOIN.map(async (sCoinName) => {
7408
+ let toDestroyMarketCoin;
7409
+ try {
7410
+ const marketCoins2 = await this.utils.selectCoins(
7411
+ Number.MAX_SAFE_INTEGER,
7412
+ this.utils.parseMarketCoinType(sCoinName),
7413
+ this.walletAddress
7414
+ );
7415
+ const mergedMarketCoin = marketCoins2[0];
7416
+ if (marketCoins2.length > 1) {
7417
+ txBlock.mergeCoins(mergedMarketCoin, marketCoins2.slice(1));
7418
+ }
7419
+ toDestroyMarketCoin = mergedMarketCoin;
7420
+ } catch (e) {
7421
+ const errMsg = e.toString();
7422
+ if (!errMsg.includes("No valid coins found for the transaction"))
7423
+ throw e;
7424
+ }
7425
+ if (SUPPORT_SPOOLS.includes(sCoinName)) {
7426
+ try {
7427
+ const stakedMarketCoins = await txBlock.unstakeQuick(
7428
+ Number.MAX_SAFE_INTEGER,
7429
+ sCoinName
7430
+ );
7431
+ if (stakedMarketCoins.length > 0) {
7432
+ const mergedStakedMarketCoin = stakedMarketCoins[0];
7433
+ if (stakedMarketCoins.length > 1) {
7434
+ txBlock.mergeCoins(
7435
+ mergedStakedMarketCoin,
7436
+ stakedMarketCoins.slice(1)
7437
+ );
7438
+ }
7439
+ if (toDestroyMarketCoin) {
7440
+ txBlock.mergeCoins(toDestroyMarketCoin, [
7441
+ mergedStakedMarketCoin
7442
+ ]);
7443
+ } else {
7444
+ toDestroyMarketCoin = mergedStakedMarketCoin;
7445
+ }
7446
+ }
7447
+ } catch (e) {
7448
+ const errMsg = e.toString();
7449
+ if (!errMsg.includes("No stake account found"))
7450
+ throw e;
7451
+ }
7452
+ }
7453
+ if (toDestroyMarketCoin) {
7454
+ const sCoin = txBlock.mintSCoin(
7455
+ sCoinName,
7456
+ toDestroyMarketCoin
7457
+ );
7458
+ try {
7459
+ const existSCoins = await this.utils.selectCoins(
7460
+ Number.MAX_SAFE_INTEGER,
7461
+ this.utils.parseSCoinType(sCoinName),
7462
+ this.walletAddress
7463
+ );
7464
+ const mergedSCoin = existSCoins[0];
7465
+ if (existSCoins.length > 1) {
7466
+ txBlock.mergeCoins(mergedSCoin, existSCoins.slice(1));
7467
+ }
7468
+ txBlock.mergeCoins(sCoin, [mergedSCoin]);
7469
+ } catch (e) {
7470
+ const errMsg = e.toString();
7471
+ if (!errMsg.includes("No valid coins found for the transaction"))
7472
+ throw e;
7473
+ }
7474
+ toTransfer.push(sCoin);
7475
+ }
7476
+ })
7477
+ );
7478
+ if (toTransfer.length > 0) {
7479
+ txBlock.transferObjects(toTransfer, this.walletAddress);
7480
+ }
7481
+ if (sign) {
7482
+ return await this.suiKit.signAndSendTxn(
7483
+ txBlock
7484
+ );
7485
+ } else {
7486
+ return txBlock.txBlock;
7487
+ }
7488
+ }
6849
7489
  async mintTestCoin(assetCoinName, amount, sign = true, receiveAddress) {
6850
7490
  const isTestnet = this.params.networkType ? this.params.networkType === "testnet" : false;
6851
7491
  if (!isTestnet) {
@@ -6872,7 +7512,7 @@ var ScallopClient = class {
6872
7512
  var Scallop = class {
6873
7513
  constructor(params, cacheOptions) {
6874
7514
  this.params = params;
6875
- this.suiKit = new import_sui_kit13.SuiKit(params);
7515
+ this.suiKit = new import_sui_kit14.SuiKit(params);
6876
7516
  this.cache = new ScallopCache(
6877
7517
  cacheOptions ?? DEFAULT_CACHE_OPTIONS,
6878
7518
  this.suiKit
@@ -6972,6 +7612,7 @@ var Scallop = class {
6972
7612
  ADDRESSES_ID,
6973
7613
  API_BASE_URL,
6974
7614
  BORROW_FEE_PROTOCOL_ID,
7615
+ FlashLoanFeeObjectMap,
6975
7616
  IS_VE_SCA_TEST,
6976
7617
  MAX_LOCK_DURATION,
6977
7618
  MAX_LOCK_ROUNDS,
@@ -6987,6 +7628,7 @@ var Scallop = class {
6987
7628
  SUPPORT_ORACLES,
6988
7629
  SUPPORT_PACKAGES,
6989
7630
  SUPPORT_POOLS,
7631
+ SUPPORT_SCOIN,
6990
7632
  SUPPORT_SPOOLS,
6991
7633
  SUPPORT_SPOOLS_REWARDS,
6992
7634
  Scallop,
@@ -6998,11 +7640,14 @@ var Scallop = class {
6998
7640
  ScallopQuery,
6999
7641
  ScallopUtils,
7000
7642
  UNLOCK_ROUND_DURATION,
7643
+ USE_TEST_ADDRESS,
7001
7644
  assetCoins,
7002
7645
  borrowIncentiveRewardCoins,
7003
7646
  coinDecimals,
7004
7647
  coinIds,
7005
7648
  marketCoins,
7649
+ sCoinIds,
7650
+ sCoins,
7006
7651
  spoolRewardCoins,
7007
7652
  stakeMarketCoins,
7008
7653
  voloCoinIds,