@scallop-io/sui-scallop-sdk 1.4.15-rc.2 → 1.4.16

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 (69) hide show
  1. package/dist/constants/common.d.ts +6 -6
  2. package/dist/constants/enum.d.ts +2 -2
  3. package/dist/constants/index.d.ts +0 -1
  4. package/dist/constants/poolAddress.d.ts +2 -0
  5. package/dist/constants/queryKeys.d.ts +3 -4
  6. package/dist/index.d.ts +0 -1
  7. package/dist/index.js +2087 -1617
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.mjs +2054 -1579
  10. package/dist/index.mjs.map +1 -1
  11. package/dist/models/scallop.d.ts +1 -2
  12. package/dist/models/scallopBuilder.d.ts +2 -1
  13. package/dist/models/scallopCache.d.ts +18 -12
  14. package/dist/models/scallopQuery.d.ts +98 -11
  15. package/dist/models/scallopUtils.d.ts +4 -4
  16. package/dist/queries/borrowIncentiveQuery.d.ts +6 -1
  17. package/dist/queries/coreQuery.d.ts +2 -0
  18. package/dist/queries/objectsQuery.d.ts +1 -2
  19. package/dist/queries/poolAddressesQuery.d.ts +5 -1
  20. package/dist/queries/portfolioQuery.d.ts +71 -5
  21. package/dist/queries/priceQuery.d.ts +4 -0
  22. package/dist/queries/sCoinQuery.d.ts +1 -1
  23. package/dist/types/builder/core.d.ts +6 -6
  24. package/dist/types/model.d.ts +8 -2
  25. package/dist/utils/index.d.ts +0 -2
  26. package/package.json +7 -7
  27. package/src/builders/borrowIncentiveBuilder.ts +11 -5
  28. package/src/builders/coreBuilder.ts +62 -33
  29. package/src/builders/loyaltyProgramBuilder.ts +3 -2
  30. package/src/builders/referralBuilder.ts +16 -6
  31. package/src/builders/sCoinBuilder.ts +6 -4
  32. package/src/builders/spoolBuilder.ts +14 -7
  33. package/src/builders/vescaBuilder.ts +13 -7
  34. package/src/constants/coinGecko.ts +2 -0
  35. package/src/constants/common.ts +7 -1
  36. package/src/constants/enum.ts +46 -20
  37. package/src/constants/index.ts +0 -1
  38. package/src/constants/poolAddress.ts +252 -66
  39. package/src/constants/pyth.ts +2 -0
  40. package/src/constants/queryKeys.ts +7 -9
  41. package/src/constants/testAddress.ts +24 -0
  42. package/src/index.ts +0 -1
  43. package/src/models/scallop.ts +9 -13
  44. package/src/models/scallopAddress.ts +2 -9
  45. package/src/models/scallopBuilder.ts +62 -8
  46. package/src/models/scallopCache.ts +236 -82
  47. package/src/models/scallopClient.ts +4 -6
  48. package/src/models/scallopIndexer.ts +1 -5
  49. package/src/models/scallopQuery.ts +62 -25
  50. package/src/models/scallopUtils.ts +9 -13
  51. package/src/queries/borrowIncentiveQuery.ts +6 -13
  52. package/src/queries/coreQuery.ts +88 -54
  53. package/src/queries/loyaltyProgramQuery.ts +1 -3
  54. package/src/queries/objectsQuery.ts +1 -3
  55. package/src/queries/poolAddressesQuery.ts +16 -7
  56. package/src/queries/portfolioQuery.ts +253 -21
  57. package/src/queries/priceQuery.ts +2 -7
  58. package/src/queries/sCoinQuery.ts +2 -2
  59. package/src/queries/spoolQuery.ts +21 -20
  60. package/src/queries/vescaQuery.ts +3 -7
  61. package/src/types/builder/core.ts +24 -5
  62. package/src/types/model.ts +13 -2
  63. package/src/utils/index.ts +0 -2
  64. package/src/utils/indexer.ts +3 -1
  65. package/src/utils/query.ts +2 -2
  66. package/dist/constants/tokenBucket.d.ts +0 -2
  67. package/dist/utils/tokenBucket.d.ts +0 -11
  68. package/src/constants/tokenBucket.ts +0 -2
  69. package/src/utils/tokenBucket.ts +0 -68
package/dist/index.mjs CHANGED
@@ -12,6 +12,7 @@ var DEFAULT_CACHE_OPTIONS = {
12
12
  var COIN_GECKGO_IDS = {
13
13
  usdc: "usdc",
14
14
  sbeth: "ethereum",
15
+ sbusdt: "tether",
15
16
  weth: "ethereum",
16
17
  wbtc: "bitcoin",
17
18
  wusdc: "usdc",
@@ -24,6 +25,7 @@ var COIN_GECKGO_IDS = {
24
25
  hasui: "sui",
25
26
  vsui: "sui",
26
27
  sca: "scallop-2",
28
+ fdusd: "first-digital-usd",
27
29
  deep: "deepbook",
28
30
  fud: "fud-the-pug"
29
31
  };
@@ -43,6 +45,8 @@ var SUPPORT_POOLS = [
43
45
  // native USDC
44
46
  "sbeth",
45
47
  // sui bridge ETH
48
+ "sbusdt",
49
+ // sui bridge USDT
46
50
  "weth",
47
51
  "wbtc",
48
52
  "wusdc",
@@ -56,13 +60,16 @@ var SUPPORT_POOLS = [
56
60
  "vsui",
57
61
  "sca",
58
62
  "fud",
59
- "deep"
63
+ "deep",
64
+ "fdusd"
60
65
  ];
61
66
  var SUPPORT_COLLATERALS = [
62
67
  "usdc",
63
68
  // native USDC
64
69
  "sbeth",
65
70
  // sui bridge ETH
71
+ "sbusdt",
72
+ // sui bridge USDT
66
73
  "weth",
67
74
  "wbtc",
68
75
  "wusdc",
@@ -74,7 +81,8 @@ var SUPPORT_COLLATERALS = [
74
81
  "afsui",
75
82
  "hasui",
76
83
  "vsui",
77
- "sca"
84
+ "sca",
85
+ "fdusd"
78
86
  ];
79
87
  var SUPPORT_SPOOLS = [
80
88
  "susdc",
@@ -90,6 +98,7 @@ var SUPPORT_SPOOLS = [
90
98
  var SUPPORT_SCOIN = [
91
99
  "susdc",
92
100
  "ssbeth",
101
+ "ssbusdt",
93
102
  "ssui",
94
103
  "swusdc",
95
104
  "swusdt",
@@ -102,9 +111,10 @@ var SUPPORT_SCOIN = [
102
111
  "swsol",
103
112
  "swbtc",
104
113
  "sdeep",
105
- "sfud"
114
+ "sfud",
115
+ "sfdusd"
106
116
  ];
107
- var SUPPORT_SUI_BRIDGE = ["sbeth"];
117
+ var SUPPORT_SUI_BRIDGE = ["sbeth", "sbusdt"];
108
118
  var SUPPORT_WORMHOLE = [
109
119
  "wusdc",
110
120
  "wusdt",
@@ -139,6 +149,7 @@ var SUPPORT_PACKAGES = [
139
149
  var coinDecimals = {
140
150
  usdc: 6,
141
151
  sbeth: 8,
152
+ sbusdt: 6,
142
153
  weth: 8,
143
154
  wbtc: 8,
144
155
  wusdc: 6,
@@ -151,11 +162,13 @@ var coinDecimals = {
151
162
  hasui: 9,
152
163
  vsui: 9,
153
164
  sca: 9,
165
+ fdusd: 6,
154
166
  deep: 6,
155
167
  fud: 5,
156
168
  susdc: 6,
157
169
  sweth: 8,
158
170
  ssbeth: 8,
171
+ ssbusdt: 6,
159
172
  swbtc: 8,
160
173
  swusdc: 6,
161
174
  swusdt: 6,
@@ -167,12 +180,14 @@ var coinDecimals = {
167
180
  shasui: 9,
168
181
  svsui: 9,
169
182
  ssca: 9,
183
+ sfdusd: 6,
170
184
  sdeep: 6,
171
185
  sfud: 5
172
186
  };
173
187
  var assetCoins = {
174
188
  usdc: "usdc",
175
189
  sbeth: "sbeth",
190
+ sbusdt: "sbusdt",
176
191
  weth: "weth",
177
192
  wbtc: "wbtc",
178
193
  wusdc: "wusdc",
@@ -185,12 +200,14 @@ var assetCoins = {
185
200
  hasui: "hasui",
186
201
  vsui: "vsui",
187
202
  sca: "sca",
203
+ fdusd: "fdusd",
188
204
  deep: "deep",
189
205
  fud: "fud"
190
206
  };
191
207
  var marketCoins = {
192
208
  susdc: "susdc",
193
209
  ssbeth: "ssbeth",
210
+ ssbusdt: "ssbusdt",
194
211
  sweth: "sweth",
195
212
  swbtc: "swbtc",
196
213
  swusdc: "swusdc",
@@ -203,12 +220,14 @@ var marketCoins = {
203
220
  shasui: "shasui",
204
221
  svsui: "svsui",
205
222
  ssca: "ssca",
223
+ sfdusd: "sfdusd",
206
224
  sdeep: "sdeep",
207
225
  sfud: "sfud"
208
226
  };
209
227
  var sCoins = {
210
228
  susdc: "susdc",
211
229
  ssbeth: "ssbeth",
230
+ ssbusdt: "ssbusdt",
212
231
  sweth: "sweth",
213
232
  swusdc: "swusdc",
214
233
  swusdt: "swusdt",
@@ -220,6 +239,7 @@ var sCoins = {
220
239
  ssca: "ssca",
221
240
  swsol: "swsol",
222
241
  swbtc: "swbtc",
242
+ sfdusd: "sfdusd",
223
243
  sfud: "sfud",
224
244
  sdeep: "sdeep"
225
245
  };
@@ -246,26 +266,33 @@ var spoolRewardCoins = {
246
266
  susdc: "sui"
247
267
  };
248
268
  var suiBridgeCoins = {
249
- sbeth: "sbeth"
269
+ sbeth: "sbeth",
270
+ sbusdt: "sbusdt"
250
271
  };
251
272
  var coinIds = {
252
- usdc: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7",
253
273
  sui: "0x0000000000000000000000000000000000000000000000000000000000000002",
254
- sbeth: "0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29",
274
+ cetus: "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b",
275
+ sca: IS_VE_SCA_TEST ? "0x6cd813061a3adf3602b76545f076205f0c8e7ec1d3b1eab9a1da7992c18c0524" : "0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6",
276
+ // Wormhole assets
255
277
  weth: "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5",
256
278
  wbtc: "0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881",
257
- wusdc: "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf",
258
- wusdt: "0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c",
259
279
  wapt: "0x3a5143bb1196e3bcdfab6203d1683ae29edd26294fc8bfeafe4aaa9d2704df37",
260
280
  wsol: "0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8",
261
- cetus: "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b",
281
+ // Sui LST
262
282
  afsui: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc",
263
283
  hasui: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d",
264
284
  vsui: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55",
265
- sca: IS_VE_SCA_TEST ? "0x6cd813061a3adf3602b76545f076205f0c8e7ec1d3b1eab9a1da7992c18c0524" : "0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6",
285
+ // stable coins
286
+ usdc: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7",
287
+ wusdc: "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf",
288
+ wusdt: "0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c",
289
+ fdusd: "0xf16e6b723f242ec745dfd7634ad072c42d5c1d9ac9d62a39c381303eaa57693a",
266
290
  // isolated assets
267
291
  deep: "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270",
268
- fud: "0x76cb819b01abed502bee8a702b4c2d547532c12f25001c9dea795a5e631c26f1"
292
+ fud: "0x76cb819b01abed502bee8a702b4c2d547532c12f25001c9dea795a5e631c26f1",
293
+ // Sui bridge assets
294
+ sbeth: "0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29",
295
+ sbusdt: "0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068"
269
296
  };
270
297
  var wormholeCoinIds = {
271
298
  weth: "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5",
@@ -279,21 +306,28 @@ var voloCoinIds = {
279
306
  vsui: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55"
280
307
  };
281
308
  var sCoinIds = {
282
- susdc: "0x854950aa624b1df59fe64e630b2ba7c550642e9342267a33061d59fb31582da5::scallop_usdc::SCALLOP_USDC",
283
- ssbeth: "0xb14f82d8506d139eacef109688d1b71e7236bcce9b2c0ad526abcd6aa5be7de0::scallop_sb_eth::SCALLOP_SB_ETH",
284
309
  ssui: "0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI",
285
- swusdc: "0xad4d71551d31092230db1fd482008ea42867dbf27b286e9c70a79d2a6191d58d::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC",
286
- swusdt: "0xe6e5a012ec20a49a3d1d57bd2b67140b96cd4d3400b9d79e541f7bdbab661f95::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT",
287
310
  ssca: "0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA",
288
311
  scetus: "0xea346ce428f91ab007210443efcea5f5cdbbb3aae7e9affc0ca93f9203c31f0c::scallop_cetus::SCALLOP_CETUS",
312
+ // Wormhole assets
289
313
  sweth: "0x67540ceb850d418679e69f1fb6b2093d6df78a2a699ffc733f7646096d552e9b::scallop_wormhole_eth::SCALLOP_WORMHOLE_ETH",
314
+ swsol: "0x1392650f2eca9e3f6ffae3ff89e42a3590d7102b80e2b430f674730bc30d3259::scallop_wormhole_sol::SCALLOP_WORMHOLE_SOL",
315
+ swbtc: "0x2cf76a9cf5d3337961d1154283234f94da2dcff18544dfe5cbdef65f319591b5::scallop_wormhole_btc::SCALLOP_WORMHOLE_BTC",
316
+ // Sui LST
290
317
  safsui: "0x00671b1fa2a124f5be8bdae8b91ee711462c5d9e31bda232e70fd9607b523c88::scallop_af_sui::SCALLOP_AF_SUI",
291
318
  shasui: "0x9a2376943f7d22f88087c259c5889925f332ca4347e669dc37d54c2bf651af3c::scallop_ha_sui::SCALLOP_HA_SUI",
292
319
  svsui: "0xe1a1cc6bcf0001a015eab84bcc6713393ce20535f55b8b6f35c142e057a25fbe::scallop_v_sui::SCALLOP_V_SUI",
293
- swsol: "0x1392650f2eca9e3f6ffae3ff89e42a3590d7102b80e2b430f674730bc30d3259::scallop_wormhole_sol::SCALLOP_WORMHOLE_SOL",
294
- swbtc: "0x2cf76a9cf5d3337961d1154283234f94da2dcff18544dfe5cbdef65f319591b5::scallop_wormhole_btc::SCALLOP_WORMHOLE_BTC",
320
+ // stable coins
321
+ susdc: "0x854950aa624b1df59fe64e630b2ba7c550642e9342267a33061d59fb31582da5::scallop_usdc::SCALLOP_USDC",
322
+ swusdc: "0xad4d71551d31092230db1fd482008ea42867dbf27b286e9c70a79d2a6191d58d::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC",
323
+ swusdt: "0xe6e5a012ec20a49a3d1d57bd2b67140b96cd4d3400b9d79e541f7bdbab661f95::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT",
324
+ sfdusd: "0x6711551c1e7652a270d9fbf0eee25d99594c157cde3cb5fbb49035eb59b1b001::scallop_fdusd::SCALLOP_FDUSD",
325
+ // isolated assets
295
326
  sdeep: "0xeb7a05a3224837c5e5503575aed0be73c091d1ce5e43aa3c3e716e0ae614608f::scallop_deep::SCALLOP_DEEP",
296
- sfud: "0xe56d5167f427cbe597da9e8150ef5c337839aaf46891d62468dcf80bdd8e10d1::scallop_fud::SCALLOP_FUD"
327
+ sfud: "0xe56d5167f427cbe597da9e8150ef5c337839aaf46891d62468dcf80bdd8e10d1::scallop_fud::SCALLOP_FUD",
328
+ // Sui bridge assets
329
+ ssbeth: "0xb14f82d8506d139eacef109688d1b71e7236bcce9b2c0ad526abcd6aa5be7de0::scallop_sb_eth::SCALLOP_SB_ETH",
330
+ ssbusdt: "0xb1d7df34829d1513b73ba17cb7ad90c88d1e104bb65ab8f62f13e0cc103783d3::scallop_sb_usdt::SCALLOP_SB_USDT"
297
331
  };
298
332
  var sCoinTypeToName = Object.entries(sCoinIds).reduce(
299
333
  (acc, [coinName, coinType]) => {
@@ -328,6 +362,40 @@ var FlashLoanFeeObjectMap = {
328
362
 
329
363
  // src/constants/poolAddress.ts
330
364
  var POOL_ADDRESSES = {
365
+ usdc: {
366
+ lendingPoolAddress: "0xd3be98bf540f7603eeb550c0c0a19dbfc78822f25158b5fa84ebd9609def415f",
367
+ collateralPoolAddress: "0x8f0d529ba179c5b3d508213003eab813aaae31f78226099639b9a69d1aec17af",
368
+ borrowDynamic: "0x77837ecd4f26fac9a410fff594f2c0bd3288904a15492ca77cb8a52684dbb866",
369
+ interestModel: "0xaae3f179d63009380cbdcb9acb12907afc9c3cb79cc3460be296a9c6d28f3ff3",
370
+ riskModel: "0x198b24db213bfeb8b3c80ae63dde92e32fd24984d25da8233ff777b851edd574",
371
+ borrowFeeKey: "0xd37c5316cfe0a5967d14264fa6b423f880518b294a1ee6581ccbb49ccc401fb8",
372
+ supplyLimitKey: "0x4be9ae54ac4d320f4f9c14cae78cb85c8e0e67791dd9bdba6d2db20614a28a24",
373
+ borrowLimitKey: "0x6b01093cba95b835181f00e3a2c31ed8dfc8d64fe3db0fb80933a09f66e1ccf1",
374
+ isolatedAssetKey: void 0,
375
+ spool: "0x0b5f5f413bd3799e4052c37311966c77f3a4545eb125d2e93e67a68478021918",
376
+ spoolReward: "0x85ed6ed72ea97c35dbf0cdc7ed6fbc48d8ec15de9b17c74bf4512df8a6d7f166",
377
+ sCoinTreasury: "0xbe6b63021f3d82e0e7e977cdd718ed7c019cf2eba374b7b546220402452f938e",
378
+ sCoinType: "0x854950aa624b1df59fe64e630b2ba7c550642e9342267a33061d59fb31582da5::scallop_usdc::SCALLOP_USDC",
379
+ coinMetadataId: "0x69b7a7c3c200439c1b5f3b19d7d495d5966d5f08de66c69276152f8db3992ec6",
380
+ coinType: "dba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC"
381
+ },
382
+ sbusdt: {
383
+ lendingPoolAddress: "0x958ca02058a7dd8b00e26ed6988f45d7c2834ae2a47ee4c4a8fdedea155f18ca",
384
+ collateralPoolAddress: "0x63c861f97192ceab2dabb1e74649ae87a9e36c33aaedcc43e40a811d3a39e653",
385
+ borrowDynamic: "0xf1ef9a19881ed6ddeb88f361c83f37c592ec5b9c64fe715383f63ccc094be205",
386
+ interestModel: "0x62c46e4667c4fa69a29030ecbc0f661c61365d02adc3810b08b11cfd8f42ca1c",
387
+ riskModel: "0x59d5f3dbcd14a0aab6ee6e2879803e10b0a752119d19c4ac0bd389d71dc8c2bf",
388
+ borrowFeeKey: "0xa418990ad042e97cca61830476483933b9e026970fc33451072b2627ccb31da2",
389
+ supplyLimitKey: "0x93641bfb62ea40760f0c15911b4ec0eb866f8725e36b0ca9a786775d93629139",
390
+ borrowLimitKey: "0x953a9b8d5353abb38db21a2cbbc5c54f8f23348895acb26cbe2c0ab61b54635d",
391
+ isolatedAssetKey: void 0,
392
+ spool: void 0,
393
+ spoolReward: void 0,
394
+ sCoinTreasury: "0x58bdf6a9752e3a60144d0b70e8608d630dfd971513e2b2bfa7282f5eaa7d04d8",
395
+ sCoinType: "0xb1d7df34829d1513b73ba17cb7ad90c88d1e104bb65ab8f62f13e0cc103783d3::scallop_sb_usdt::SCALLOP_SB_USDT",
396
+ coinMetadataId: "0xda61b33ac61ed4c084bbda65a2229459ed4eb2185729e70498538f0688bec3cc",
397
+ coinType: "0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT"
398
+ },
331
399
  sbeth: {
332
400
  lendingPoolAddress: "0xaa34c938e0394e5186c7dc626ad69be96af2194b23fdc6ac1c63090e399f5ba4",
333
401
  collateralPoolAddress: "0xce0549a1cbe952e734f56646988e6b02bbae14667889a60e24d0d03540a6119f",
@@ -339,20 +407,28 @@ var POOL_ADDRESSES = {
339
407
  borrowLimitKey: "0x165c274c67eda2b0d13563124741fffd0ce7d643f4c1c4b59d7e53a83796ae25",
340
408
  isolatedAssetKey: void 0,
341
409
  spool: void 0,
342
- spoolReward: void 0
410
+ spoolReward: void 0,
411
+ sCoinTreasury: "0xfd0f02def6358a1f266acfa1493d4707ee8387460d434fb667d63d755ff907ed",
412
+ sCoinType: "0xb14f82d8506d139eacef109688d1b71e7236bcce9b2c0ad526abcd6aa5be7de0::scallop_sb_eth::SCALLOP_SB_ETH",
413
+ coinMetadataId: "0x89b04ba87f8832d4d76e17a1c9dce72eb3e64d372cf02012b8d2de5384faeef0",
414
+ coinType: "d0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29::eth::ETH"
343
415
  },
344
- usdc: {
345
- lendingPoolAddress: "0xd3be98bf540f7603eeb550c0c0a19dbfc78822f25158b5fa84ebd9609def415f",
346
- collateralPoolAddress: "0x8f0d529ba179c5b3d508213003eab813aaae31f78226099639b9a69d1aec17af",
347
- borrowDynamic: "0x77837ecd4f26fac9a410fff594f2c0bd3288904a15492ca77cb8a52684dbb866",
348
- interestModel: "0xaae3f179d63009380cbdcb9acb12907afc9c3cb79cc3460be296a9c6d28f3ff3",
349
- riskModel: "0x198b24db213bfeb8b3c80ae63dde92e32fd24984d25da8233ff777b851edd574",
350
- borrowFeeKey: "0xd37c5316cfe0a5967d14264fa6b423f880518b294a1ee6581ccbb49ccc401fb8",
351
- supplyLimitKey: "0x4be9ae54ac4d320f4f9c14cae78cb85c8e0e67791dd9bdba6d2db20614a28a24",
352
- borrowLimitKey: "0x6b01093cba95b835181f00e3a2c31ed8dfc8d64fe3db0fb80933a09f66e1ccf1",
416
+ weth: {
417
+ lendingPoolAddress: "0xc8fcdff48efc265740ae0b74aae3faccae9ec00034039a113f3339798035108c",
418
+ collateralPoolAddress: "0xad7ced91ed6e7f2b81805561eee27fa6f3e72fdae561077334c7248583db4dbf",
419
+ borrowDynamic: "0xd1578e1d1c9c82eb4c5bf14beece8142a67a683b2647d7276e92984119fc1445",
420
+ interestModel: "0xa1dc08541cd2cb7cfb4e56272292d5c6a4780e80fd210c58abffae98268b5ed9",
421
+ riskModel: "0x9f05a25fd33a9e8cf33962126b175d038e184f0ee1b87dc41d4cedbe6abebbe5",
422
+ borrowFeeKey: "0x29672ba8ab4625b8181d8ed739e5344de22a97d417748c4d1276c7379283d7a3",
423
+ supplyLimitKey: "0x2b957941bdc9432bbc83ab74dc194b6ebb7c927bc4c6926a5492b5503499e509",
424
+ borrowLimitKey: "0x51f256d87e51a7ca2b1c482923096f4b6dac6beac89d8ecf4c65b7d5764115d6",
353
425
  isolatedAssetKey: void 0,
354
- spool: "0x0b5f5f413bd3799e4052c37311966c77f3a4545eb125d2e93e67a68478021918",
355
- spoolReward: "0x85ed6ed72ea97c35dbf0cdc7ed6fbc48d8ec15de9b17c74bf4512df8a6d7f166"
426
+ spool: "0xeec40beccb07c575bebd842eeaabb835f77cd3dab73add433477e57f583a6787",
427
+ spoolReward: "0x957de68a18d87817de8309b30c1ec269a4d87ae513abbeed86b5619cb9ce1077",
428
+ sCoinTreasury: "0x4b7f5da0e306c9d52490a0c1d4091e653d6b89778b9b4f23c877e534e4d9cd21",
429
+ sCoinType: "0x67540ceb850d418679e69f1fb6b2093d6df78a2a699ffc733f7646096d552e9b::scallop_wormhole_eth::SCALLOP_WORMHOLE_ETH",
430
+ coinMetadataId: "0x8900e4ceede3363bef086d6b50ca89d816d0e90bf6bc46efefe1f8455e08f50f",
431
+ coinType: "af8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5::coin::COIN"
356
432
  },
357
433
  wbtc: {
358
434
  lendingPoolAddress: "0x65cc08a5aca0a0b8d72e1993ded8d145f06dd102fd0d8f285b92934faed564ab",
@@ -365,7 +441,11 @@ var POOL_ADDRESSES = {
365
441
  borrowLimitKey: "0x231e13ba6b1eb26c562f4a125778d3152f9a77e31f124bd6012e234a73012169",
366
442
  isolatedAssetKey: void 0,
367
443
  spool: void 0,
368
- spoolReward: void 0
444
+ spoolReward: void 0,
445
+ sCoinTreasury: "0xe2883934ea42c99bc998bbe0f01dd6d27aa0e27a56455707b1b34e6a41c20baa",
446
+ sCoinType: "0x2cf76a9cf5d3337961d1154283234f94da2dcff18544dfe5cbdef65f319591b5::scallop_wormhole_btc::SCALLOP_WORMHOLE_BTC",
447
+ coinMetadataId: "0x5d3c6e60eeff8a05b693b481539e7847dfe33013e7070cdcb387f5c0cac05dfd",
448
+ coinType: "027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881::coin::COIN"
369
449
  },
370
450
  wusdc: {
371
451
  lendingPoolAddress: "0x2f4df5e1368fbbdaa5c712d28b837b3d41c2d3872979ccededcdfdac55ff8a93",
@@ -378,20 +458,11 @@ var POOL_ADDRESSES = {
378
458
  borrowLimitKey: "0x97f1502ce994db0bcb15aac1760d174def9e88e97cd2262eed54521ee2c19f81",
379
459
  isolatedAssetKey: void 0,
380
460
  spool: "0x4ace6648ddc64e646ba47a957c562c32c9599b3bba8f5ac1aadb2ae23a2f8ca0",
381
- spoolReward: "0xf4268cc9b9413b9bfe09e8966b8de650494c9e5784bf0930759cfef4904daff8"
382
- },
383
- weth: {
384
- lendingPoolAddress: "0xc8fcdff48efc265740ae0b74aae3faccae9ec00034039a113f3339798035108c",
385
- collateralPoolAddress: "0xad7ced91ed6e7f2b81805561eee27fa6f3e72fdae561077334c7248583db4dbf",
386
- borrowDynamic: "0xd1578e1d1c9c82eb4c5bf14beece8142a67a683b2647d7276e92984119fc1445",
387
- interestModel: "0xa1dc08541cd2cb7cfb4e56272292d5c6a4780e80fd210c58abffae98268b5ed9",
388
- riskModel: "0x9f05a25fd33a9e8cf33962126b175d038e184f0ee1b87dc41d4cedbe6abebbe5",
389
- borrowFeeKey: "0x29672ba8ab4625b8181d8ed739e5344de22a97d417748c4d1276c7379283d7a3",
390
- supplyLimitKey: "0x2b957941bdc9432bbc83ab74dc194b6ebb7c927bc4c6926a5492b5503499e509",
391
- borrowLimitKey: "0x51f256d87e51a7ca2b1c482923096f4b6dac6beac89d8ecf4c65b7d5764115d6",
392
- isolatedAssetKey: void 0,
393
- spool: "0xeec40beccb07c575bebd842eeaabb835f77cd3dab73add433477e57f583a6787",
394
- spoolReward: "0x957de68a18d87817de8309b30c1ec269a4d87ae513abbeed86b5619cb9ce1077"
461
+ spoolReward: "0xf4268cc9b9413b9bfe09e8966b8de650494c9e5784bf0930759cfef4904daff8",
462
+ sCoinTreasury: "0x50c5cfcbcca3aaacab0984e4d7ad9a6ad034265bebb440f0d1cd688ec20b2548",
463
+ sCoinType: "0xad4d71551d31092230db1fd482008ea42867dbf27b286e9c70a79d2a6191d58d::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC",
464
+ coinMetadataId: "0x4fbf84f3029bd0c0b77164b587963be957f853eccf834a67bb9ecba6ec80f189",
465
+ coinType: "5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN"
395
466
  },
396
467
  wusdt: {
397
468
  lendingPoolAddress: "0xfbc056f126dd35adc1f8fe985e2cedc8010e687e8e851e1c5b99fdf63cd1c879",
@@ -404,7 +475,11 @@ var POOL_ADDRESSES = {
404
475
  borrowLimitKey: "0xa3278564fc613680a69c10972a0299965bf6e12e9ac171388842fc958de0f90e",
405
476
  isolatedAssetKey: void 0,
406
477
  spool: "0xcb328f7ffa7f9342ed85af3fdb2f22919e1a06dfb2f713c04c73543870d7548f",
407
- spoolReward: "0x2c9f934d67a5baa586ceec2cc24163a2f049a6af3d5ba36b84d8ac40f25c4080"
478
+ spoolReward: "0x2c9f934d67a5baa586ceec2cc24163a2f049a6af3d5ba36b84d8ac40f25c4080",
479
+ sCoinTreasury: "0x1f02e2fed702b477732d4ad6044aaed04f2e8e586a169153694861a901379df0",
480
+ sCoinType: "0xe6e5a012ec20a49a3d1d57bd2b67140b96cd4d3400b9d79e541f7bdbab661f95::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT",
481
+ coinMetadataId: "0xfb0e3eb97dd158a5ae979dddfa24348063843c5b20eb8381dd5fa7c93699e45c",
482
+ coinType: "c060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN"
408
483
  },
409
484
  sui: {
410
485
  lendingPoolAddress: "0x9c9077abf7a29eebce41e33addbcd6f5246a5221dd733e56ea0f00ae1b25c9e8",
@@ -417,7 +492,11 @@ var POOL_ADDRESSES = {
417
492
  borrowLimitKey: "0x2b33a7efdcf6a6df24f4d8a356dd52f58d75bc023c3f171d99502d4d008b53f0",
418
493
  isolatedAssetKey: void 0,
419
494
  spool: "0x4f0ba970d3c11db05c8f40c64a15b6a33322db3702d634ced6536960ab6f3ee4",
420
- spoolReward: "0x162250ef72393a4ad3d46294c4e1bdfcb03f04c869d390e7efbfc995353a7ee9"
495
+ spoolReward: "0x162250ef72393a4ad3d46294c4e1bdfcb03f04c869d390e7efbfc995353a7ee9",
496
+ sCoinTreasury: "0x5c1678c8261ac9eec024d4d630006a9f55c80dc0b1aa38a003fcb1d425818c6b",
497
+ sCoinType: "0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI",
498
+ coinMetadataId: "0x9258181f5ceac8dbffb7030890243caed69a9599d2886d957a9cb7656af3bdb3",
499
+ coinType: "0000000000000000000000000000000000000000000000000000000000000002::sui::SUI"
421
500
  },
422
501
  wapt: {
423
502
  lendingPoolAddress: "0xca8c14a24e0c32b198eaf479a3317461e3cc339097ce88eaf296a15df8dcfdf5",
@@ -430,20 +509,28 @@ var POOL_ADDRESSES = {
430
509
  borrowLimitKey: void 0,
431
510
  isolatedAssetKey: void 0,
432
511
  spool: void 0,
433
- spoolReward: void 0
512
+ spoolReward: void 0,
513
+ sCoinTreasury: void 0,
514
+ sCoinType: void 0,
515
+ coinMetadataId: "0xc969c5251f372c0f34c32759f1d315cf1ea0ee5e4454b52aea08778eacfdd0a8",
516
+ coinType: "3a5143bb1196e3bcdfab6203d1683ae29edd26294fc8bfeafe4aaa9d2704df37::coin::COIN"
434
517
  },
435
- afsui: {
436
- lendingPoolAddress: "0x9b942a24ce390b7f5016d34a0217057bf9487b92aa6d7cc9894271dbbe62471a",
437
- collateralPoolAddress: "0xe5e56f5c0e3072760b21f9d49a5cc793f37d736c412a9065c16e1265c74e6341",
438
- borrowDynamic: "0x1c76d4df9506154a117bbac0f5e005d8a9c0d9ca60e3fe0c9d080006f6f54e81",
439
- interestModel: "0xb155c536b37c9601baaa734ad1dd0ef335b2b597aceb8d3ecee41a43f94dcd70",
440
- riskModel: "0x75371b1d04b5bebc0738af548ba64ea658e74f78228ec8014336d8eebb992312",
441
- borrowFeeKey: "0xabc6422db2d4ee01635ddaeaa44ba68370eebd785d2c4632515f841ae9bc47d9",
442
- supplyLimitKey: "0x61a2054eb37f543c0d774da57f2c9542aad8d79a197f748ac08ef5df6cc47028",
443
- borrowLimitKey: "0x4459498a043872cd107ea917493fee0baf2d37a273c7538e1d6581cc61b92af8",
518
+ cetus: {
519
+ lendingPoolAddress: "0xc09858f60e74a1b671635bec4e8a2c84a0ff313eb87f525fba3258e88c6b6282",
520
+ collateralPoolAddress: "0xe363967e29b7b9c1245d6d46d63e719de8f90b37e3358c545b55d945ea0b676a",
521
+ borrowDynamic: "0xcc725fd5d71990cdccc7e16c88a2abde6dbcd0bf6e805ccc1c0cb83a106bbf4e",
522
+ interestModel: "0x2f1258aab89d04d11834121599ab1317dfecb582b4246f106df399911125845a",
523
+ riskModel: "0x03fed312dbba624dff5edaf4736891a1c7d864445fd268e7572b42ec7381132e",
524
+ borrowFeeKey: "0xdf5fb0cc4ebbf5eebfae23dfa5b266f6a58c18a894a13054ae60c0eb6e79c382",
525
+ supplyLimitKey: "0xa5ea3d4bf663d7bc667e82b40a98923590ff3851b9ea8e7afbc26c588c7007d3",
526
+ borrowLimitKey: "0xf44218a5f0feb128e6fbe74b91d1e7e9ef859bd23a576ff0de151829e015a157",
444
527
  isolatedAssetKey: void 0,
445
- spool: "0xeedf438abcaa6ce4d9625ffca110920592d5867e4c5637d84ad9f466c4feb800",
446
- spoolReward: "0x89255a2f86ed7fbfef35ab8b7be48cc7667015975be2685dd9a55a9a64baf76e"
528
+ spool: "0xac1bb13bf4472a637c18c2415fb0e3c1227ea2bcf35242e50563c98215bd298e",
529
+ spoolReward: "0x6835c1224126a45086fc6406adc249e3f30df18d779ca4f4e570e38716a17f3f",
530
+ sCoinTreasury: "0xa283c63488773c916cb3d6c64109536160d5eb496caddc721eb39aad2977d735",
531
+ sCoinType: "0xea346ce428f91ab007210443efcea5f5cdbbb3aae7e9affc0ca93f9203c31f0c::scallop_cetus::SCALLOP_CETUS",
532
+ coinMetadataId: "0x4c0dce55eff2db5419bbd2d239d1aa22b4a400c01bbb648b058a9883989025da",
533
+ coinType: "06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b::cetus::CETUS"
447
534
  },
448
535
  wsol: {
449
536
  lendingPoolAddress: "0x985682c42984cdfb03f9ff7d8923344c2fe096b1ae4b82ea17721af19d22a21f",
@@ -456,20 +543,28 @@ var POOL_ADDRESSES = {
456
543
  borrowLimitKey: "0x77d453c51948f32564c810bc73f9ba7abde880657b7f89e1c8a3bc28fa36ee87",
457
544
  isolatedAssetKey: void 0,
458
545
  spool: void 0,
459
- spoolReward: void 0
546
+ spoolReward: void 0,
547
+ sCoinTreasury: "0x760fd66f5be869af4382fa32b812b3c67f0eca1bb1ed7a5578b21d56e1848819",
548
+ sCoinType: "0x1392650f2eca9e3f6ffae3ff89e42a3590d7102b80e2b430f674730bc30d3259::scallop_wormhole_sol::SCALLOP_WORMHOLE_SOL",
549
+ coinMetadataId: "0x4d2c39082b4477e3e79dc4562d939147ab90c42fc5f3e4acf03b94383cd69b6e",
550
+ coinType: "b7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8::coin::COIN"
460
551
  },
461
- cetus: {
462
- lendingPoolAddress: "0xc09858f60e74a1b671635bec4e8a2c84a0ff313eb87f525fba3258e88c6b6282",
463
- collateralPoolAddress: "0xe363967e29b7b9c1245d6d46d63e719de8f90b37e3358c545b55d945ea0b676a",
464
- borrowDynamic: "0xcc725fd5d71990cdccc7e16c88a2abde6dbcd0bf6e805ccc1c0cb83a106bbf4e",
465
- interestModel: "0x2f1258aab89d04d11834121599ab1317dfecb582b4246f106df399911125845a",
466
- riskModel: "0x03fed312dbba624dff5edaf4736891a1c7d864445fd268e7572b42ec7381132e",
467
- borrowFeeKey: "0xdf5fb0cc4ebbf5eebfae23dfa5b266f6a58c18a894a13054ae60c0eb6e79c382",
468
- supplyLimitKey: "0xa5ea3d4bf663d7bc667e82b40a98923590ff3851b9ea8e7afbc26c588c7007d3",
469
- borrowLimitKey: "0xf44218a5f0feb128e6fbe74b91d1e7e9ef859bd23a576ff0de151829e015a157",
552
+ afsui: {
553
+ lendingPoolAddress: "0x9b942a24ce390b7f5016d34a0217057bf9487b92aa6d7cc9894271dbbe62471a",
554
+ collateralPoolAddress: "0xe5e56f5c0e3072760b21f9d49a5cc793f37d736c412a9065c16e1265c74e6341",
555
+ borrowDynamic: "0x1c76d4df9506154a117bbac0f5e005d8a9c0d9ca60e3fe0c9d080006f6f54e81",
556
+ interestModel: "0xb155c536b37c9601baaa734ad1dd0ef335b2b597aceb8d3ecee41a43f94dcd70",
557
+ riskModel: "0x75371b1d04b5bebc0738af548ba64ea658e74f78228ec8014336d8eebb992312",
558
+ borrowFeeKey: "0xabc6422db2d4ee01635ddaeaa44ba68370eebd785d2c4632515f841ae9bc47d9",
559
+ supplyLimitKey: "0x61a2054eb37f543c0d774da57f2c9542aad8d79a197f748ac08ef5df6cc47028",
560
+ borrowLimitKey: "0x4459498a043872cd107ea917493fee0baf2d37a273c7538e1d6581cc61b92af8",
470
561
  isolatedAssetKey: void 0,
471
- spool: "0xac1bb13bf4472a637c18c2415fb0e3c1227ea2bcf35242e50563c98215bd298e",
472
- spoolReward: "0x6835c1224126a45086fc6406adc249e3f30df18d779ca4f4e570e38716a17f3f"
562
+ spool: "0xeedf438abcaa6ce4d9625ffca110920592d5867e4c5637d84ad9f466c4feb800",
563
+ spoolReward: "0x89255a2f86ed7fbfef35ab8b7be48cc7667015975be2685dd9a55a9a64baf76e",
564
+ sCoinTreasury: "0x55f4dfe9e40bc4cc11c70fcb1f3daefa2bdc330567c58d4f0792fbd9f9175a62",
565
+ sCoinType: "0x00671b1fa2a124f5be8bdae8b91ee711462c5d9e31bda232e70fd9607b523c88::scallop_af_sui::SCALLOP_AF_SUI",
566
+ coinMetadataId: "0x2f9217f533e51334873a39b8026a4aa6919497b47f49d0986a4f1aec66f8a34d",
567
+ coinType: "f325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc::afsui::AFSUI"
473
568
  },
474
569
  hasui: {
475
570
  lendingPoolAddress: "0x7ebc607f6bdeb659fb6506cb91c5cc1d47bb365cfd5d2e637ea765346ec84ed4",
@@ -482,7 +577,11 @@ var POOL_ADDRESSES = {
482
577
  borrowLimitKey: "0x65333e606eead786a999c8267bc9886b0fdbc298a8a8635a48a9c9b8838d9395",
483
578
  isolatedAssetKey: void 0,
484
579
  spool: "0xa6148bc1b623e936d39a952ceb5bea79e8b37228a8f595067bf1852efd3c34aa",
485
- spoolReward: "0x6f3563644d3e2ef13176dbf9d865bd93479df60ccbe07b7e66db57f6309f5a66"
580
+ spoolReward: "0x6f3563644d3e2ef13176dbf9d865bd93479df60ccbe07b7e66db57f6309f5a66",
581
+ sCoinTreasury: "0x404ccc1404d74a90eb6f9c9d4b6cda6d417fb03189f80d9070a35e5dab1df0f5",
582
+ sCoinType: "0x9a2376943f7d22f88087c259c5889925f332ca4347e669dc37d54c2bf651af3c::scallop_ha_sui::SCALLOP_HA_SUI",
583
+ coinMetadataId: "0x2c5f33af93f6511df699aaaa5822d823aac6ed99d4a0de2a4a50b3afa0172e24",
584
+ coinType: "bde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI"
486
585
  },
487
586
  vsui: {
488
587
  lendingPoolAddress: "0xda9257c0731d8822e8a438ebced13415850d705b779c79958dcf2aeb21fcb43d",
@@ -495,7 +594,11 @@ var POOL_ADDRESSES = {
495
594
  borrowLimitKey: "0x4eb206b4417642cfc1b02f80bb5f5e366af2af2f9fb4ea4f4e898ae82367f8a0",
496
595
  isolatedAssetKey: void 0,
497
596
  spool: "0x69ce8e537e750a95381e6040794afa5ab1758353a1a2e1de7760391b01f91670",
498
- spoolReward: "0xbca914adce058ad0902c7f3cfcd698392a475f00dcfdc3f76001d0370b98777a"
597
+ spoolReward: "0xbca914adce058ad0902c7f3cfcd698392a475f00dcfdc3f76001d0370b98777a",
598
+ sCoinTreasury: "0xc06688ee1af25abc286ffb1d18ce273d1d5907cd1064c25f4e8ca61ea989c1d1",
599
+ sCoinType: "0xe1a1cc6bcf0001a015eab84bcc6713393ce20535f55b8b6f35c142e057a25fbe::scallop_v_sui::SCALLOP_V_SUI",
600
+ coinMetadataId: "0xabd84a23467b33854ab25cf862006fd97479f8f6f53e50fe732c43a274d939bd",
601
+ coinType: "549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT"
499
602
  },
500
603
  sca: {
501
604
  lendingPoolAddress: "0x6fc7d4211fc7018b6c75e7b908b88f2e0536443239804a3d32af547637bd28d7",
@@ -508,7 +611,28 @@ var POOL_ADDRESSES = {
508
611
  borrowLimitKey: "0x04c7de61c5b42972f9bf6a8b1848e5fea2d037ee8deba81741ecd4a70aa80d30",
509
612
  isolatedAssetKey: void 0,
510
613
  spool: void 0,
511
- spoolReward: void 0
614
+ spoolReward: void 0,
615
+ sCoinTreasury: "0xe04bfc95e00252bd654ee13c08edef9ac5e4b6ae4074e8390db39e9a0109c529",
616
+ sCoinType: "0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA",
617
+ coinMetadataId: "0x5d26a1e9a55c88147ac870bfa31b729d7f49f8804b8b3adfdf3582d301cca844",
618
+ coinType: "7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6::sca::SCA"
619
+ },
620
+ fud: {
621
+ lendingPoolAddress: "0xefed2cbe76b344792ac724523c8b2236740d1cea2100d46a0ed0dc760c7f4231",
622
+ collateralPoolAddress: void 0,
623
+ borrowDynamic: "0x14367ddca30e2860cb89ed4eaca20c7ece260c5d59dd9990d2c85a8321326acb",
624
+ interestModel: "0x2600ac100ef154eb2329ffd3aad47aca308ff9f9348de3e8e94aaeb906ec2303",
625
+ riskModel: void 0,
626
+ borrowFeeKey: "0xa87e8b26e07ff35ac9fb57adcc779be2883080fc7d12de2d9e7e16d8d8d5e529",
627
+ supplyLimitKey: "0xf98419aecc37a3c5de716f8ec590f8991a5be34da72ce1a2da09531ff45adf7d",
628
+ borrowLimitKey: "0x3d928a001c453c50004baa54e14b0a0e1b0907d9c613dfd76064fd7ed4e8beb8",
629
+ isolatedAssetKey: "0xfcb533e9e4e31f9c9f32d6cbf7fbb3425f1d60474e229a363a2dc7f835d587e2",
630
+ spool: void 0,
631
+ spoolReward: void 0,
632
+ sCoinTreasury: "0xf25212f11d182decff7a86165699a73e3d5787aced203ca539f43cfbc10db867",
633
+ sCoinType: "0xe56d5167f427cbe597da9e8150ef5c337839aaf46891d62468dcf80bdd8e10d1::scallop_fud::SCALLOP_FUD",
634
+ coinMetadataId: "0x01087411ef48aaac1eb6e24803213e3a60a03b147dac930e5e341f17a85e524e",
635
+ coinType: "76cb819b01abed502bee8a702b4c2d547532c12f25001c9dea795a5e631c26f1::fud::FUD"
512
636
  },
513
637
  deep: {
514
638
  lendingPoolAddress: "0xf4a67ffb43da1e1c61c049f188f19463ea8dbbf2d5ef4722d6df854ff1b1cc03",
@@ -521,20 +645,28 @@ var POOL_ADDRESSES = {
521
645
  borrowLimitKey: "0xf4217e8ef9d9c32e8992092e910a77535a8124c19b8a762a673f227f5f765a4e",
522
646
  isolatedAssetKey: "0x208d3a24ba369dcfc8f0387333d1512b98199eb150d2f2a69359ff708cf761e3",
523
647
  spool: void 0,
524
- spoolReward: void 0
648
+ spoolReward: void 0,
649
+ sCoinTreasury: "0xc63838fabe37b25ad897392d89876d920f5e0c6a406bf3abcb84753d2829bc88",
650
+ sCoinType: "0xeb7a05a3224837c5e5503575aed0be73c091d1ce5e43aa3c3e716e0ae614608f::scallop_deep::SCALLOP_DEEP",
651
+ coinMetadataId: "0x6e60b051a08fa836f5a7acd7c464c8d9825bc29c44657fe170fe9b8e1e4770c0",
652
+ coinType: "deeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP"
525
653
  },
526
- fud: {
527
- lendingPoolAddress: "0xefed2cbe76b344792ac724523c8b2236740d1cea2100d46a0ed0dc760c7f4231",
528
- collateralPoolAddress: void 0,
529
- borrowDynamic: "0x14367ddca30e2860cb89ed4eaca20c7ece260c5d59dd9990d2c85a8321326acb",
530
- interestModel: "0x2600ac100ef154eb2329ffd3aad47aca308ff9f9348de3e8e94aaeb906ec2303",
531
- riskModel: void 0,
532
- borrowFeeKey: "0xa87e8b26e07ff35ac9fb57adcc779be2883080fc7d12de2d9e7e16d8d8d5e529",
533
- supplyLimitKey: "0xf98419aecc37a3c5de716f8ec590f8991a5be34da72ce1a2da09531ff45adf7d",
534
- borrowLimitKey: "0x3d928a001c453c50004baa54e14b0a0e1b0907d9c613dfd76064fd7ed4e8beb8",
535
- isolatedAssetKey: "0xfcb533e9e4e31f9c9f32d6cbf7fbb3425f1d60474e229a363a2dc7f835d587e2",
654
+ fdusd: {
655
+ lendingPoolAddress: "0x4f46051a01f05c3ad9aecf29a771aad5c884e1a1888e08d7709085e3a095bc9c",
656
+ collateralPoolAddress: "0x4f6647a9afcfdb62bb9b27e4d1cb7bd7130aca1b4f13fa7164453c869c1681ae",
657
+ borrowDynamic: "0x4ddcf19b6290a8b048ecb314b14ef7f52c1c5b9ddc9259a2a242cd91d681a085",
658
+ interestModel: "0xb57a33706b29d2d253c74c1c0869e6e20da99036338d2b0b7235ab41621ee9dd",
659
+ riskModel: "0xd65fb21758dc1e6184940a1a27efb13228d7cf5e19f6dcca06cc2d996af4a6b9",
660
+ borrowFeeKey: "0xafe673a27747b063fa918d2dfe47794e44af553737ac562c2a63186539a07f45",
661
+ supplyLimitKey: "0x730e0785ba056a7a95f4a6959371a598d7fe782e81c40785c79982ced4cf4e35",
662
+ borrowLimitKey: "0x1630c6954918a06fe56312afb8958366c5ed7af653dae0e32c09d088da38577e",
663
+ isolatedAssetKey: void 0,
536
664
  spool: void 0,
537
- spoolReward: void 0
665
+ spoolReward: void 0,
666
+ sCoinTreasury: "0xdad9bc6293e694f67a5274ea51b596e0bdabfafc585ae6d7e82888e65f1a03e0",
667
+ sCoinType: "0x6711551c1e7652a270d9fbf0eee25d99594c157cde3cb5fbb49035eb59b1b001::scallop_fdusd::SCALLOP_FDUSD",
668
+ coinMetadataId: "0xdebee5265a67c186ed87fe93303d33dfe1de53e3b4fd7d9329c2852860acd3e7",
669
+ coinType: "f16e6b723f242ec745dfd7634ad072c42d5c1d9ac9d62a39c381303eaa57693a::fdusd::FDUSD"
538
670
  }
539
671
  };
540
672
 
@@ -546,6 +678,7 @@ var PYTH_ENDPOINTS = {
546
678
  var PYTH_FEED_IDS = {
547
679
  usdc: "eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a",
548
680
  sbeth: "ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace",
681
+ sbusdt: "2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b",
549
682
  weth: "ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace",
550
683
  wbtc: "e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43",
551
684
  wusdc: "eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a",
@@ -558,6 +691,7 @@ var PYTH_FEED_IDS = {
558
691
  hasui: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
559
692
  vsui: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
560
693
  sca: "7e17f0ac105abe9214deb9944c30264f5986bf292869c6bd8e8da3ccd92d79bc",
694
+ fdusd: "0xccdc1a08923e2e4f4b1e6ea89de6acbc5fe1948e9706f5604b8cb50bc1ed3979",
561
695
  deep: "29bdd5248234e33bd93d3b81100b5fa32eaa5997843847e2c2cb16d7c6d9f7ff",
562
696
  fud: "6a4090703da959247727f2b490eb21aea95c8684ecfac675f432008830890c75"
563
697
  };
@@ -588,15 +722,13 @@ var queryKeys = {
588
722
  getObject: (objectId, options) => [
589
723
  "rpc",
590
724
  "getObject",
591
- { options, objectId }
725
+ { objectId, options }
592
726
  ],
593
- getObjects: (objectIds, walletAddress, options) => [
727
+ getObjects: (objectIds) => [
594
728
  "rpc",
595
729
  "getObjects",
596
730
  {
597
- walletAddress,
598
- options,
599
- objectIds: JSON.stringify(objectIds ?? [])
731
+ objectIds: JSON.stringify(objectIds ?? void 0)
600
732
  }
601
733
  ],
602
734
  getOwnedObjects: (input) => [
@@ -639,7 +771,10 @@ var queryKeys = {
639
771
  "rpc",
640
772
  "getAllCoinBalances",
641
773
  { owner }
642
- ]
774
+ ],
775
+ getNormalizedMoveFunction: (target) => {
776
+ return ["rpc", "getNormalizedMoveCall", target];
777
+ }
643
778
  },
644
779
  oracle: {
645
780
  getPythLatestPriceFeeds: () => ["oracle", "getPythPriceIds"]
@@ -864,6 +999,22 @@ var TEST_ADDRESSES = {
864
999
  }
865
1000
  }
866
1001
  },
1002
+ // @TODO: add test address
1003
+ // @ts-ignore
1004
+ sbusdt: {},
1005
+ fdusd: {
1006
+ id: "0xf16e6b723f242ec745dfd7634ad072c42d5c1d9ac9d62a39c381303eaa57693a",
1007
+ metaData: "0xdebee5265a67c186ed87fe93303d33dfe1de53e3b4fd7d9329c2852860acd3e7",
1008
+ treasury: "",
1009
+ oracle: {
1010
+ supra: "",
1011
+ switchboard: "",
1012
+ pyth: {
1013
+ feed: "0xccdc1a08923e2e4f4b1e6ea89de6acbc5fe1948e9706f5604b8cb50bc1ed3979",
1014
+ feedObject: "0x5f6583b2b0fe1ecf94aaffeaab8a838794693960cea48c0da282d5f4a24be027"
1015
+ }
1016
+ }
1017
+ },
867
1018
  deep: {
868
1019
  id: "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270",
869
1020
  metaData: "0x6e60b051a08fa836f5a7acd7c464c8d9825bc29c44657fe170fe9b8e1e4770c0",
@@ -1109,6 +1260,10 @@ var TEST_ADDRESSES = {
1109
1260
  coinType: "0xb14f82d8506d139eacef109688d1b71e7236bcce9b2c0ad526abcd6aa5be7de0::scallop_sb_eth::SCALLOP_SB_ETH",
1110
1261
  treasury: "0xfd0f02def6358a1f266acfa1493d4707ee8387460d434fb667d63d755ff907ed"
1111
1262
  },
1263
+ sfdusd: {
1264
+ coinType: "0x6711551c1e7652a270d9fbf0eee25d99594c157cde3cb5fbb49035eb59b1b001::scallop_fdusd::SCALLOP_FDUSD",
1265
+ treasury: "0xdad9bc6293e694f67a5274ea51b596e0bdabfafc585ae6d7e82888e65f1a03e0"
1266
+ },
1112
1267
  sdeep: {
1113
1268
  coinType: "0xeb7a05a3224837c5e5503575aed0be73c091d1ce5e43aa3c3e716e0ae614608f::scallop_deep::SCALLOP_DEEP",
1114
1269
  treasury: "0xc63838fabe37b25ad897392d89876d920f5e0c6a406bf3abcb84753d2829bc88"
@@ -1121,10 +1276,6 @@ var TEST_ADDRESSES = {
1121
1276
  }
1122
1277
  };
1123
1278
 
1124
- // src/constants/tokenBucket.ts
1125
- var DEFAULT_TOKENS_PER_INTERVAL = 10;
1126
- var DEFAULT_INTERVAL_IN_MS = 250;
1127
-
1128
1279
  // src/constants/vesca.ts
1129
1280
  var UNLOCK_ROUND_DURATION = 60 * 60 * 24;
1130
1281
  var MAX_LOCK_ROUNDS = 1460;
@@ -1132,944 +1283,406 @@ var MAX_LOCK_DURATION = MAX_LOCK_ROUNDS * UNLOCK_ROUND_DURATION;
1132
1283
  var MIN_INITIAL_LOCK_AMOUNT = 1e10;
1133
1284
  var MIN_TOP_UP_AMOUNT = 1e9;
1134
1285
 
1135
- // src/models/scallopAddress.ts
1136
- import { SuiKit } from "@scallop-io/sui-kit";
1137
-
1138
1286
  // src/models/scallopCache.ts
1139
1287
  import { QueryClient } from "@tanstack/query-core";
1140
1288
  import {
1141
1289
  SuiTxBlock,
1142
- normalizeStructTag as normalizeStructTag2
1290
+ normalizeStructTag,
1291
+ parseStructTag
1143
1292
  } from "@scallop-io/sui-kit";
1144
1293
 
1145
- // src/utils/builder.ts
1146
- var requireSender = (txBlock) => {
1147
- const sender = txBlock.blockData.sender;
1148
- if (!sender) {
1149
- throw new Error("Sender is required");
1150
- }
1151
- return sender;
1152
- };
1153
- var checkVesca = (prevUnlockAtInMillisTimestamp) => {
1154
- if (prevUnlockAtInMillisTimestamp === void 0) {
1155
- throw new Error("veSca not found");
1156
- }
1157
- };
1158
- var checkVescaExpired = (prevUnlockAtInMillisTimestamp) => {
1159
- if (prevUnlockAtInMillisTimestamp <= (/* @__PURE__ */ new Date()).getTime()) {
1160
- throw new Error("veSca is expired, use renewExpiredVeScaQuick instead");
1161
- }
1162
- };
1163
- var checkExtendLockPeriod = (lockPeriodInDays, newUnlockAtInSecondTimestamp, prevUnlockAtInMillisTimestamp) => {
1164
- checkVesca(prevUnlockAtInMillisTimestamp);
1165
- checkVescaExpired(prevUnlockAtInMillisTimestamp);
1166
- const prevUnlockAtInSecondTimestamp = Math.floor(
1167
- prevUnlockAtInMillisTimestamp / 1e3
1168
- );
1169
- if (lockPeriodInDays < 1) {
1170
- throw new Error("Minimum lock period is 1 day");
1171
- }
1172
- const availableLockPeriodInDays = Math.floor(
1173
- (newUnlockAtInSecondTimestamp - prevUnlockAtInSecondTimestamp) / UNLOCK_ROUND_DURATION
1174
- );
1175
- if (lockPeriodInDays > availableLockPeriodInDays) {
1176
- throw new Error(
1177
- `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}`
1178
- );
1179
- }
1294
+ // src/models/suiKit.ts
1295
+ import { SuiKit } from "@scallop-io/sui-kit";
1296
+ var newSuiKit = (params) => {
1297
+ return new SuiKit({
1298
+ ...params,
1299
+ fullnodeUrls: Array.from(
1300
+ /* @__PURE__ */ new Set([...params.fullnodeUrls ?? [], ...RPC_PROVIDERS])
1301
+ )
1302
+ });
1180
1303
  };
1181
- var checkLockSca = (scaAmountOrCoin, lockPeriodInDays, newUnlockAtInSecondTimestamp, prevUnlockAtInMillisTimestamp) => {
1182
- const prevUnlockAtInSecondTimestamp = prevUnlockAtInMillisTimestamp ? Math.floor(prevUnlockAtInMillisTimestamp / 1e3) : void 0;
1183
- const isInitialLock = !prevUnlockAtInSecondTimestamp;
1184
- const isLockExpired = !isInitialLock && prevUnlockAtInSecondTimestamp * 1e3 <= (/* @__PURE__ */ new Date()).getTime();
1185
- if (isInitialLock || isLockExpired) {
1186
- if (scaAmountOrCoin !== void 0 && lockPeriodInDays !== void 0) {
1187
- if (lockPeriodInDays <= 0) {
1188
- throw new Error("Lock period must be greater than 0");
1189
- }
1190
- if (typeof scaAmountOrCoin === "number" && scaAmountOrCoin < MIN_INITIAL_LOCK_AMOUNT) {
1191
- throw new Error(
1192
- `Minimum lock amount for ${isLockExpired ? "renewing expired veSca" : "initial lock"} is 10 SCA`
1193
- );
1194
- }
1195
- const extendLockPeriodInSecond = lockPeriodInDays * UNLOCK_ROUND_DURATION;
1196
- if (extendLockPeriodInSecond > MAX_LOCK_DURATION) {
1197
- throw new Error(
1198
- `Maximum lock period is ~4 years (${MAX_LOCK_ROUNDS} days)`
1199
- );
1200
- }
1201
- } else {
1202
- throw new Error(
1203
- `SCA amount and lock period is required for ${isLockExpired ? "renewing expired veSca" : "initial lock"}`
1204
- );
1205
- }
1206
- } else {
1207
- checkVesca(prevUnlockAtInMillisTimestamp);
1208
- checkVescaExpired(prevUnlockAtInMillisTimestamp);
1209
- if (typeof scaAmountOrCoin === "number" && scaAmountOrCoin < MIN_TOP_UP_AMOUNT) {
1210
- throw new Error("Minimum top up amount is 1 SCA");
1211
- }
1212
- if (newUnlockAtInSecondTimestamp && lockPeriodInDays) {
1213
- checkExtendLockPeriod(
1214
- lockPeriodInDays,
1215
- newUnlockAtInSecondTimestamp,
1216
- prevUnlockAtInMillisTimestamp
1304
+
1305
+ // src/models/scallopCache.ts
1306
+ var DEFAULT_TOKENS_PER_INTERVAL = 10;
1307
+ var DEFAULT_INTERVAL_IN_MS = 250;
1308
+ var deepMergeObject = (curr, update) => {
1309
+ const result = { ...curr };
1310
+ for (const key in update) {
1311
+ if (update[key] && typeof update[key] === "object" && !Array.isArray(update[key])) {
1312
+ result[key] = deepMergeObject(
1313
+ curr[key] || {},
1314
+ update[key]
1217
1315
  );
1316
+ } else {
1317
+ result[key] = update[key];
1218
1318
  }
1219
1319
  }
1320
+ return result;
1220
1321
  };
1221
- var checkExtendLockAmount = (scaAmount, prevUnlockAtInMillisTimestamp) => {
1222
- checkVesca(prevUnlockAtInMillisTimestamp);
1223
- checkVescaExpired(prevUnlockAtInMillisTimestamp);
1224
- if (scaAmount < MIN_TOP_UP_AMOUNT) {
1225
- throw new Error("Minimum top up amount is 1 SCA");
1322
+ var ScallopCache = class {
1323
+ constructor(params, instance) {
1324
+ this.tokensPerInterval = DEFAULT_TOKENS_PER_INTERVAL;
1325
+ this.interval = DEFAULT_INTERVAL_IN_MS;
1326
+ this.params = params;
1327
+ this.suiKit = instance?.suiKit ?? newSuiKit(params);
1328
+ this.queryClient = instance?.queryClient ?? new QueryClient(params?.cacheOptions ?? DEFAULT_CACHE_OPTIONS);
1329
+ this.tokens = this.tokensPerInterval;
1330
+ this.lastRefill = Date.now();
1331
+ this.walletAddress = params.walletAddress ?? this.suiKit.currentAddress();
1226
1332
  }
1227
- const isInitialLock = !prevUnlockAtInMillisTimestamp;
1228
- const isLockExpired = !isInitialLock && prevUnlockAtInMillisTimestamp <= (/* @__PURE__ */ new Date()).getTime();
1229
- if (isLockExpired) {
1230
- throw new Error("veSca is expired, use renewExpiredVeScaQuick instead");
1333
+ get client() {
1334
+ return this.suiKit.client();
1231
1335
  }
1232
- };
1233
- var checkRenewExpiredVeSca = (scaAmount, lockPeriodInDays, prevUnlockAtInMillisTimestamp) => {
1234
- if (!prevUnlockAtInMillisTimestamp || prevUnlockAtInMillisTimestamp > (/* @__PURE__ */ new Date()).getTime()) {
1235
- throw new Error("Renew method can only be used for expired veSca");
1336
+ refill() {
1337
+ const now = Date.now();
1338
+ const elapsed = now - this.lastRefill;
1339
+ if (elapsed >= this.interval) {
1340
+ const tokensToAdd = Math.floor(elapsed / this.interval) * this.tokensPerInterval;
1341
+ this.tokens = Math.min(this.tokens + tokensToAdd, this.tokensPerInterval);
1342
+ this.lastRefill += Math.floor(elapsed / this.interval) * this.interval;
1343
+ }
1236
1344
  }
1237
- if (scaAmount < MIN_INITIAL_LOCK_AMOUNT) {
1238
- throw new Error("Minimum lock amount for renewing expired vesca 10 SCA");
1345
+ removeTokens(count) {
1346
+ this.refill();
1347
+ if (this.tokens >= count) {
1348
+ this.tokens -= count;
1349
+ return true;
1350
+ }
1351
+ return false;
1239
1352
  }
1240
- const extendLockPeriodInSecond = lockPeriodInDays * UNLOCK_ROUND_DURATION;
1241
- if (extendLockPeriodInSecond >= MAX_LOCK_DURATION - UNLOCK_ROUND_DURATION) {
1242
- throw new Error(
1243
- `Maximum lock period is ~4 years (${MAX_LOCK_ROUNDS - 1} days)`
1353
+ async callWithRateLimit(fn, maxRetries = 15, backoffFactor = 1.25) {
1354
+ let retries = 0;
1355
+ const tryRequest = async () => {
1356
+ if (this.removeTokens(1)) {
1357
+ const result = await fn();
1358
+ return result;
1359
+ } else if (retries < maxRetries) {
1360
+ retries++;
1361
+ const delay = this.interval * Math.pow(backoffFactor, retries);
1362
+ await new Promise((resolve) => setTimeout(resolve, delay));
1363
+ return tryRequest();
1364
+ } else {
1365
+ console.error("Maximum retries reached");
1366
+ return null;
1367
+ }
1368
+ };
1369
+ return tryRequest();
1370
+ }
1371
+ /**
1372
+ * @description Invalidate cache based on the refetchType parameter
1373
+ * @param refetchType Determines the type of queries to be refetched. Defaults to `active`.
1374
+ *
1375
+ * - `active`: Only queries that match the refetch predicate and are actively being rendered via useQuery and related functions will be refetched in the background.
1376
+ * - `inactive`: Only queries that match the refetch predicate and are NOT actively being rendered via useQuery and related functions will be refetched in the background.
1377
+ * - `all`: All queries that match the refetch predicate will be refetched in the background.
1378
+ * - `none`: No queries will be refetched. Queries that match the refetch predicate will only be marked as invalid.
1379
+ */
1380
+ // public async invalidateAllCache() {
1381
+ // return Object.values(queryKeys.rpc).map((t) =>
1382
+ // this.queryClient.invalidateQueries({
1383
+ // queryKey: t(),
1384
+ // type: 'all',
1385
+ // })
1386
+ // );
1387
+ // }
1388
+ retryFn(errCount, e) {
1389
+ if (errCount === 5)
1390
+ return false;
1391
+ if (e.status === 429)
1392
+ return true;
1393
+ return false;
1394
+ }
1395
+ /**
1396
+ * @description Provides cache for inspectTxn of the SuiKit.
1397
+ * @param QueryInspectTxnParams
1398
+ * @param txBlock
1399
+ * @returns Promise<DevInspectResults>
1400
+ */
1401
+ async queryInspectTxn({
1402
+ queryTarget,
1403
+ args,
1404
+ typeArgs
1405
+ }) {
1406
+ const txBlock = new SuiTxBlock();
1407
+ const resolvedQueryTarget = await this.queryGetNormalizedMoveFunction(queryTarget);
1408
+ if (!resolvedQueryTarget)
1409
+ throw new Error("Invalid query target");
1410
+ const { parameters } = resolvedQueryTarget;
1411
+ const resolvedArgs = await Promise.all(
1412
+ (args ?? []).map(async (arg, idx) => {
1413
+ if (typeof arg !== "string")
1414
+ return arg;
1415
+ const cachedData = (await this.queryGetObject(arg))?.data;
1416
+ if (!cachedData)
1417
+ return arg;
1418
+ const owner = cachedData.owner;
1419
+ if (!owner || typeof owner !== "object" || !("Shared" in owner))
1420
+ return {
1421
+ objectId: cachedData.objectId,
1422
+ version: cachedData.version,
1423
+ digest: cachedData.digest
1424
+ };
1425
+ const parameter = parameters[idx];
1426
+ if (typeof parameter !== "object" || !("MutableReference" in parameter || "Reference" in parameter))
1427
+ return arg;
1428
+ return {
1429
+ objectId: cachedData.objectId,
1430
+ initialSharedVersion: owner.Shared.initial_shared_version,
1431
+ mutable: "MutableReference" in parameter
1432
+ };
1433
+ })
1244
1434
  );
1435
+ txBlock.moveCall(queryTarget, resolvedArgs, typeArgs);
1436
+ const query = await this.queryClient.fetchQuery({
1437
+ retry: this.retryFn,
1438
+ retryDelay: 1e3,
1439
+ queryKey: queryKeys.rpc.getInspectTxn(queryTarget, args, typeArgs),
1440
+ queryFn: async () => {
1441
+ return await this.callWithRateLimit(
1442
+ async () => await this.suiKit.inspectTxn(txBlock)
1443
+ );
1444
+ }
1445
+ });
1446
+ return query;
1447
+ }
1448
+ async queryGetNormalizedMoveFunction(target) {
1449
+ const { address, module, name } = parseStructTag(target);
1450
+ return this.queryClient.fetchQuery({
1451
+ queryKey: queryKeys.rpc.getNormalizedMoveFunction(target),
1452
+ queryFn: async () => {
1453
+ return await this.callWithRateLimit(
1454
+ async () => await this.suiKit.client().getNormalizedMoveFunction({
1455
+ package: address,
1456
+ module,
1457
+ function: name
1458
+ })
1459
+ );
1460
+ }
1461
+ });
1462
+ }
1463
+ /**
1464
+ * @description Provides cache for getObject of the SuiKit.
1465
+ * @param objectId
1466
+ * @param QueryObjectParams
1467
+ * @returns Promise<SuiObjectResponse>
1468
+ */
1469
+ async queryGetObject(objectId, options) {
1470
+ options = {
1471
+ ...options,
1472
+ showOwner: true,
1473
+ showContent: true,
1474
+ showType: true
1475
+ };
1476
+ return this.queryClient.fetchQuery({
1477
+ retry: this.retryFn,
1478
+ retryDelay: 1e3,
1479
+ queryKey: queryKeys.rpc.getObject(objectId, options),
1480
+ queryFn: async () => {
1481
+ return await this.callWithRateLimit(
1482
+ async () => await this.client.getObject({
1483
+ id: objectId,
1484
+ options
1485
+ })
1486
+ );
1487
+ }
1488
+ });
1489
+ }
1490
+ /**
1491
+ * @description Provides cache for getObjects of the SuiKit.
1492
+ * @param objectIds
1493
+ * @returns Promise<SuiObjectData[]>
1494
+ */
1495
+ async queryGetObjects(objectIds) {
1496
+ if (objectIds.length === 0)
1497
+ return [];
1498
+ const options = {
1499
+ showContent: true,
1500
+ showOwner: true,
1501
+ showType: true
1502
+ };
1503
+ return this.queryClient.fetchQuery({
1504
+ retry: this.retryFn,
1505
+ retryDelay: 1e3,
1506
+ queryKey: queryKeys.rpc.getObjects(objectIds),
1507
+ queryFn: async () => {
1508
+ const results = await this.callWithRateLimit(
1509
+ async () => await this.suiKit.getObjects(objectIds, options)
1510
+ );
1511
+ if (results) {
1512
+ results.forEach((result) => {
1513
+ const queryKey = queryKeys.rpc.getObject(result.objectId);
1514
+ const prevDatas = this.queryClient.getQueriesData({
1515
+ exact: false,
1516
+ queryKey
1517
+ });
1518
+ prevDatas.forEach(([key, prevData]) => {
1519
+ this.queryClient.setQueryData(
1520
+ key,
1521
+ deepMergeObject(prevData, { data: result, error: null }),
1522
+ { updatedAt: Date.now() }
1523
+ );
1524
+ });
1525
+ });
1526
+ }
1527
+ return results;
1528
+ }
1529
+ });
1530
+ }
1531
+ /**
1532
+ * @description Provides cache for getOwnedObjects of the SuiKit.
1533
+ * @param input
1534
+ * @returns Promise<PaginatedObjectsResponse>
1535
+ */
1536
+ async queryGetOwnedObjects(input) {
1537
+ return this.queryClient.fetchQuery({
1538
+ retry: this.retryFn,
1539
+ retryDelay: 1e3,
1540
+ queryKey: queryKeys.rpc.getOwnedObjects(input),
1541
+ queryFn: async () => {
1542
+ const results = await this.callWithRateLimit(
1543
+ async () => await this.client.getOwnedObjects(input)
1544
+ );
1545
+ if (results && results.data.length > 0) {
1546
+ results.data.filter(
1547
+ (result) => !!result.data
1548
+ ).forEach((result) => {
1549
+ const queryKey = queryKeys.rpc.getObject(result.data.objectId);
1550
+ const prevDatas = this.queryClient.getQueriesData({
1551
+ exact: false,
1552
+ queryKey
1553
+ });
1554
+ prevDatas.forEach(([key, prevData]) => {
1555
+ this.queryClient.setQueryData(
1556
+ key,
1557
+ deepMergeObject(prevData, { data: result.data, error: null }),
1558
+ { updatedAt: Date.now() }
1559
+ );
1560
+ });
1561
+ });
1562
+ }
1563
+ return results;
1564
+ }
1565
+ });
1566
+ }
1567
+ async queryGetDynamicFields(input) {
1568
+ return this.queryClient.fetchQuery({
1569
+ retry: this.retryFn,
1570
+ retryDelay: 1e3,
1571
+ queryKey: queryKeys.rpc.getDynamicFields(input),
1572
+ queryFn: async () => {
1573
+ return await this.callWithRateLimit(
1574
+ async () => await this.client.getDynamicFields(input)
1575
+ );
1576
+ }
1577
+ });
1578
+ }
1579
+ async queryGetDynamicFieldObject(input) {
1580
+ return this.queryClient.fetchQuery({
1581
+ retry: this.retryFn,
1582
+ retryDelay: (attemptIndex) => Math.min(1e3 * attemptIndex, 8e3),
1583
+ queryKey: queryKeys.rpc.getDynamicFieldObject(input),
1584
+ queryFn: async () => {
1585
+ const result = await this.callWithRateLimit(
1586
+ () => this.client.getDynamicFieldObject(input)
1587
+ );
1588
+ if (result?.data) {
1589
+ const queryKey = queryKeys.rpc.getObject(result.data.objectId);
1590
+ const prevDatas = this.queryClient.getQueriesData({
1591
+ exact: false,
1592
+ queryKey
1593
+ });
1594
+ prevDatas.forEach(([key, prevData]) => {
1595
+ this.queryClient.setQueryData(
1596
+ key,
1597
+ deepMergeObject(prevData, { data: result.data, error: null }),
1598
+ { updatedAt: Date.now() }
1599
+ );
1600
+ });
1601
+ }
1602
+ return result;
1603
+ }
1604
+ });
1605
+ }
1606
+ async queryGetAllCoinBalances(owner) {
1607
+ return this.queryClient.fetchQuery({
1608
+ retry: this.retryFn,
1609
+ retryDelay: 1e3,
1610
+ queryKey: queryKeys.rpc.getAllCoinBalances(owner),
1611
+ queryFn: async () => {
1612
+ const allBalances = await this.callWithRateLimit(
1613
+ async () => await this.client.getAllBalances({ owner })
1614
+ );
1615
+ if (!allBalances)
1616
+ return {};
1617
+ const balances = allBalances.reduce(
1618
+ (acc, coinBalance) => {
1619
+ if (coinBalance.totalBalance !== "0") {
1620
+ acc[normalizeStructTag(coinBalance.coinType)] = coinBalance;
1621
+ }
1622
+ return acc;
1623
+ },
1624
+ {}
1625
+ );
1626
+ return balances;
1627
+ }
1628
+ });
1629
+ }
1630
+ async queryGetCoinBalance(input) {
1631
+ if (!input.coinType)
1632
+ return null;
1633
+ return (await this.queryGetAllCoinBalances(input.owner) ?? {})[normalizeStructTag(input.coinType)] ?? "0";
1245
1634
  }
1246
1635
  };
1247
1636
 
1248
- // src/utils/query.ts
1249
- import BigNumber from "bignumber.js";
1250
- import { normalizeStructTag, parseStructTag } from "@mysten/sui/utils";
1251
- var parseOriginMarketPoolData = (originMarketPoolData) => {
1252
- return {
1253
- coinType: normalizeStructTag(originMarketPoolData.type.name),
1254
- // Parse origin data required for basic calculations.
1255
- maxBorrowRate: Number(originMarketPoolData.maxBorrowRate.value) / 2 ** 32,
1256
- borrowRate: Number(originMarketPoolData.interestRate.value) / 2 ** 32,
1257
- borrowRateScale: Number(originMarketPoolData.interestRateScale),
1258
- borrowIndex: Number(originMarketPoolData.borrowIndex),
1259
- lastUpdated: Number(originMarketPoolData.lastUpdated),
1260
- cashAmount: Number(originMarketPoolData.cash),
1261
- debtAmount: Number(originMarketPoolData.debt),
1262
- marketCoinSupplyAmount: Number(originMarketPoolData.marketCoinSupply),
1263
- reserveAmount: Number(originMarketPoolData.reserve),
1264
- reserveFactor: Number(originMarketPoolData.reserveFactor.value) / 2 ** 32,
1265
- borrowWeight: Number(originMarketPoolData.borrowWeight.value) / 2 ** 32,
1266
- borrowFee: Number(originMarketPoolData.borrowFeeRate.value) / 2 ** 32,
1267
- // Parse origin data required for additional display.
1268
- baseBorrowRate: Number(originMarketPoolData.baseBorrowRatePerSec.value) / 2 ** 32,
1269
- borrowRateOnHighKink: Number(originMarketPoolData.borrowRateOnHighKink.value) / 2 ** 32,
1270
- borrowRateOnMidKink: Number(originMarketPoolData.borrowRateOnMidKink.value) / 2 ** 32,
1271
- highKink: Number(originMarketPoolData.highKink.value) / 2 ** 32,
1272
- midKink: Number(originMarketPoolData.midKink.value) / 2 ** 32,
1273
- minBorrowAmount: Number(originMarketPoolData.minBorrowAmount),
1274
- isIsolated: originMarketPoolData.isIsolated,
1275
- supplyLimit: Number(originMarketPoolData.supplyLimit),
1276
- borrowLimit: Number(originMarketPoolData.borrowLimit)
1277
- };
1278
- };
1279
- var calculateMarketPoolData = (utils, parsedMarketPoolData) => {
1280
- const poolCoinName = utils.parseCoinNameFromType(
1281
- parsedMarketPoolData.coinType
1282
- );
1283
- const coinDecimal = utils.getCoinDecimal(poolCoinName);
1284
- const borrowYearFactor = 24 * 365 * 3600;
1285
- const baseBorrowApr = parsedMarketPoolData.baseBorrowRate * borrowYearFactor / parsedMarketPoolData.borrowRateScale;
1286
- const borrowAprOnHighKink = parsedMarketPoolData.borrowRateOnHighKink * borrowYearFactor / parsedMarketPoolData.borrowRateScale;
1287
- const borrowAprOnMidKink = parsedMarketPoolData.borrowRateOnMidKink * borrowYearFactor / parsedMarketPoolData.borrowRateScale;
1288
- const maxBorrowApr = parsedMarketPoolData.maxBorrowRate * borrowYearFactor / parsedMarketPoolData.borrowRateScale;
1289
- const borrowApr = parsedMarketPoolData.borrowRate * borrowYearFactor / parsedMarketPoolData.borrowRateScale;
1290
- const timeDelta = Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3) - parsedMarketPoolData.lastUpdated;
1291
- const borrowIndexDelta = BigNumber(parsedMarketPoolData.borrowIndex).multipliedBy(
1292
- BigNumber(timeDelta).multipliedBy(parsedMarketPoolData.borrowRate)
1293
- ).dividedBy(parsedMarketPoolData.borrowRateScale);
1294
- const currentBorrowIndex = BigNumber(parsedMarketPoolData.borrowIndex).plus(
1295
- borrowIndexDelta
1296
- );
1297
- const growthInterest = BigNumber(currentBorrowIndex).dividedBy(parsedMarketPoolData.borrowIndex).minus(1);
1298
- const increasedDebtAmount = BigNumber(
1299
- parsedMarketPoolData.debtAmount
1300
- ).multipliedBy(growthInterest);
1301
- const borrowAmount = increasedDebtAmount.plus(
1302
- parsedMarketPoolData.debtAmount
1303
- );
1304
- const borrowCoin = borrowAmount.shiftedBy(-1 * coinDecimal);
1305
- const reserveAmount = BigNumber(parsedMarketPoolData.reserveAmount).plus(
1306
- increasedDebtAmount.multipliedBy(parsedMarketPoolData.reserveFactor)
1307
- );
1308
- const reserveCoin = reserveAmount.shiftedBy(-1 * coinDecimal);
1309
- const supplyAmount = BigNumber(borrowAmount).plus(
1310
- Math.max(parsedMarketPoolData.cashAmount - reserveAmount.toNumber(), 0)
1311
- );
1312
- const supplyCoin = supplyAmount.shiftedBy(-1 * coinDecimal);
1313
- let utilizationRate = BigNumber(borrowAmount).dividedBy(supplyAmount);
1314
- utilizationRate = utilizationRate.isFinite() ? utilizationRate : BigNumber(0);
1315
- let supplyApr = BigNumber(borrowApr).multipliedBy(utilizationRate).multipliedBy(1 - parsedMarketPoolData.reserveFactor);
1316
- supplyApr = supplyApr.isFinite() ? supplyApr : BigNumber(0);
1317
- let conversionRate = supplyAmount.dividedBy(
1318
- parsedMarketPoolData.marketCoinSupplyAmount
1319
- );
1320
- conversionRate = conversionRate.isFinite() && !conversionRate.isNaN() ? conversionRate : BigNumber(1);
1321
- return {
1322
- baseBorrowApr,
1323
- baseBorrowApy: utils.parseAprToApy(baseBorrowApr),
1324
- borrowAprOnHighKink,
1325
- borrowApyOnHighKink: utils.parseAprToApy(borrowAprOnHighKink),
1326
- borrowAprOnMidKink,
1327
- borrowApyOnMidKink: utils.parseAprToApy(borrowAprOnMidKink),
1328
- coinDecimal,
1329
- maxBorrowApr,
1330
- maxBorrowApy: utils.parseAprToApy(maxBorrowApr),
1331
- borrowApr: Math.min(borrowApr, maxBorrowApr),
1332
- borrowApy: Math.min(
1333
- utils.parseAprToApy(borrowApr),
1334
- utils.parseAprToApy(maxBorrowApr)
1335
- ),
1336
- borrowIndex: currentBorrowIndex.toNumber(),
1337
- growthInterest: growthInterest.toNumber(),
1338
- supplyAmount: supplyAmount.toNumber(),
1339
- supplyCoin: supplyCoin.toNumber(),
1340
- borrowAmount: borrowAmount.toNumber(),
1341
- borrowCoin: borrowCoin.toNumber(),
1342
- reserveAmount: reserveAmount.toNumber(),
1343
- reserveCoin: reserveCoin.toNumber(),
1344
- utilizationRate: utilizationRate.toNumber(),
1345
- supplyApr: supplyApr.toNumber(),
1346
- supplyApy: utils.parseAprToApy(supplyApr.toNumber()),
1347
- conversionRate: conversionRate.toNumber(),
1348
- isIsolated: parsedMarketPoolData.isIsolated,
1349
- maxSupplyCoin: BigNumber(parsedMarketPoolData.supplyLimit).shiftedBy(coinDecimal).toNumber(),
1350
- maxBorrowCoin: BigNumber(parsedMarketPoolData.borrowLimit).shiftedBy(coinDecimal).toNumber()
1351
- };
1352
- };
1353
- var parseOriginMarketCollateralData = (originMarketCollateralData) => {
1354
- const divisor = 2 ** 32;
1355
- return {
1356
- coinType: normalizeStructTag(originMarketCollateralData.type.name),
1357
- isIsolated: originMarketCollateralData.isIsolated,
1358
- collateralFactor: Number(originMarketCollateralData.collateralFactor.value) / divisor,
1359
- liquidationFactor: Number(originMarketCollateralData.liquidationFactor.value) / divisor,
1360
- liquidationDiscount: Number(originMarketCollateralData.liquidationDiscount.value) / divisor,
1361
- liquidationPenalty: Number(originMarketCollateralData.liquidationPenalty.value) / divisor,
1362
- liquidationReserveFactor: Number(originMarketCollateralData.liquidationReserveFactor.value) / divisor,
1363
- maxCollateralAmount: Number(originMarketCollateralData.maxCollateralAmount),
1364
- totalCollateralAmount: Number(
1365
- originMarketCollateralData.totalCollateralAmount
1366
- )
1367
- };
1368
- };
1369
- var calculateMarketCollateralData = (utils, parsedMarketCollateralData) => {
1370
- const collateralCoinName = utils.parseCoinNameFromType(
1371
- parsedMarketCollateralData.coinType
1372
- );
1373
- const coinDecimal = utils.getCoinDecimal(collateralCoinName);
1374
- const maxCollateralCoin = BigNumber(
1375
- parsedMarketCollateralData.maxCollateralAmount
1376
- ).shiftedBy(-1 * coinDecimal);
1377
- const depositCoin = BigNumber(
1378
- parsedMarketCollateralData.totalCollateralAmount
1379
- ).shiftedBy(-1 * coinDecimal);
1380
- return {
1381
- coinDecimal,
1382
- isIsolated: parsedMarketCollateralData.isIsolated,
1383
- maxDepositAmount: parsedMarketCollateralData.maxCollateralAmount,
1384
- maxDepositCoin: maxCollateralCoin.toNumber(),
1385
- depositAmount: parsedMarketCollateralData.totalCollateralAmount,
1386
- depositCoin: depositCoin.toNumber()
1387
- };
1388
- };
1389
- var parseOriginSpoolData = (originSpoolData) => {
1390
- return {
1391
- stakeType: normalizeStructTag(originSpoolData.stakeType.fields.name),
1392
- maxPoint: Number(originSpoolData.maxDistributedPoint),
1393
- distributedPoint: Number(originSpoolData.distributedPoint),
1394
- pointPerPeriod: Number(originSpoolData.distributedPointPerPeriod),
1395
- period: Number(originSpoolData.pointDistributionTime),
1396
- maxStake: Number(originSpoolData.maxStake),
1397
- staked: Number(originSpoolData.stakes),
1398
- index: Number(originSpoolData.index),
1399
- createdAt: Number(originSpoolData.createdAt),
1400
- lastUpdate: Number(originSpoolData.lastUpdate)
1401
- };
1402
- };
1403
- var calculateSpoolData = (parsedSpoolData, stakeMarketCoinPrice, stakeMarketCoinDecimal) => {
1404
- const baseIndexRate = 1e9;
1405
- const distributedPointPerSec = BigNumber(
1406
- parsedSpoolData.pointPerPeriod
1407
- ).dividedBy(parsedSpoolData.period);
1408
- const pointPerSec = BigNumber(parsedSpoolData.pointPerPeriod).dividedBy(
1409
- parsedSpoolData.period
1410
- );
1411
- const remainingPeriod = pointPerSec.gt(0) ? BigNumber(parsedSpoolData.maxPoint).minus(parsedSpoolData.distributedPoint).dividedBy(pointPerSec) : BigNumber(0);
1412
- const startDate = parsedSpoolData.createdAt;
1413
- const endDate = remainingPeriod.plus(parsedSpoolData.lastUpdate).integerValue().toNumber();
1414
- const timeDelta = BigNumber(
1415
- Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3) - parsedSpoolData.lastUpdate
1416
- ).dividedBy(parsedSpoolData.period).toFixed(0);
1417
- const remainingPoints = BigNumber(parsedSpoolData.maxPoint).minus(
1418
- parsedSpoolData.distributedPoint
1419
- );
1420
- const accumulatedPoints = BigNumber.minimum(
1421
- BigNumber(timeDelta).multipliedBy(parsedSpoolData.pointPerPeriod),
1422
- remainingPoints
1423
- );
1424
- const currentPointIndex = BigNumber(parsedSpoolData.index).plus(
1425
- accumulatedPoints.dividedBy(parsedSpoolData.staked).isFinite() ? BigNumber(baseIndexRate).multipliedBy(accumulatedPoints).dividedBy(parsedSpoolData.staked) : 0
1426
- );
1427
- const currentTotalDistributedPoint = BigNumber(
1428
- parsedSpoolData.distributedPoint
1429
- ).plus(accumulatedPoints);
1430
- const stakedAmount = BigNumber(parsedSpoolData.staked);
1431
- const stakedCoin = stakedAmount.shiftedBy(-1 * stakeMarketCoinDecimal);
1432
- const stakedValue = stakedCoin.multipliedBy(stakeMarketCoinPrice);
1433
- return {
1434
- distributedPointPerSec: distributedPointPerSec.toNumber(),
1435
- accumulatedPoints: accumulatedPoints.toNumber(),
1436
- currentPointIndex: currentPointIndex.toNumber(),
1437
- currentTotalDistributedPoint: currentTotalDistributedPoint.toNumber(),
1438
- startDate: new Date(startDate * 1e3),
1439
- endDate: new Date(endDate * 1e3),
1440
- stakedAmount: stakedAmount.toNumber(),
1441
- stakedCoin: stakedCoin.toNumber(),
1442
- stakedValue: stakedValue.toNumber()
1443
- };
1444
- };
1445
- var parseOriginSpoolRewardPoolData = (originSpoolRewardPoolData) => {
1446
- return {
1447
- claimedRewards: Number(originSpoolRewardPoolData.claimed_rewards),
1448
- exchangeRateDenominator: Number(
1449
- originSpoolRewardPoolData.exchange_rate_denominator
1450
- ),
1451
- exchangeRateNumerator: Number(
1452
- originSpoolRewardPoolData.exchange_rate_numerator
1453
- ),
1454
- rewards: Number(originSpoolRewardPoolData.rewards),
1455
- spoolId: String(originSpoolRewardPoolData.spool_id)
1456
- };
1457
- };
1458
- var calculateSpoolRewardPoolData = (parsedSpoolData, parsedSpoolRewardPoolData, calculatedSpoolData, rewardCoinPrice, rewardCoinDecimal) => {
1459
- const rateYearFactor = 365 * 24 * 60 * 60;
1460
- const rewardPerSec = BigNumber(calculatedSpoolData.distributedPointPerSec).multipliedBy(parsedSpoolRewardPoolData.exchangeRateNumerator).dividedBy(parsedSpoolRewardPoolData.exchangeRateDenominator);
1461
- const totalRewardAmount = BigNumber(parsedSpoolData.maxPoint).multipliedBy(parsedSpoolRewardPoolData.exchangeRateNumerator).dividedBy(parsedSpoolRewardPoolData.exchangeRateDenominator);
1462
- const totalRewardCoin = totalRewardAmount.shiftedBy(-1 * rewardCoinDecimal);
1463
- const totalRewardValue = totalRewardCoin.multipliedBy(rewardCoinPrice);
1464
- const remaindRewardAmount = BigNumber(parsedSpoolRewardPoolData.rewards);
1465
- const remaindRewardCoin = remaindRewardAmount.shiftedBy(
1466
- -1 * rewardCoinDecimal
1467
- );
1468
- const remaindRewardValue = remaindRewardCoin.multipliedBy(rewardCoinPrice);
1469
- const claimedRewardAmount = BigNumber(
1470
- parsedSpoolRewardPoolData.claimedRewards
1471
- );
1472
- const claimedRewardCoin = claimedRewardAmount.shiftedBy(
1473
- -1 * rewardCoinDecimal
1474
- );
1475
- const claimedRewardValue = claimedRewardCoin.multipliedBy(rewardCoinPrice);
1476
- const rewardValueForYear = BigNumber(rewardPerSec).shiftedBy(-1 * rewardCoinDecimal).multipliedBy(rateYearFactor).multipliedBy(rewardCoinPrice);
1477
- let rewardRate = rewardValueForYear.dividedBy(calculatedSpoolData.stakedValue).isFinite() ? rewardValueForYear.dividedBy(calculatedSpoolData.stakedValue).toNumber() : Infinity;
1478
- if (parsedSpoolData.maxPoint <= parsedSpoolData.distributedPoint || parsedSpoolData.pointPerPeriod === 0) {
1479
- rewardRate = Infinity;
1480
- }
1481
- return {
1482
- rewardApr: rewardRate,
1483
- totalRewardAmount: totalRewardAmount.toNumber(),
1484
- totalRewardCoin: totalRewardCoin.toNumber(),
1485
- totalRewardValue: totalRewardValue.toNumber(),
1486
- remaindRewardAmount: remaindRewardAmount.toNumber(),
1487
- remaindRewardCoin: remaindRewardCoin.toNumber(),
1488
- remaindRewardValue: remaindRewardValue.toNumber(),
1489
- claimedRewardAmount: claimedRewardAmount.toNumber(),
1490
- claimedRewardCoin: claimedRewardCoin.toNumber(),
1491
- claimedRewardValue: claimedRewardValue.toNumber(),
1492
- rewardPerSec: rewardPerSec.toNumber()
1493
- };
1494
- };
1495
- var parseOriginBorrowIncentivesPoolPointData = (originBorrowIncentivePoolPointData) => {
1496
- return {
1497
- pointType: normalizeStructTag(
1498
- originBorrowIncentivePoolPointData.point_type.name
1499
- ),
1500
- distributedPointPerPeriod: Number(
1501
- originBorrowIncentivePoolPointData.distributed_point_per_period
1502
- ),
1503
- period: Number(originBorrowIncentivePoolPointData.point_distribution_time),
1504
- distributedPoint: Number(
1505
- originBorrowIncentivePoolPointData.distributed_point
1506
- ),
1507
- points: Number(originBorrowIncentivePoolPointData.points),
1508
- index: Number(originBorrowIncentivePoolPointData.index),
1509
- baseWeight: Number(originBorrowIncentivePoolPointData.base_weight),
1510
- weightedAmount: Number(originBorrowIncentivePoolPointData.weighted_amount),
1511
- lastUpdate: Number(originBorrowIncentivePoolPointData.last_update),
1512
- createdAt: Number(originBorrowIncentivePoolPointData.created_at)
1513
- };
1514
- };
1515
- var parseOriginBorrowIncentivePoolData = (utils, originBorrowIncentivePoolData) => {
1516
- return {
1517
- poolType: normalizeStructTag(originBorrowIncentivePoolData.pool_type.name),
1518
- minStakes: Number(originBorrowIncentivePoolData.min_stakes),
1519
- maxStakes: Number(originBorrowIncentivePoolData.max_stakes),
1520
- staked: Number(originBorrowIncentivePoolData.stakes),
1521
- poolPoints: originBorrowIncentivePoolData.points.reduce(
1522
- (acc, point) => {
1523
- const parsed = parseOriginBorrowIncentivesPoolPointData(point);
1524
- const name = utils.parseSCoinTypeNameToMarketCoinName(
1525
- parseStructTag(parsed.pointType).name.toLowerCase()
1526
- );
1527
- acc[name] = parsed;
1528
- return acc;
1637
+ // src/models/scallopAddress.ts
1638
+ import axios from "axios";
1639
+ var EMPTY_ADDRESSES = {
1640
+ core: {
1641
+ version: "",
1642
+ versionCap: "",
1643
+ object: "",
1644
+ market: "",
1645
+ adminCap: "",
1646
+ coinDecimalsRegistry: "",
1647
+ obligationAccessStore: "",
1648
+ coins: {
1649
+ cetus: {
1650
+ id: "",
1651
+ metaData: "",
1652
+ treasury: "",
1653
+ oracle: {
1654
+ supra: "",
1655
+ switchboard: "",
1656
+ pyth: {
1657
+ feed: "",
1658
+ feedObject: ""
1659
+ }
1660
+ }
1529
1661
  },
1530
- {}
1531
- )
1532
- };
1533
- };
1534
- var calculateBorrowIncentivePoolPointData = (parsedBorrowIncentivePoolPointData, rewardCoinPrice, rewardCoinDecimal, poolCoinPrice, poolCoinDecimal) => {
1535
- const baseIndexRate = 1e9;
1536
- const distributedPointPerSec = BigNumber(
1537
- parsedBorrowIncentivePoolPointData.distributedPointPerPeriod
1538
- ).dividedBy(parsedBorrowIncentivePoolPointData.period);
1539
- const timeDelta = BigNumber(
1540
- Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3) - parsedBorrowIncentivePoolPointData.lastUpdate
1541
- ).dividedBy(parsedBorrowIncentivePoolPointData.period).toFixed(0);
1542
- const accumulatedPoints = BigNumber.minimum(
1543
- BigNumber(timeDelta).multipliedBy(
1544
- parsedBorrowIncentivePoolPointData.distributedPointPerPeriod
1545
- ),
1546
- BigNumber(parsedBorrowIncentivePoolPointData.points)
1547
- );
1548
- const currentPointIndex = BigNumber(
1549
- parsedBorrowIncentivePoolPointData.index
1550
- ).plus(
1551
- accumulatedPoints.dividedBy(parsedBorrowIncentivePoolPointData.weightedAmount).isFinite() ? BigNumber(baseIndexRate).multipliedBy(accumulatedPoints).dividedBy(parsedBorrowIncentivePoolPointData.weightedAmount) : 0
1552
- );
1553
- const currentTotalDistributedPoint = BigNumber(
1554
- parsedBorrowIncentivePoolPointData.distributedPoint
1555
- ).plus(accumulatedPoints);
1556
- const baseWeight = BigNumber(parsedBorrowIncentivePoolPointData.baseWeight);
1557
- const weightedStakedAmount = BigNumber(
1558
- parsedBorrowIncentivePoolPointData.weightedAmount
1559
- );
1560
- const weightedStakedCoin = weightedStakedAmount.shiftedBy(
1561
- -1 * poolCoinDecimal
1562
- );
1563
- const weightedStakedValue = weightedStakedCoin.multipliedBy(poolCoinPrice);
1564
- const rateYearFactor = 365 * 24 * 60 * 60;
1565
- const rewardPerSec = BigNumber(distributedPointPerSec).shiftedBy(
1566
- -1 * rewardCoinDecimal
1567
- );
1568
- const rewardValueForYear = BigNumber(rewardPerSec).multipliedBy(rateYearFactor).multipliedBy(rewardCoinPrice);
1569
- const weightScale = BigNumber(1e12);
1570
- const rewardRate = rewardValueForYear.multipliedBy(
1571
- BigNumber(parsedBorrowIncentivePoolPointData.baseWeight).dividedBy(
1572
- weightScale
1573
- )
1574
- ).dividedBy(weightedStakedValue).isFinite() && parsedBorrowIncentivePoolPointData.points > 0 ? rewardValueForYear.multipliedBy(
1575
- BigNumber(parsedBorrowIncentivePoolPointData.baseWeight).dividedBy(
1576
- weightScale
1577
- )
1578
- ).dividedBy(weightedStakedValue).toNumber() : Infinity;
1579
- return {
1580
- distributedPointPerSec: distributedPointPerSec.toNumber(),
1581
- accumulatedPoints: accumulatedPoints.toNumber(),
1582
- currentPointIndex: currentPointIndex.toNumber(),
1583
- currentTotalDistributedPoint: currentTotalDistributedPoint.toNumber(),
1584
- baseWeight: baseWeight.toNumber(),
1585
- weightedStakedAmount: weightedStakedAmount.toNumber(),
1586
- weightedStakedCoin: weightedStakedCoin.toNumber(),
1587
- weightedStakedValue: weightedStakedValue.toNumber(),
1588
- rewardApr: rewardRate,
1589
- rewardPerSec: rewardPerSec.toNumber()
1590
- };
1591
- };
1592
- var parseOriginBorrowIncentiveAccountPoolPointData = (originBorrowIncentiveAccountPoolPointData) => {
1593
- return {
1594
- pointType: normalizeStructTag(
1595
- originBorrowIncentiveAccountPoolPointData.point_type.name
1596
- ),
1597
- weightedAmount: Number(
1598
- originBorrowIncentiveAccountPoolPointData.weighted_amount
1599
- ),
1600
- points: Number(originBorrowIncentiveAccountPoolPointData.points),
1601
- totalPoints: Number(originBorrowIncentiveAccountPoolPointData.total_points),
1602
- index: Number(originBorrowIncentiveAccountPoolPointData.index)
1603
- };
1604
- };
1605
- var parseOriginBorrowIncentiveAccountData = (originBorrowIncentiveAccountData) => {
1606
- return {
1607
- poolType: normalizeStructTag(
1608
- originBorrowIncentiveAccountData.pool_type.name
1609
- ),
1610
- debtAmount: Number(originBorrowIncentiveAccountData.debt_amount),
1611
- pointList: originBorrowIncentiveAccountData.points_list.reduce(
1612
- (acc, point) => {
1613
- const parsed = parseOriginBorrowIncentiveAccountPoolPointData(point);
1614
- const name = parseStructTag(
1615
- parsed.pointType
1616
- ).name.toLowerCase();
1617
- acc[name] = parsed;
1618
- return acc;
1662
+ wapt: {
1663
+ id: "",
1664
+ metaData: "",
1665
+ treasury: "",
1666
+ oracle: {
1667
+ supra: "",
1668
+ switchboard: "",
1669
+ pyth: {
1670
+ feed: "",
1671
+ feedObject: ""
1672
+ }
1673
+ }
1619
1674
  },
1620
- {}
1621
- )
1622
- };
1623
- };
1624
- var minBigNumber = (...args) => {
1625
- return BigNumber(
1626
- args.reduce(
1627
- (min, current) => new BigNumber(current).lt(min) ? current : min
1628
- )
1629
- );
1630
- };
1631
- var estimatedFactor = (amount, scaleStep, type) => {
1632
- const amountOfDigits = Math.max(
1633
- 1,
1634
- Math.floor(Math.log10(Math.abs(amount)) + 1)
1635
- );
1636
- const adjustScale = Math.max(Math.floor((amountOfDigits - 1) / scaleStep), 1) + 1;
1637
- let adjustFactor = Math.pow(10, -adjustScale);
1638
- adjustFactor = type === "increase" ? 1 - adjustFactor : 1 + adjustFactor;
1639
- return adjustFactor;
1640
- };
1641
-
1642
- // src/utils/util.ts
1643
- var COIN_SET = Array.from(
1644
- /* @__PURE__ */ new Set([
1645
- ...SUPPORT_POOLS,
1646
- ...SUPPORT_COLLATERALS,
1647
- ...SUPPORT_SPOOLS_REWARDS,
1648
- ...SUPPORT_BORROW_INCENTIVE_REWARDS,
1649
- ...SUPPORT_SCOIN
1650
- ])
1651
- );
1652
- var isMarketCoin = (coinName) => {
1653
- const assetCoinName = coinName.slice(1).toLowerCase();
1654
- return coinName.charAt(0).toLowerCase() === "s" && COIN_SET.includes(assetCoinName);
1655
- };
1656
- var isSuiBridgeAsset = (coinName) => {
1657
- return SUPPORT_SUI_BRIDGE.includes(coinName);
1658
- };
1659
- var isWormholeAsset = (coinName) => {
1660
- return SUPPORT_WORMHOLE.includes(coinName);
1661
- };
1662
- var parseAssetSymbol = (coinName) => {
1663
- if (isWormholeAsset(coinName)) {
1664
- return `w${coinName.slice(1).toUpperCase()}`;
1665
- }
1666
- if (isSuiBridgeAsset(coinName)) {
1667
- return `sb${coinName.slice(2).toUpperCase()}`;
1668
- }
1669
- if (isMarketCoin(coinName)) {
1670
- const assetCoinName = coinName.slice(1).toLowerCase();
1671
- return coinName.slice(0, 1).toLowerCase() + parseAssetSymbol(assetCoinName);
1672
- }
1673
- switch (coinName) {
1674
- case "afsui":
1675
- return "afSUI";
1676
- case "hasui":
1677
- return "haSUI";
1678
- case "vsui":
1679
- return "vSUI";
1680
- default:
1681
- return coinName.toUpperCase();
1682
- }
1683
- };
1684
- var parseDataFromPythPriceFeed = (feed, address) => {
1685
- const assetCoinNames = COIN_SET;
1686
- const assetCoinName = assetCoinNames.find((assetCoinName2) => {
1687
- return address.get(`core.coins.${assetCoinName2}.oracle.pyth.feed`) === feed.id;
1688
- });
1689
- if (assetCoinName) {
1690
- const price = feed.price.price * 10 ** feed.price.expo;
1691
- return {
1692
- coinName: assetCoinName,
1693
- price,
1694
- publishTime: Number(feed.price.publishTime) * 10 ** 3
1695
- };
1696
- } else {
1697
- throw new Error("Invalid feed id");
1698
- }
1699
- };
1700
- var findClosestUnlockRound = (unlockAtInSecondTimestamp) => {
1701
- const unlockDate = new Date(unlockAtInSecondTimestamp * 1e3);
1702
- const closestTwelveAM = new Date(unlockAtInSecondTimestamp * 1e3);
1703
- closestTwelveAM.setUTCHours(0, 0, 0, 0);
1704
- if (unlockDate.getUTCHours() >= 0) {
1705
- closestTwelveAM.setUTCDate(closestTwelveAM.getUTCDate() + 1);
1706
- }
1707
- const now = (/* @__PURE__ */ new Date()).getTime();
1708
- if (closestTwelveAM.getTime() - now > MAX_LOCK_DURATION * 1e3) {
1709
- closestTwelveAM.setUTCDate(closestTwelveAM.getUTCDate() - 1);
1710
- }
1711
- return Math.floor(closestTwelveAM.getTime() / 1e3);
1712
- };
1713
- var partitionArray = (array, chunkSize) => {
1714
- const result = [];
1715
- for (let i = 0; i < array.length; i += chunkSize) {
1716
- result.push(array.slice(i, i + chunkSize));
1717
- }
1718
- return result;
1719
- };
1720
-
1721
- // src/utils/tokenBucket.ts
1722
- var TokenBucket = class {
1723
- constructor(tokensPerInterval, intervalInMs) {
1724
- this.tokensPerInterval = tokensPerInterval;
1725
- this.interval = intervalInMs;
1726
- this.tokens = tokensPerInterval;
1727
- this.lastRefill = Date.now();
1728
- }
1729
- refill() {
1730
- const now = Date.now();
1731
- const elapsed = now - this.lastRefill;
1732
- if (elapsed >= this.interval) {
1733
- const tokensToAdd = Math.floor(elapsed / this.interval) * this.tokensPerInterval;
1734
- this.tokens = Math.min(this.tokens + tokensToAdd, this.tokensPerInterval);
1735
- this.lastRefill += Math.floor(elapsed / this.interval) * this.interval;
1736
- }
1737
- }
1738
- removeTokens(count) {
1739
- this.refill();
1740
- if (this.tokens >= count) {
1741
- this.tokens -= count;
1742
- return true;
1743
- }
1744
- return false;
1745
- }
1746
- };
1747
- var callWithRateLimit = async (tokenBucket, fn, retryDelayInMs = DEFAULT_INTERVAL_IN_MS, maxRetries = 15, backoffFactor = 1.25) => {
1748
- let retries = 0;
1749
- const tryRequest = async () => {
1750
- if (tokenBucket.removeTokens(1)) {
1751
- const result = await fn();
1752
- return result;
1753
- } else if (retries < maxRetries) {
1754
- retries++;
1755
- const delay = retryDelayInMs * Math.pow(backoffFactor, retries);
1756
- await new Promise((resolve) => setTimeout(resolve, delay));
1757
- return tryRequest();
1758
- } else {
1759
- console.error("Maximum retries reached");
1760
- return null;
1761
- }
1762
- };
1763
- return tryRequest();
1764
- };
1765
-
1766
- // src/utils/indexer.ts
1767
- async function callMethodWithIndexerFallback(method, context, ...args) {
1768
- const lastArgs = args[args.length - 1];
1769
- if (typeof lastArgs === "object" && lastArgs.indexer) {
1770
- try {
1771
- return await method.apply(context, args);
1772
- } catch (e) {
1773
- console.warn(`Indexer requests failed: ${e}. Retrying without indexer..`);
1774
- return await method.apply(context, [
1775
- ...args.slice(0, -1),
1776
- {
1777
- ...lastArgs,
1778
- indexer: false
1779
- }
1780
- ]);
1781
- }
1782
- }
1783
- return await method.apply(context, args);
1784
- }
1785
- function withIndexerFallback(method) {
1786
- return (...args) => {
1787
- return callMethodWithIndexerFallback(method, this, ...args);
1788
- };
1789
- }
1790
-
1791
- // src/utils/core.ts
1792
- var parseObjectAs = (object) => {
1793
- if (!(object && object.content && "fields" in object.content))
1794
- throw new Error(`Failed to parse object`);
1795
- const fields = object.content.fields;
1796
- if (typeof fields === "object" && "value" in fields) {
1797
- const value = fields.value;
1798
- if (typeof value === "object" && "fields" in value)
1799
- return value.fields;
1800
- return value;
1801
- } else if (typeof fields === "object") {
1802
- return fields;
1803
- }
1804
- return fields;
1805
- };
1806
-
1807
- // src/models/scallopCache.ts
1808
- var ScallopCache = class {
1809
- constructor(suiKit, walletAddress, cacheOptions, tokenBucket, queryClient) {
1810
- this.queryClient = queryClient ?? new QueryClient(cacheOptions ?? DEFAULT_CACHE_OPTIONS);
1811
- this._suiKit = suiKit;
1812
- this.tokenBucket = tokenBucket ?? new TokenBucket(DEFAULT_TOKENS_PER_INTERVAL, DEFAULT_INTERVAL_IN_MS);
1813
- this.walletAddress = walletAddress ?? suiKit.currentAddress();
1814
- }
1815
- get suiKit() {
1816
- if (!this._suiKit) {
1817
- throw new Error("SuiKit instance is not initialized");
1818
- }
1819
- return this._suiKit;
1820
- }
1821
- get client() {
1822
- return this.suiKit.client();
1823
- }
1824
- /**
1825
- * @description Invalidate cache based on the refetchType parameter
1826
- * @param refetchType Determines the type of queries to be refetched. Defaults to `active`.
1827
- *
1828
- * - `active`: Only queries that match the refetch predicate and are actively being rendered via useQuery and related functions will be refetched in the background.
1829
- * - `inactive`: Only queries that match the refetch predicate and are NOT actively being rendered via useQuery and related functions will be refetched in the background.
1830
- * - `all`: All queries that match the refetch predicate will be refetched in the background.
1831
- * - `none`: No queries will be refetched. Queries that match the refetch predicate will only be marked as invalid.
1832
- */
1833
- async invalidateAllCache() {
1834
- return Object.values(queryKeys.rpc).map(
1835
- (t) => this.queryClient.invalidateQueries({
1836
- queryKey: t(),
1837
- type: "all"
1838
- })
1839
- );
1840
- }
1841
- retryFn(errCount, e) {
1842
- if (errCount === 5)
1843
- return false;
1844
- if (e.status === 429)
1845
- return true;
1846
- return false;
1847
- }
1848
- /**
1849
- * @description Provides cache for inspectTxn of the SuiKit.
1850
- * @param QueryInspectTxnParams
1851
- * @param txBlock
1852
- * @returns Promise<DevInspectResults>
1853
- */
1854
- async queryInspectTxn({
1855
- queryTarget,
1856
- args,
1857
- typeArgs
1858
- }) {
1859
- const txBlock = new SuiTxBlock();
1860
- const resolvedArgs = await Promise.all(
1861
- args.map(async (arg) => {
1862
- if (typeof arg === "string") {
1863
- return (await this.queryGetObject(arg))?.data;
1864
- }
1865
- return arg;
1866
- })
1867
- );
1868
- txBlock.moveCall(queryTarget, resolvedArgs, typeArgs);
1869
- const query = await this.queryClient.fetchQuery({
1870
- retry: this.retryFn,
1871
- retryDelay: 1e3,
1872
- queryKey: queryKeys.rpc.getInspectTxn(queryTarget, args, typeArgs),
1873
- queryFn: async () => {
1874
- return await callWithRateLimit(
1875
- this.tokenBucket,
1876
- async () => await this.suiKit.inspectTxn(txBlock)
1877
- );
1878
- }
1879
- });
1880
- return query;
1881
- }
1882
- /**
1883
- * @description Provides cache for getObject of the SuiKit.
1884
- * @param objectId
1885
- * @param QueryObjectParams
1886
- * @returns Promise<SuiObjectResponse>
1887
- */
1888
- async queryGetObject(objectId, options) {
1889
- return this.queryClient.fetchQuery({
1890
- retry: this.retryFn,
1891
- retryDelay: 1e3,
1892
- queryKey: queryKeys.rpc.getObject(objectId, options),
1893
- queryFn: async () => {
1894
- return await callWithRateLimit(
1895
- this.tokenBucket,
1896
- async () => await this.client.getObject({
1897
- id: objectId,
1898
- options
1899
- })
1900
- );
1901
- }
1902
- });
1903
- }
1904
- /**
1905
- * @description Provides cache for getObjects of the SuiKit.
1906
- * @param objectIds
1907
- * @returns Promise<SuiObjectData[]>
1908
- */
1909
- async queryGetObjects(objectIds, options = {
1910
- showContent: true
1911
- }) {
1912
- if (objectIds.length === 0)
1913
- return [];
1914
- return this.queryClient.fetchQuery({
1915
- retry: this.retryFn,
1916
- retryDelay: 1e3,
1917
- queryKey: queryKeys.rpc.getObjects(
1918
- objectIds,
1919
- this.walletAddress,
1920
- options
1921
- ),
1922
- queryFn: async () => {
1923
- const results = await callWithRateLimit(
1924
- this.tokenBucket,
1925
- async () => await this.suiKit.getObjects(objectIds, options)
1926
- );
1927
- if (results) {
1928
- results.forEach((result) => {
1929
- this.queryClient.setQueriesData(
1930
- {
1931
- exact: false,
1932
- queryKey: queryKeys.rpc.getObject(result.objectId, options)
1933
- },
1934
- {
1935
- data: result,
1936
- error: null
1937
- },
1938
- {
1939
- updatedAt: Date.now()
1940
- }
1941
- );
1942
- });
1943
- }
1944
- return results;
1945
- }
1946
- });
1947
- }
1948
- /**
1949
- * @description Provides cache for getOwnedObjects of the SuiKit.
1950
- * @param input
1951
- * @returns Promise<PaginatedObjectsResponse>
1952
- */
1953
- async queryGetOwnedObjects(input) {
1954
- return this.queryClient.fetchQuery({
1955
- retry: this.retryFn,
1956
- retryDelay: 1e3,
1957
- queryKey: queryKeys.rpc.getOwnedObjects(input),
1958
- queryFn: async () => {
1959
- return await callWithRateLimit(
1960
- this.tokenBucket,
1961
- async () => await this.client.getOwnedObjects(input)
1962
- );
1963
- }
1964
- });
1965
- }
1966
- async queryGetDynamicFields(input) {
1967
- return this.queryClient.fetchQuery({
1968
- retry: this.retryFn,
1969
- retryDelay: 1e3,
1970
- queryKey: queryKeys.rpc.getDynamicFields(input),
1971
- queryFn: async () => {
1972
- return await callWithRateLimit(
1973
- this.tokenBucket,
1974
- async () => await this.client.getDynamicFields(input)
1975
- );
1976
- }
1977
- });
1978
- }
1979
- async queryGetDynamicFieldObject(input) {
1980
- return this.queryClient.fetchQuery({
1981
- retry: this.retryFn,
1982
- retryDelay: (attemptIndex) => Math.min(1e3 * attemptIndex, 8e3),
1983
- queryKey: queryKeys.rpc.getDynamicFieldObject(input),
1984
- queryFn: async () => {
1985
- return await callWithRateLimit(
1986
- this.tokenBucket,
1987
- () => this.client.getDynamicFieldObject(input)
1988
- );
1989
- }
1990
- });
1991
- }
1992
- async queryGetAllCoinBalances(owner) {
1993
- return this.queryClient.fetchQuery({
1994
- retry: this.retryFn,
1995
- retryDelay: 1e3,
1996
- queryKey: queryKeys.rpc.getAllCoinBalances(owner),
1997
- queryFn: async () => {
1998
- const allBalances = await callWithRateLimit(
1999
- this.tokenBucket,
2000
- async () => await this.client.getAllBalances({ owner })
2001
- );
2002
- if (!allBalances)
2003
- return {};
2004
- const balances = allBalances.reduce(
2005
- (acc, coinBalance) => {
2006
- if (coinBalance.totalBalance !== "0") {
2007
- acc[normalizeStructTag2(coinBalance.coinType)] = coinBalance.totalBalance;
2008
- }
2009
- return acc;
2010
- },
2011
- {}
2012
- );
2013
- return balances;
2014
- }
2015
- });
2016
- }
2017
- async queryGetCoinBalance(input) {
2018
- if (!input.coinType)
2019
- return "0";
2020
- return (await this.queryGetAllCoinBalances(input.owner) ?? {})[normalizeStructTag2(input.coinType)] ?? "0";
2021
- }
2022
- };
2023
-
2024
- // src/models/scallopAddress.ts
2025
- import axios from "axios";
2026
- var EMPTY_ADDRESSES = {
2027
- core: {
2028
- version: "",
2029
- versionCap: "",
2030
- object: "",
2031
- market: "",
2032
- adminCap: "",
2033
- coinDecimalsRegistry: "",
2034
- obligationAccessStore: "",
2035
- coins: {
2036
- cetus: {
2037
- id: "",
2038
- metaData: "",
2039
- treasury: "",
2040
- oracle: {
2041
- supra: "",
2042
- switchboard: "",
2043
- pyth: {
2044
- feed: "",
2045
- feedObject: ""
2046
- }
2047
- }
2048
- },
2049
- wapt: {
2050
- id: "",
2051
- metaData: "",
2052
- treasury: "",
2053
- oracle: {
2054
- supra: "",
2055
- switchboard: "",
2056
- pyth: {
2057
- feed: "",
2058
- feedObject: ""
2059
- }
2060
- }
2061
- },
2062
- wsol: {
2063
- id: "",
2064
- metaData: "",
2065
- treasury: "",
2066
- oracle: {
2067
- supra: "",
2068
- switchboard: "",
2069
- pyth: {
2070
- feed: "",
2071
- feedObject: ""
2072
- }
1675
+ wsol: {
1676
+ id: "",
1677
+ metaData: "",
1678
+ treasury: "",
1679
+ oracle: {
1680
+ supra: "",
1681
+ switchboard: "",
1682
+ pyth: {
1683
+ feed: "",
1684
+ feedObject: ""
1685
+ }
2073
1686
  }
2074
1687
  },
2075
1688
  wbtc: {
@@ -2357,342 +1970,959 @@ var EMPTY_ADDRESSES = {
2357
1970
  coinType: "",
2358
1971
  treasury: ""
2359
1972
  },
2360
- svsui: {
2361
- coinType: "",
2362
- treasury: ""
2363
- }
2364
- }
2365
- }
1973
+ svsui: {
1974
+ coinType: "",
1975
+ treasury: ""
1976
+ }
1977
+ }
1978
+ }
1979
+ };
1980
+ var ScallopAddress = class {
1981
+ constructor(params, instance) {
1982
+ const { id, auth, network, forceInterface } = params;
1983
+ this.cache = instance?.cache ?? new ScallopCache({});
1984
+ this._requestClient = axios.create({
1985
+ baseURL: API_BASE_URL,
1986
+ headers: {
1987
+ "Content-Type": "application/json",
1988
+ Accept: "application/json"
1989
+ },
1990
+ timeout: 8e3
1991
+ });
1992
+ if (auth)
1993
+ this._auth = auth;
1994
+ this._id = id;
1995
+ this._network = network ?? "mainnet";
1996
+ this._addressesMap = USE_TEST_ADDRESS ? /* @__PURE__ */ new Map([["mainnet", TEST_ADDRESSES]]) : /* @__PURE__ */ new Map();
1997
+ if (USE_TEST_ADDRESS)
1998
+ this._currentAddresses = TEST_ADDRESSES;
1999
+ if (forceInterface) {
2000
+ for (const [network2, addresses] of Object.entries(
2001
+ forceInterface
2002
+ )) {
2003
+ if (["localnet", "devnet", "testnet", "mainnet"].includes(network2)) {
2004
+ if (network2 === this._network)
2005
+ this._currentAddresses = addresses;
2006
+ this._addressesMap.set(network2, addresses);
2007
+ }
2008
+ }
2009
+ }
2010
+ }
2011
+ /**
2012
+ * Get addresses API id.
2013
+ *
2014
+ * @return The addresses API id.
2015
+ */
2016
+ getId() {
2017
+ return this._id || void 0;
2018
+ }
2019
+ /**
2020
+ * Get the address at the provided path.
2021
+ *
2022
+ * @param path - The path of the address to get.
2023
+ * @return The address at the provided path.
2024
+ */
2025
+ get(path) {
2026
+ if (this._currentAddresses) {
2027
+ const value = path.split(".").reduce(
2028
+ (nestedAddressObj, key) => typeof nestedAddressObj === "object" ? nestedAddressObj[key] : nestedAddressObj,
2029
+ this._currentAddresses
2030
+ );
2031
+ return value || void 0;
2032
+ } else {
2033
+ return void 0;
2034
+ }
2035
+ }
2036
+ /**
2037
+ * Sets the address for the specified path, it does not interact with the API.
2038
+ *
2039
+ * @param path - The path of the address to set.
2040
+ * @param address - The address be setted to the tartget path.
2041
+ * @return The addresses.
2042
+ */
2043
+ set(path, address) {
2044
+ if (this._currentAddresses) {
2045
+ const keys = path.split(".");
2046
+ keys.reduce((nestedAddressObj, key, index) => {
2047
+ if (index === keys.length - 1) {
2048
+ nestedAddressObj[key] = address;
2049
+ } else {
2050
+ return nestedAddressObj[key];
2051
+ }
2052
+ }, this._currentAddresses);
2053
+ }
2054
+ return this._currentAddresses;
2055
+ }
2056
+ /**
2057
+ * Synchronize the specified network addresses from the addresses map to the
2058
+ * current addresses and change the default network to specified network.
2059
+ *
2060
+ * @param network - Specifies which network's addresses you want to get.
2061
+ * @return Current addresses.
2062
+ */
2063
+ switchCurrentAddresses(network) {
2064
+ if (this._addressesMap.has(network)) {
2065
+ this._currentAddresses = this._addressesMap.get(network);
2066
+ this._network = network;
2067
+ }
2068
+ return this._currentAddresses;
2069
+ }
2070
+ /**
2071
+ * Get the addresses, If `network` is not provided, returns the current
2072
+ * addresses or the default network addresses in the addresses map.
2073
+ *
2074
+ * @param network - Specifies which network's addresses you want to get.
2075
+ */
2076
+ getAddresses(network) {
2077
+ if (network) {
2078
+ return this._addressesMap.get(network);
2079
+ } else {
2080
+ return this._currentAddresses ?? this._addressesMap.get(this._network);
2081
+ }
2082
+ }
2083
+ /**
2084
+ * Set the addresses into addresses map. If the specified network is the same
2085
+ * as the current network, the current addresses will be updated at the same time.
2086
+ *
2087
+ * @param addresses - The addresses be setted to the tartget network.
2088
+ * @param network - Specifies which network's addresses you want to set.
2089
+ * @return The addresses.
2090
+ */
2091
+ setAddresses(addresses, network) {
2092
+ const targetNetwork = network || this._network;
2093
+ if (targetNetwork === this._network)
2094
+ this._currentAddresses = addresses;
2095
+ this._addressesMap.set(targetNetwork, addresses);
2096
+ }
2097
+ /**
2098
+ * Get all addresses.
2099
+ *
2100
+ * @return All addresses.
2101
+ */
2102
+ getAllAddresses() {
2103
+ return Object.fromEntries(this._addressesMap);
2104
+ }
2105
+ /**
2106
+ * Create a new addresses through the API and synchronize it back to the
2107
+ * instance.
2108
+ *
2109
+ * @description
2110
+ * If the `network` is not specified, the mainnet is used by default.
2111
+ * If no `addresses` from instance or parameter is provided, an addresses with
2112
+ * all empty strings is created by default.
2113
+ *
2114
+ * This function only allows for one addresses to be input into a specific network
2115
+ * at a time, and does not provide an addresses map for setting addresses
2116
+ * across all networks at once.
2117
+ *
2118
+ * @param params.addresses - The addresses be setted to the tartget network.
2119
+ * @param params.network - Specifies which network's addresses you want to set.
2120
+ * @param params.auth - The authentication API key.
2121
+ * @param params.memo - Add memo to the addresses created in the API.
2122
+ * @return All addresses.
2123
+ */
2124
+ async create(params) {
2125
+ const { addresses, network, auth, memo } = params ?? {};
2126
+ const apiKey = auth || this._auth || void 0;
2127
+ const targetNetwork = network || this._network;
2128
+ const targetAddresses = addresses || this._currentAddresses || this._addressesMap.get(targetNetwork) || EMPTY_ADDRESSES;
2129
+ if (apiKey !== void 0) {
2130
+ this._addressesMap.clear();
2131
+ this.setAddresses(targetAddresses, targetNetwork);
2132
+ const response = await this._requestClient.post(
2133
+ `/addresses`,
2134
+ JSON.stringify({ ...Object.fromEntries(this._addressesMap), memo }),
2135
+ {
2136
+ headers: {
2137
+ "Content-Type": "application/json",
2138
+ "api-key": auth || this._auth
2139
+ }
2140
+ }
2141
+ );
2142
+ if (response.status === 201) {
2143
+ for (const [network2, addresses2] of Object.entries(
2144
+ response.data
2145
+ )) {
2146
+ if (["localnet", "devnet", "testnet", "mainnet"].includes(network2)) {
2147
+ if (network2 === this._network)
2148
+ this._currentAddresses = addresses2;
2149
+ this._addressesMap.set(network2, addresses2);
2150
+ }
2151
+ }
2152
+ this._id = response.data.id;
2153
+ return this.getAllAddresses();
2154
+ } else {
2155
+ throw Error("Failed to create addresses.");
2156
+ }
2157
+ } else {
2158
+ throw Error("You don't have permission to access this request.");
2159
+ }
2160
+ }
2161
+ /**
2162
+ * Read and synchronizes all addresses from the API into instance.
2163
+ *
2164
+ * @param id - The id of the addresses to get.
2165
+ * @return All addresses.
2166
+ */
2167
+ async read(id) {
2168
+ const addressesId = id || this._id || void 0;
2169
+ if (addressesId !== void 0) {
2170
+ const response = await this.cache.queryClient.fetchQuery({
2171
+ queryKey: queryKeys.api.getAddresses(addressesId),
2172
+ queryFn: async () => {
2173
+ return await this._requestClient.get(`/addresses/${addressesId}`, {
2174
+ headers: {
2175
+ "Content-Type": "application/json"
2176
+ }
2177
+ });
2178
+ }
2179
+ });
2180
+ if (response.status === 200) {
2181
+ for (const [network, addresses] of Object.entries(
2182
+ response.data
2183
+ )) {
2184
+ if (["localnet", "devnet", "testnet", "mainnet"].includes(network)) {
2185
+ if (network === this._network)
2186
+ this._currentAddresses = addresses;
2187
+ this._addressesMap.set(network, addresses);
2188
+ }
2189
+ }
2190
+ this._id = response.data.id;
2191
+ return this.getAllAddresses();
2192
+ } else {
2193
+ throw Error("Failed to create addresses.");
2194
+ }
2195
+ } else {
2196
+ throw Error("Please provide API addresses id.");
2197
+ }
2198
+ }
2199
+ /**
2200
+ * Update the addresses through the API and synchronize it back to the
2201
+ * instance.
2202
+ *
2203
+ * @description
2204
+ * If the `network` is not specified, the mainnet is used by default.
2205
+ * If no `addresses` from instance or parameter is provided, an addresses with
2206
+ * all empty strings is created by default.
2207
+ *
2208
+ * This function only allows for one addresses to be input into a specific network
2209
+ * at a time, and does not provide an addresses map for setting addresses
2210
+ * across all networks at once.
2211
+ *
2212
+ * @param params.id - The id of the addresses to update.
2213
+ * @param params.addresses - The addresses be setted to the tartget network.
2214
+ * @param params.network - Specifies which network's addresses you want to set.
2215
+ * @param params.auth - The authentication api key.
2216
+ * @param params.memo - Add memo to the addresses created in the API.
2217
+ * @return All addresses.
2218
+ */
2219
+ async update(params) {
2220
+ const { id, addresses, network, auth, memo } = params ?? {};
2221
+ const apiKey = auth || this._auth || void 0;
2222
+ const targetId = id || this._id || void 0;
2223
+ const targetNetwork = network || this._network;
2224
+ const targetAddresses = addresses || this._currentAddresses || this._addressesMap.get(targetNetwork) || EMPTY_ADDRESSES;
2225
+ if (targetId === void 0)
2226
+ throw Error("Require specific addresses id to be updated.");
2227
+ if (apiKey !== void 0) {
2228
+ if (id !== this._id) {
2229
+ this._addressesMap.clear();
2230
+ }
2231
+ this.setAddresses(targetAddresses, targetNetwork);
2232
+ const response = await this._requestClient.put(
2233
+ `/addresses/${targetId}`,
2234
+ JSON.stringify({ ...Object.fromEntries(this._addressesMap), memo }),
2235
+ {
2236
+ headers: {
2237
+ "Content-Type": "application/json",
2238
+ "api-key": auth || this._auth
2239
+ }
2240
+ }
2241
+ );
2242
+ if (response.status === 200) {
2243
+ for (const [network2, addresses2] of Object.entries(
2244
+ response.data
2245
+ )) {
2246
+ if (["localnet", "devnet", "testnet", "mainnet"].includes(network2)) {
2247
+ if (network2 === this._network)
2248
+ this._currentAddresses = addresses2;
2249
+ this._addressesMap.set(network2, addresses2);
2250
+ }
2251
+ }
2252
+ this._id = response.data.id;
2253
+ return this.getAllAddresses();
2254
+ } else {
2255
+ throw Error("Failed to update addresses.");
2256
+ }
2257
+ } else {
2258
+ throw Error("You don't have permission to access this request.");
2259
+ }
2260
+ }
2261
+ /**
2262
+ * Deletes all addresses of a specified id through the API and clear all
2263
+ * addresses in the instance.
2264
+ *
2265
+ * @param id - The id of the addresses to delete.
2266
+ * @param auth - The authentication API key.
2267
+ */
2268
+ async delete(id, auth) {
2269
+ const apiKey = auth || this._auth || void 0;
2270
+ const targetId = id || this._id || void 0;
2271
+ if (targetId === void 0)
2272
+ throw Error("Require specific addresses id to be deleted.");
2273
+ if (apiKey !== void 0) {
2274
+ const response = await this._requestClient.delete(
2275
+ `/addresses/${targetId}`,
2276
+ {
2277
+ headers: {
2278
+ "Content-Type": "application/json",
2279
+ "api-key": auth || this._auth
2280
+ }
2281
+ }
2282
+ );
2283
+ if (response.status === 200) {
2284
+ this._id = void 0;
2285
+ this._currentAddresses = void 0;
2286
+ this._addressesMap.clear();
2287
+ } else {
2288
+ throw Error("Failed to delete addresses.");
2289
+ }
2290
+ } else {
2291
+ throw Error("You don't have permission to access this request.");
2292
+ }
2293
+ }
2294
+ };
2295
+
2296
+ // src/models/scallopClient.ts
2297
+ import { normalizeSuiAddress as normalizeSuiAddress3 } from "@mysten/sui/utils";
2298
+
2299
+ // src/models/scallopUtils.ts
2300
+ import { SUI_TYPE_ARG as SUI_TYPE_ARG2, normalizeStructTag as normalizeStructTag7 } from "@mysten/sui/utils";
2301
+ import { SuiPriceServiceConnection } from "@pythnetwork/pyth-sui-js";
2302
+
2303
+ // src/queries/borrowIncentiveQuery.ts
2304
+ import { normalizeStructTag as normalizeStructTag3 } from "@mysten/sui/utils";
2305
+
2306
+ // src/utils/builder.ts
2307
+ var requireSender = (txBlock) => {
2308
+ const sender = txBlock.blockData.sender;
2309
+ if (!sender) {
2310
+ throw new Error("Sender is required");
2311
+ }
2312
+ return sender;
2313
+ };
2314
+ var checkVesca = (prevUnlockAtInMillisTimestamp) => {
2315
+ if (prevUnlockAtInMillisTimestamp === void 0) {
2316
+ throw new Error("veSca not found");
2317
+ }
2318
+ };
2319
+ var checkVescaExpired = (prevUnlockAtInMillisTimestamp) => {
2320
+ if (prevUnlockAtInMillisTimestamp <= (/* @__PURE__ */ new Date()).getTime()) {
2321
+ throw new Error("veSca is expired, use renewExpiredVeScaQuick instead");
2322
+ }
2323
+ };
2324
+ var checkExtendLockPeriod = (lockPeriodInDays, newUnlockAtInSecondTimestamp, prevUnlockAtInMillisTimestamp) => {
2325
+ checkVesca(prevUnlockAtInMillisTimestamp);
2326
+ checkVescaExpired(prevUnlockAtInMillisTimestamp);
2327
+ const prevUnlockAtInSecondTimestamp = Math.floor(
2328
+ prevUnlockAtInMillisTimestamp / 1e3
2329
+ );
2330
+ if (lockPeriodInDays < 1) {
2331
+ throw new Error("Minimum lock period is 1 day");
2332
+ }
2333
+ const availableLockPeriodInDays = Math.floor(
2334
+ (newUnlockAtInSecondTimestamp - prevUnlockAtInSecondTimestamp) / UNLOCK_ROUND_DURATION
2335
+ );
2336
+ if (lockPeriodInDays > availableLockPeriodInDays) {
2337
+ throw new Error(
2338
+ `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}`
2339
+ );
2340
+ }
2341
+ };
2342
+ var checkLockSca = (scaAmountOrCoin, lockPeriodInDays, newUnlockAtInSecondTimestamp, prevUnlockAtInMillisTimestamp) => {
2343
+ const prevUnlockAtInSecondTimestamp = prevUnlockAtInMillisTimestamp ? Math.floor(prevUnlockAtInMillisTimestamp / 1e3) : void 0;
2344
+ const isInitialLock = !prevUnlockAtInSecondTimestamp;
2345
+ const isLockExpired = !isInitialLock && prevUnlockAtInSecondTimestamp * 1e3 <= (/* @__PURE__ */ new Date()).getTime();
2346
+ if (isInitialLock || isLockExpired) {
2347
+ if (scaAmountOrCoin !== void 0 && lockPeriodInDays !== void 0) {
2348
+ if (lockPeriodInDays <= 0) {
2349
+ throw new Error("Lock period must be greater than 0");
2350
+ }
2351
+ if (typeof scaAmountOrCoin === "number" && scaAmountOrCoin < MIN_INITIAL_LOCK_AMOUNT) {
2352
+ throw new Error(
2353
+ `Minimum lock amount for ${isLockExpired ? "renewing expired veSca" : "initial lock"} is 10 SCA`
2354
+ );
2355
+ }
2356
+ const extendLockPeriodInSecond = lockPeriodInDays * UNLOCK_ROUND_DURATION;
2357
+ if (extendLockPeriodInSecond > MAX_LOCK_DURATION) {
2358
+ throw new Error(
2359
+ `Maximum lock period is ~4 years (${MAX_LOCK_ROUNDS} days)`
2360
+ );
2361
+ }
2362
+ } else {
2363
+ throw new Error(
2364
+ `SCA amount and lock period is required for ${isLockExpired ? "renewing expired veSca" : "initial lock"}`
2365
+ );
2366
+ }
2367
+ } else {
2368
+ checkVesca(prevUnlockAtInMillisTimestamp);
2369
+ checkVescaExpired(prevUnlockAtInMillisTimestamp);
2370
+ if (typeof scaAmountOrCoin === "number" && scaAmountOrCoin < MIN_TOP_UP_AMOUNT) {
2371
+ throw new Error("Minimum top up amount is 1 SCA");
2372
+ }
2373
+ if (newUnlockAtInSecondTimestamp && lockPeriodInDays) {
2374
+ checkExtendLockPeriod(
2375
+ lockPeriodInDays,
2376
+ newUnlockAtInSecondTimestamp,
2377
+ prevUnlockAtInMillisTimestamp
2378
+ );
2379
+ }
2380
+ }
2381
+ };
2382
+ var checkExtendLockAmount = (scaAmount, prevUnlockAtInMillisTimestamp) => {
2383
+ checkVesca(prevUnlockAtInMillisTimestamp);
2384
+ checkVescaExpired(prevUnlockAtInMillisTimestamp);
2385
+ if (scaAmount < MIN_TOP_UP_AMOUNT) {
2386
+ throw new Error("Minimum top up amount is 1 SCA");
2387
+ }
2388
+ const isInitialLock = !prevUnlockAtInMillisTimestamp;
2389
+ const isLockExpired = !isInitialLock && prevUnlockAtInMillisTimestamp <= (/* @__PURE__ */ new Date()).getTime();
2390
+ if (isLockExpired) {
2391
+ throw new Error("veSca is expired, use renewExpiredVeScaQuick instead");
2392
+ }
2393
+ };
2394
+ var checkRenewExpiredVeSca = (scaAmount, lockPeriodInDays, prevUnlockAtInMillisTimestamp) => {
2395
+ if (!prevUnlockAtInMillisTimestamp || prevUnlockAtInMillisTimestamp > (/* @__PURE__ */ new Date()).getTime()) {
2396
+ throw new Error("Renew method can only be used for expired veSca");
2397
+ }
2398
+ if (scaAmount < MIN_INITIAL_LOCK_AMOUNT) {
2399
+ throw new Error("Minimum lock amount for renewing expired vesca 10 SCA");
2400
+ }
2401
+ const extendLockPeriodInSecond = lockPeriodInDays * UNLOCK_ROUND_DURATION;
2402
+ if (extendLockPeriodInSecond >= MAX_LOCK_DURATION - UNLOCK_ROUND_DURATION) {
2403
+ throw new Error(
2404
+ `Maximum lock period is ~4 years (${MAX_LOCK_ROUNDS - 1} days)`
2405
+ );
2406
+ }
2407
+ };
2408
+
2409
+ // src/utils/query.ts
2410
+ import BigNumber from "bignumber.js";
2411
+ import { normalizeStructTag as normalizeStructTag2, parseStructTag as parseStructTag2 } from "@mysten/sui/utils";
2412
+ var parseOriginMarketPoolData = (originMarketPoolData) => {
2413
+ return {
2414
+ coinType: normalizeStructTag2(originMarketPoolData.type.name),
2415
+ // Parse origin data required for basic calculations.
2416
+ maxBorrowRate: Number(originMarketPoolData.maxBorrowRate.value) / 2 ** 32,
2417
+ borrowRate: Number(originMarketPoolData.interestRate.value) / 2 ** 32,
2418
+ borrowRateScale: Number(originMarketPoolData.interestRateScale),
2419
+ borrowIndex: Number(originMarketPoolData.borrowIndex),
2420
+ lastUpdated: Number(originMarketPoolData.lastUpdated),
2421
+ cashAmount: Number(originMarketPoolData.cash),
2422
+ debtAmount: Number(originMarketPoolData.debt),
2423
+ marketCoinSupplyAmount: Number(originMarketPoolData.marketCoinSupply),
2424
+ reserveAmount: Number(originMarketPoolData.reserve),
2425
+ reserveFactor: Number(originMarketPoolData.reserveFactor.value) / 2 ** 32,
2426
+ borrowWeight: Number(originMarketPoolData.borrowWeight.value) / 2 ** 32,
2427
+ borrowFee: Number(originMarketPoolData.borrowFeeRate.value) / 2 ** 32,
2428
+ // Parse origin data required for additional display.
2429
+ baseBorrowRate: Number(originMarketPoolData.baseBorrowRatePerSec.value) / 2 ** 32,
2430
+ borrowRateOnHighKink: Number(originMarketPoolData.borrowRateOnHighKink.value) / 2 ** 32,
2431
+ borrowRateOnMidKink: Number(originMarketPoolData.borrowRateOnMidKink.value) / 2 ** 32,
2432
+ highKink: Number(originMarketPoolData.highKink.value) / 2 ** 32,
2433
+ midKink: Number(originMarketPoolData.midKink.value) / 2 ** 32,
2434
+ minBorrowAmount: Number(originMarketPoolData.minBorrowAmount),
2435
+ isIsolated: originMarketPoolData.isIsolated,
2436
+ supplyLimit: Number(originMarketPoolData.supplyLimit),
2437
+ borrowLimit: Number(originMarketPoolData.borrowLimit)
2438
+ };
2439
+ };
2440
+ var calculateMarketPoolData = (utils, parsedMarketPoolData) => {
2441
+ const poolCoinName = utils.parseCoinNameFromType(
2442
+ parsedMarketPoolData.coinType
2443
+ );
2444
+ const coinDecimal = utils.getCoinDecimal(poolCoinName);
2445
+ const borrowYearFactor = 24 * 365 * 3600;
2446
+ const baseBorrowApr = parsedMarketPoolData.baseBorrowRate * borrowYearFactor / parsedMarketPoolData.borrowRateScale;
2447
+ const borrowAprOnHighKink = parsedMarketPoolData.borrowRateOnHighKink * borrowYearFactor / parsedMarketPoolData.borrowRateScale;
2448
+ const borrowAprOnMidKink = parsedMarketPoolData.borrowRateOnMidKink * borrowYearFactor / parsedMarketPoolData.borrowRateScale;
2449
+ const maxBorrowApr = parsedMarketPoolData.maxBorrowRate * borrowYearFactor / parsedMarketPoolData.borrowRateScale;
2450
+ const borrowApr = parsedMarketPoolData.borrowRate * borrowYearFactor / parsedMarketPoolData.borrowRateScale;
2451
+ const timeDelta = Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3) - parsedMarketPoolData.lastUpdated;
2452
+ const borrowIndexDelta = BigNumber(parsedMarketPoolData.borrowIndex).multipliedBy(
2453
+ BigNumber(timeDelta).multipliedBy(parsedMarketPoolData.borrowRate)
2454
+ ).dividedBy(parsedMarketPoolData.borrowRateScale);
2455
+ const currentBorrowIndex = BigNumber(parsedMarketPoolData.borrowIndex).plus(
2456
+ borrowIndexDelta
2457
+ );
2458
+ const growthInterest = BigNumber(currentBorrowIndex).dividedBy(parsedMarketPoolData.borrowIndex).minus(1);
2459
+ const increasedDebtAmount = BigNumber(
2460
+ parsedMarketPoolData.debtAmount
2461
+ ).multipliedBy(growthInterest);
2462
+ const borrowAmount = increasedDebtAmount.plus(
2463
+ parsedMarketPoolData.debtAmount
2464
+ );
2465
+ const borrowCoin = borrowAmount.shiftedBy(-1 * coinDecimal);
2466
+ const reserveAmount = BigNumber(parsedMarketPoolData.reserveAmount).plus(
2467
+ increasedDebtAmount.multipliedBy(parsedMarketPoolData.reserveFactor)
2468
+ );
2469
+ const reserveCoin = reserveAmount.shiftedBy(-1 * coinDecimal);
2470
+ const supplyAmount = BigNumber(borrowAmount).plus(
2471
+ Math.max(parsedMarketPoolData.cashAmount - reserveAmount.toNumber(), 0)
2472
+ );
2473
+ const supplyCoin = supplyAmount.shiftedBy(-1 * coinDecimal);
2474
+ let utilizationRate = BigNumber(borrowAmount).dividedBy(supplyAmount);
2475
+ utilizationRate = utilizationRate.isFinite() ? utilizationRate : BigNumber(0);
2476
+ let supplyApr = BigNumber(borrowApr).multipliedBy(utilizationRate).multipliedBy(1 - parsedMarketPoolData.reserveFactor);
2477
+ supplyApr = supplyApr.isFinite() ? supplyApr : BigNumber(0);
2478
+ let conversionRate = supplyAmount.dividedBy(
2479
+ parsedMarketPoolData.marketCoinSupplyAmount
2480
+ );
2481
+ conversionRate = conversionRate.isFinite() && !conversionRate.isNaN() ? conversionRate : BigNumber(1);
2482
+ return {
2483
+ baseBorrowApr,
2484
+ baseBorrowApy: utils.parseAprToApy(baseBorrowApr),
2485
+ borrowAprOnHighKink,
2486
+ borrowApyOnHighKink: utils.parseAprToApy(borrowAprOnHighKink),
2487
+ borrowAprOnMidKink,
2488
+ borrowApyOnMidKink: utils.parseAprToApy(borrowAprOnMidKink),
2489
+ coinDecimal,
2490
+ maxBorrowApr,
2491
+ maxBorrowApy: utils.parseAprToApy(maxBorrowApr),
2492
+ borrowApr: Math.min(borrowApr, maxBorrowApr),
2493
+ borrowApy: Math.min(
2494
+ utils.parseAprToApy(borrowApr),
2495
+ utils.parseAprToApy(maxBorrowApr)
2496
+ ),
2497
+ borrowIndex: currentBorrowIndex.toNumber(),
2498
+ growthInterest: growthInterest.toNumber(),
2499
+ supplyAmount: supplyAmount.toNumber(),
2500
+ supplyCoin: supplyCoin.toNumber(),
2501
+ borrowAmount: borrowAmount.toNumber(),
2502
+ borrowCoin: borrowCoin.toNumber(),
2503
+ reserveAmount: reserveAmount.toNumber(),
2504
+ reserveCoin: reserveCoin.toNumber(),
2505
+ utilizationRate: utilizationRate.toNumber(),
2506
+ supplyApr: supplyApr.toNumber(),
2507
+ supplyApy: utils.parseAprToApy(supplyApr.toNumber()),
2508
+ conversionRate: conversionRate.toNumber(),
2509
+ isIsolated: parsedMarketPoolData.isIsolated,
2510
+ maxSupplyCoin: BigNumber(parsedMarketPoolData.supplyLimit).shiftedBy(-coinDecimal).toNumber(),
2511
+ maxBorrowCoin: BigNumber(parsedMarketPoolData.borrowLimit).shiftedBy(-coinDecimal).toNumber()
2512
+ };
2513
+ };
2514
+ var parseOriginMarketCollateralData = (originMarketCollateralData) => {
2515
+ const divisor = 2 ** 32;
2516
+ return {
2517
+ coinType: normalizeStructTag2(originMarketCollateralData.type.name),
2518
+ isIsolated: originMarketCollateralData.isIsolated,
2519
+ collateralFactor: Number(originMarketCollateralData.collateralFactor.value) / divisor,
2520
+ liquidationFactor: Number(originMarketCollateralData.liquidationFactor.value) / divisor,
2521
+ liquidationDiscount: Number(originMarketCollateralData.liquidationDiscount.value) / divisor,
2522
+ liquidationPenalty: Number(originMarketCollateralData.liquidationPenalty.value) / divisor,
2523
+ liquidationReserveFactor: Number(originMarketCollateralData.liquidationReserveFactor.value) / divisor,
2524
+ maxCollateralAmount: Number(originMarketCollateralData.maxCollateralAmount),
2525
+ totalCollateralAmount: Number(
2526
+ originMarketCollateralData.totalCollateralAmount
2527
+ )
2528
+ };
2529
+ };
2530
+ var calculateMarketCollateralData = (utils, parsedMarketCollateralData) => {
2531
+ const collateralCoinName = utils.parseCoinNameFromType(
2532
+ parsedMarketCollateralData.coinType
2533
+ );
2534
+ const coinDecimal = utils.getCoinDecimal(collateralCoinName);
2535
+ const maxCollateralCoin = BigNumber(
2536
+ parsedMarketCollateralData.maxCollateralAmount
2537
+ ).shiftedBy(-1 * coinDecimal);
2538
+ const depositCoin = BigNumber(
2539
+ parsedMarketCollateralData.totalCollateralAmount
2540
+ ).shiftedBy(-1 * coinDecimal);
2541
+ return {
2542
+ coinDecimal,
2543
+ isIsolated: parsedMarketCollateralData.isIsolated,
2544
+ maxDepositAmount: parsedMarketCollateralData.maxCollateralAmount,
2545
+ maxDepositCoin: maxCollateralCoin.toNumber(),
2546
+ depositAmount: parsedMarketCollateralData.totalCollateralAmount,
2547
+ depositCoin: depositCoin.toNumber()
2548
+ };
2549
+ };
2550
+ var parseOriginSpoolData = (originSpoolData) => {
2551
+ return {
2552
+ stakeType: normalizeStructTag2(originSpoolData.stakeType.fields.name),
2553
+ maxPoint: Number(originSpoolData.maxDistributedPoint),
2554
+ distributedPoint: Number(originSpoolData.distributedPoint),
2555
+ pointPerPeriod: Number(originSpoolData.distributedPointPerPeriod),
2556
+ period: Number(originSpoolData.pointDistributionTime),
2557
+ maxStake: Number(originSpoolData.maxStake),
2558
+ staked: Number(originSpoolData.stakes),
2559
+ index: Number(originSpoolData.index),
2560
+ createdAt: Number(originSpoolData.createdAt),
2561
+ lastUpdate: Number(originSpoolData.lastUpdate)
2562
+ };
2563
+ };
2564
+ var calculateSpoolData = (parsedSpoolData, stakeMarketCoinPrice, stakeMarketCoinDecimal) => {
2565
+ const baseIndexRate = 1e9;
2566
+ const distributedPointPerSec = BigNumber(
2567
+ parsedSpoolData.pointPerPeriod
2568
+ ).dividedBy(parsedSpoolData.period);
2569
+ const pointPerSec = BigNumber(parsedSpoolData.pointPerPeriod).dividedBy(
2570
+ parsedSpoolData.period
2571
+ );
2572
+ const remainingPeriod = pointPerSec.gt(0) ? BigNumber(parsedSpoolData.maxPoint).minus(parsedSpoolData.distributedPoint).dividedBy(pointPerSec) : BigNumber(0);
2573
+ const startDate = parsedSpoolData.createdAt;
2574
+ const endDate = remainingPeriod.plus(parsedSpoolData.lastUpdate).integerValue().toNumber();
2575
+ const timeDelta = BigNumber(
2576
+ Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3) - parsedSpoolData.lastUpdate
2577
+ ).dividedBy(parsedSpoolData.period).toFixed(0);
2578
+ const remainingPoints = BigNumber(parsedSpoolData.maxPoint).minus(
2579
+ parsedSpoolData.distributedPoint
2580
+ );
2581
+ const accumulatedPoints = BigNumber.minimum(
2582
+ BigNumber(timeDelta).multipliedBy(parsedSpoolData.pointPerPeriod),
2583
+ remainingPoints
2584
+ );
2585
+ const currentPointIndex = BigNumber(parsedSpoolData.index).plus(
2586
+ accumulatedPoints.dividedBy(parsedSpoolData.staked).isFinite() ? BigNumber(baseIndexRate).multipliedBy(accumulatedPoints).dividedBy(parsedSpoolData.staked) : 0
2587
+ );
2588
+ const currentTotalDistributedPoint = BigNumber(
2589
+ parsedSpoolData.distributedPoint
2590
+ ).plus(accumulatedPoints);
2591
+ const stakedAmount = BigNumber(parsedSpoolData.staked);
2592
+ const stakedCoin = stakedAmount.shiftedBy(-1 * stakeMarketCoinDecimal);
2593
+ const stakedValue = stakedCoin.multipliedBy(stakeMarketCoinPrice);
2594
+ return {
2595
+ distributedPointPerSec: distributedPointPerSec.toNumber(),
2596
+ accumulatedPoints: accumulatedPoints.toNumber(),
2597
+ currentPointIndex: currentPointIndex.toNumber(),
2598
+ currentTotalDistributedPoint: currentTotalDistributedPoint.toNumber(),
2599
+ startDate: new Date(startDate * 1e3),
2600
+ endDate: new Date(endDate * 1e3),
2601
+ stakedAmount: stakedAmount.toNumber(),
2602
+ stakedCoin: stakedCoin.toNumber(),
2603
+ stakedValue: stakedValue.toNumber()
2604
+ };
2605
+ };
2606
+ var parseOriginSpoolRewardPoolData = (originSpoolRewardPoolData) => {
2607
+ return {
2608
+ claimedRewards: Number(originSpoolRewardPoolData.claimed_rewards),
2609
+ exchangeRateDenominator: Number(
2610
+ originSpoolRewardPoolData.exchange_rate_denominator
2611
+ ),
2612
+ exchangeRateNumerator: Number(
2613
+ originSpoolRewardPoolData.exchange_rate_numerator
2614
+ ),
2615
+ rewards: Number(originSpoolRewardPoolData.rewards),
2616
+ spoolId: String(originSpoolRewardPoolData.spool_id)
2617
+ };
2618
+ };
2619
+ var calculateSpoolRewardPoolData = (parsedSpoolData, parsedSpoolRewardPoolData, calculatedSpoolData, rewardCoinPrice, rewardCoinDecimal) => {
2620
+ const rateYearFactor = 365 * 24 * 60 * 60;
2621
+ const rewardPerSec = BigNumber(calculatedSpoolData.distributedPointPerSec).multipliedBy(parsedSpoolRewardPoolData.exchangeRateNumerator).dividedBy(parsedSpoolRewardPoolData.exchangeRateDenominator);
2622
+ const totalRewardAmount = BigNumber(parsedSpoolData.maxPoint).multipliedBy(parsedSpoolRewardPoolData.exchangeRateNumerator).dividedBy(parsedSpoolRewardPoolData.exchangeRateDenominator);
2623
+ const totalRewardCoin = totalRewardAmount.shiftedBy(-1 * rewardCoinDecimal);
2624
+ const totalRewardValue = totalRewardCoin.multipliedBy(rewardCoinPrice);
2625
+ const remaindRewardAmount = BigNumber(parsedSpoolRewardPoolData.rewards);
2626
+ const remaindRewardCoin = remaindRewardAmount.shiftedBy(
2627
+ -1 * rewardCoinDecimal
2628
+ );
2629
+ const remaindRewardValue = remaindRewardCoin.multipliedBy(rewardCoinPrice);
2630
+ const claimedRewardAmount = BigNumber(
2631
+ parsedSpoolRewardPoolData.claimedRewards
2632
+ );
2633
+ const claimedRewardCoin = claimedRewardAmount.shiftedBy(
2634
+ -1 * rewardCoinDecimal
2635
+ );
2636
+ const claimedRewardValue = claimedRewardCoin.multipliedBy(rewardCoinPrice);
2637
+ const rewardValueForYear = BigNumber(rewardPerSec).shiftedBy(-1 * rewardCoinDecimal).multipliedBy(rateYearFactor).multipliedBy(rewardCoinPrice);
2638
+ let rewardRate = rewardValueForYear.dividedBy(calculatedSpoolData.stakedValue).isFinite() ? rewardValueForYear.dividedBy(calculatedSpoolData.stakedValue).toNumber() : Infinity;
2639
+ if (parsedSpoolData.maxPoint <= parsedSpoolData.distributedPoint || parsedSpoolData.pointPerPeriod === 0) {
2640
+ rewardRate = Infinity;
2641
+ }
2642
+ return {
2643
+ rewardApr: rewardRate,
2644
+ totalRewardAmount: totalRewardAmount.toNumber(),
2645
+ totalRewardCoin: totalRewardCoin.toNumber(),
2646
+ totalRewardValue: totalRewardValue.toNumber(),
2647
+ remaindRewardAmount: remaindRewardAmount.toNumber(),
2648
+ remaindRewardCoin: remaindRewardCoin.toNumber(),
2649
+ remaindRewardValue: remaindRewardValue.toNumber(),
2650
+ claimedRewardAmount: claimedRewardAmount.toNumber(),
2651
+ claimedRewardCoin: claimedRewardCoin.toNumber(),
2652
+ claimedRewardValue: claimedRewardValue.toNumber(),
2653
+ rewardPerSec: rewardPerSec.toNumber()
2654
+ };
2655
+ };
2656
+ var parseOriginBorrowIncentivesPoolPointData = (originBorrowIncentivePoolPointData) => {
2657
+ return {
2658
+ pointType: normalizeStructTag2(
2659
+ originBorrowIncentivePoolPointData.point_type.name
2660
+ ),
2661
+ distributedPointPerPeriod: Number(
2662
+ originBorrowIncentivePoolPointData.distributed_point_per_period
2663
+ ),
2664
+ period: Number(originBorrowIncentivePoolPointData.point_distribution_time),
2665
+ distributedPoint: Number(
2666
+ originBorrowIncentivePoolPointData.distributed_point
2667
+ ),
2668
+ points: Number(originBorrowIncentivePoolPointData.points),
2669
+ index: Number(originBorrowIncentivePoolPointData.index),
2670
+ baseWeight: Number(originBorrowIncentivePoolPointData.base_weight),
2671
+ weightedAmount: Number(originBorrowIncentivePoolPointData.weighted_amount),
2672
+ lastUpdate: Number(originBorrowIncentivePoolPointData.last_update),
2673
+ createdAt: Number(originBorrowIncentivePoolPointData.created_at)
2674
+ };
2675
+ };
2676
+ var parseOriginBorrowIncentivePoolData = (utils, originBorrowIncentivePoolData) => {
2677
+ return {
2678
+ poolType: normalizeStructTag2(originBorrowIncentivePoolData.pool_type.name),
2679
+ minStakes: Number(originBorrowIncentivePoolData.min_stakes),
2680
+ maxStakes: Number(originBorrowIncentivePoolData.max_stakes),
2681
+ staked: Number(originBorrowIncentivePoolData.stakes),
2682
+ poolPoints: originBorrowIncentivePoolData.points.reduce(
2683
+ (acc, point) => {
2684
+ const parsed = parseOriginBorrowIncentivesPoolPointData(point);
2685
+ const name = utils.parseSCoinTypeNameToMarketCoinName(
2686
+ parseStructTag2(parsed.pointType).name.toLowerCase()
2687
+ );
2688
+ acc[name] = parsed;
2689
+ return acc;
2690
+ },
2691
+ {}
2692
+ )
2693
+ };
2366
2694
  };
2367
- var ScallopAddress = class {
2368
- constructor(params, instance) {
2369
- const { id, auth, network, forceInterface } = params;
2370
- this.cache = instance?.cache ?? new ScallopCache(
2371
- instance?.suiKit ?? new SuiKit({}),
2372
- void 0,
2373
- DEFAULT_CACHE_OPTIONS
2374
- );
2375
- this._requestClient = axios.create({
2376
- baseURL: API_BASE_URL,
2377
- headers: {
2378
- "Content-Type": "application/json",
2379
- Accept: "application/json"
2695
+ var calculateBorrowIncentivePoolPointData = (parsedBorrowIncentivePoolPointData, rewardCoinPrice, rewardCoinDecimal, poolCoinPrice, poolCoinDecimal) => {
2696
+ const baseIndexRate = 1e9;
2697
+ const distributedPointPerSec = BigNumber(
2698
+ parsedBorrowIncentivePoolPointData.distributedPointPerPeriod
2699
+ ).dividedBy(parsedBorrowIncentivePoolPointData.period);
2700
+ const timeDelta = BigNumber(
2701
+ Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3) - parsedBorrowIncentivePoolPointData.lastUpdate
2702
+ ).dividedBy(parsedBorrowIncentivePoolPointData.period).toFixed(0);
2703
+ const accumulatedPoints = BigNumber.minimum(
2704
+ BigNumber(timeDelta).multipliedBy(
2705
+ parsedBorrowIncentivePoolPointData.distributedPointPerPeriod
2706
+ ),
2707
+ BigNumber(parsedBorrowIncentivePoolPointData.points)
2708
+ );
2709
+ const currentPointIndex = BigNumber(
2710
+ parsedBorrowIncentivePoolPointData.index
2711
+ ).plus(
2712
+ accumulatedPoints.dividedBy(parsedBorrowIncentivePoolPointData.weightedAmount).isFinite() ? BigNumber(baseIndexRate).multipliedBy(accumulatedPoints).dividedBy(parsedBorrowIncentivePoolPointData.weightedAmount) : 0
2713
+ );
2714
+ const currentTotalDistributedPoint = BigNumber(
2715
+ parsedBorrowIncentivePoolPointData.distributedPoint
2716
+ ).plus(accumulatedPoints);
2717
+ const baseWeight = BigNumber(parsedBorrowIncentivePoolPointData.baseWeight);
2718
+ const weightedStakedAmount = BigNumber(
2719
+ parsedBorrowIncentivePoolPointData.weightedAmount
2720
+ );
2721
+ const weightedStakedCoin = weightedStakedAmount.shiftedBy(
2722
+ -1 * poolCoinDecimal
2723
+ );
2724
+ const weightedStakedValue = weightedStakedCoin.multipliedBy(poolCoinPrice);
2725
+ const rateYearFactor = 365 * 24 * 60 * 60;
2726
+ const rewardPerSec = BigNumber(distributedPointPerSec).shiftedBy(
2727
+ -1 * rewardCoinDecimal
2728
+ );
2729
+ const rewardValueForYear = BigNumber(rewardPerSec).multipliedBy(rateYearFactor).multipliedBy(rewardCoinPrice);
2730
+ const weightScale = BigNumber(1e12);
2731
+ const rewardRate = rewardValueForYear.multipliedBy(
2732
+ BigNumber(parsedBorrowIncentivePoolPointData.baseWeight).dividedBy(
2733
+ weightScale
2734
+ )
2735
+ ).dividedBy(weightedStakedValue).isFinite() && parsedBorrowIncentivePoolPointData.points > 0 ? rewardValueForYear.multipliedBy(
2736
+ BigNumber(parsedBorrowIncentivePoolPointData.baseWeight).dividedBy(
2737
+ weightScale
2738
+ )
2739
+ ).dividedBy(weightedStakedValue).toNumber() : Infinity;
2740
+ return {
2741
+ distributedPointPerSec: distributedPointPerSec.toNumber(),
2742
+ accumulatedPoints: accumulatedPoints.toNumber(),
2743
+ currentPointIndex: currentPointIndex.toNumber(),
2744
+ currentTotalDistributedPoint: currentTotalDistributedPoint.toNumber(),
2745
+ baseWeight: baseWeight.toNumber(),
2746
+ weightedStakedAmount: weightedStakedAmount.toNumber(),
2747
+ weightedStakedCoin: weightedStakedCoin.toNumber(),
2748
+ weightedStakedValue: weightedStakedValue.toNumber(),
2749
+ rewardApr: rewardRate,
2750
+ rewardPerSec: rewardPerSec.toNumber()
2751
+ };
2752
+ };
2753
+ var parseOriginBorrowIncentiveAccountPoolPointData = (originBorrowIncentiveAccountPoolPointData) => {
2754
+ return {
2755
+ pointType: normalizeStructTag2(
2756
+ originBorrowIncentiveAccountPoolPointData.point_type.name
2757
+ ),
2758
+ weightedAmount: Number(
2759
+ originBorrowIncentiveAccountPoolPointData.weighted_amount
2760
+ ),
2761
+ points: Number(originBorrowIncentiveAccountPoolPointData.points),
2762
+ totalPoints: Number(originBorrowIncentiveAccountPoolPointData.total_points),
2763
+ index: Number(originBorrowIncentiveAccountPoolPointData.index)
2764
+ };
2765
+ };
2766
+ var parseOriginBorrowIncentiveAccountData = (originBorrowIncentiveAccountData) => {
2767
+ return {
2768
+ poolType: normalizeStructTag2(
2769
+ originBorrowIncentiveAccountData.pool_type.name
2770
+ ),
2771
+ debtAmount: Number(originBorrowIncentiveAccountData.debt_amount),
2772
+ pointList: originBorrowIncentiveAccountData.points_list.reduce(
2773
+ (acc, point) => {
2774
+ const parsed = parseOriginBorrowIncentiveAccountPoolPointData(point);
2775
+ const name = parseStructTag2(
2776
+ parsed.pointType
2777
+ ).name.toLowerCase();
2778
+ acc[name] = parsed;
2779
+ return acc;
2380
2780
  },
2381
- timeout: 8e3
2382
- });
2383
- if (auth)
2384
- this._auth = auth;
2385
- this._id = id;
2386
- this._network = network ?? "mainnet";
2387
- this._addressesMap = USE_TEST_ADDRESS ? /* @__PURE__ */ new Map([["mainnet", TEST_ADDRESSES]]) : /* @__PURE__ */ new Map();
2388
- if (USE_TEST_ADDRESS)
2389
- this._currentAddresses = TEST_ADDRESSES;
2390
- if (forceInterface) {
2391
- for (const [network2, addresses] of Object.entries(
2392
- forceInterface
2393
- )) {
2394
- if (["localnet", "devnet", "testnet", "mainnet"].includes(network2)) {
2395
- if (network2 === this._network)
2396
- this._currentAddresses = addresses;
2397
- this._addressesMap.set(network2, addresses);
2398
- }
2399
- }
2400
- }
2401
- }
2402
- /**
2403
- * Get addresses API id.
2404
- *
2405
- * @return The addresses API id.
2406
- */
2407
- getId() {
2408
- return this._id || void 0;
2409
- }
2410
- /**
2411
- * Get the address at the provided path.
2412
- *
2413
- * @param path - The path of the address to get.
2414
- * @return The address at the provided path.
2415
- */
2416
- get(path) {
2417
- if (this._currentAddresses) {
2418
- const value = path.split(".").reduce(
2419
- (nestedAddressObj, key) => typeof nestedAddressObj === "object" ? nestedAddressObj[key] : nestedAddressObj,
2420
- this._currentAddresses
2421
- );
2422
- return value || void 0;
2423
- } else {
2424
- return void 0;
2425
- }
2426
- }
2427
- /**
2428
- * Sets the address for the specified path, it does not interact with the API.
2429
- *
2430
- * @param path - The path of the address to set.
2431
- * @param address - The address be setted to the tartget path.
2432
- * @return The addresses.
2433
- */
2434
- set(path, address) {
2435
- if (this._currentAddresses) {
2436
- const keys = path.split(".");
2437
- keys.reduce((nestedAddressObj, key, index) => {
2438
- if (index === keys.length - 1) {
2439
- nestedAddressObj[key] = address;
2440
- } else {
2441
- return nestedAddressObj[key];
2442
- }
2443
- }, this._currentAddresses);
2444
- }
2445
- return this._currentAddresses;
2446
- }
2447
- /**
2448
- * Synchronize the specified network addresses from the addresses map to the
2449
- * current addresses and change the default network to specified network.
2450
- *
2451
- * @param network - Specifies which network's addresses you want to get.
2452
- * @return Current addresses.
2453
- */
2454
- switchCurrentAddresses(network) {
2455
- if (this._addressesMap.has(network)) {
2456
- this._currentAddresses = this._addressesMap.get(network);
2457
- this._network = network;
2458
- }
2459
- return this._currentAddresses;
2781
+ {}
2782
+ )
2783
+ };
2784
+ };
2785
+ var minBigNumber = (...args) => {
2786
+ return BigNumber(
2787
+ args.reduce(
2788
+ (min, current) => new BigNumber(current).lt(min) ? current : min
2789
+ )
2790
+ );
2791
+ };
2792
+ var estimatedFactor = (amount, scaleStep, type) => {
2793
+ const amountOfDigits = Math.max(
2794
+ 1,
2795
+ Math.floor(Math.log10(Math.abs(amount)) + 1)
2796
+ );
2797
+ const adjustScale = Math.max(Math.floor((amountOfDigits - 1) / scaleStep), 1) + 1;
2798
+ let adjustFactor = Math.pow(10, -adjustScale);
2799
+ adjustFactor = type === "increase" ? 1 - adjustFactor : 1 + adjustFactor;
2800
+ return adjustFactor;
2801
+ };
2802
+
2803
+ // src/utils/util.ts
2804
+ var COIN_SET = Array.from(
2805
+ /* @__PURE__ */ new Set([
2806
+ ...SUPPORT_POOLS,
2807
+ ...SUPPORT_COLLATERALS,
2808
+ ...SUPPORT_SPOOLS_REWARDS,
2809
+ ...SUPPORT_BORROW_INCENTIVE_REWARDS,
2810
+ ...SUPPORT_SCOIN
2811
+ ])
2812
+ );
2813
+ var isMarketCoin = (coinName) => {
2814
+ const assetCoinName = coinName.slice(1).toLowerCase();
2815
+ return coinName.charAt(0).toLowerCase() === "s" && COIN_SET.includes(assetCoinName);
2816
+ };
2817
+ var isSuiBridgeAsset = (coinName) => {
2818
+ return SUPPORT_SUI_BRIDGE.includes(coinName);
2819
+ };
2820
+ var isWormholeAsset = (coinName) => {
2821
+ return SUPPORT_WORMHOLE.includes(coinName);
2822
+ };
2823
+ var parseAssetSymbol = (coinName) => {
2824
+ if (isWormholeAsset(coinName)) {
2825
+ return `w${coinName.slice(1).toUpperCase()}`;
2460
2826
  }
2461
- /**
2462
- * Get the addresses, If `network` is not provided, returns the current
2463
- * addresses or the default network addresses in the addresses map.
2464
- *
2465
- * @param network - Specifies which network's addresses you want to get.
2466
- */
2467
- getAddresses(network) {
2468
- if (network) {
2469
- return this._addressesMap.get(network);
2470
- } else {
2471
- return this._currentAddresses ?? this._addressesMap.get(this._network);
2472
- }
2827
+ if (isSuiBridgeAsset(coinName)) {
2828
+ return `sb${coinName.slice(2).toUpperCase()}`;
2473
2829
  }
2474
- /**
2475
- * Set the addresses into addresses map. If the specified network is the same
2476
- * as the current network, the current addresses will be updated at the same time.
2477
- *
2478
- * @param addresses - The addresses be setted to the tartget network.
2479
- * @param network - Specifies which network's addresses you want to set.
2480
- * @return The addresses.
2481
- */
2482
- setAddresses(addresses, network) {
2483
- const targetNetwork = network || this._network;
2484
- if (targetNetwork === this._network)
2485
- this._currentAddresses = addresses;
2486
- this._addressesMap.set(targetNetwork, addresses);
2830
+ if (isMarketCoin(coinName)) {
2831
+ const assetCoinName = coinName.slice(1).toLowerCase();
2832
+ return coinName.slice(0, 1).toLowerCase() + parseAssetSymbol(assetCoinName);
2487
2833
  }
2488
- /**
2489
- * Get all addresses.
2490
- *
2491
- * @return All addresses.
2492
- */
2493
- getAllAddresses() {
2494
- return Object.fromEntries(this._addressesMap);
2834
+ switch (coinName) {
2835
+ case "afsui":
2836
+ return "afSUI";
2837
+ case "hasui":
2838
+ return "haSUI";
2839
+ case "vsui":
2840
+ return "vSUI";
2841
+ default:
2842
+ return coinName.toUpperCase();
2495
2843
  }
2496
- /**
2497
- * Create a new addresses through the API and synchronize it back to the
2498
- * instance.
2499
- *
2500
- * @description
2501
- * If the `network` is not specified, the mainnet is used by default.
2502
- * If no `addresses` from instance or parameter is provided, an addresses with
2503
- * all empty strings is created by default.
2504
- *
2505
- * This function only allows for one addresses to be input into a specific network
2506
- * at a time, and does not provide an addresses map for setting addresses
2507
- * across all networks at once.
2508
- *
2509
- * @param params.addresses - The addresses be setted to the tartget network.
2510
- * @param params.network - Specifies which network's addresses you want to set.
2511
- * @param params.auth - The authentication API key.
2512
- * @param params.memo - Add memo to the addresses created in the API.
2513
- * @return All addresses.
2514
- */
2515
- async create(params) {
2516
- const { addresses, network, auth, memo } = params ?? {};
2517
- const apiKey = auth || this._auth || void 0;
2518
- const targetNetwork = network || this._network;
2519
- const targetAddresses = addresses || this._currentAddresses || this._addressesMap.get(targetNetwork) || EMPTY_ADDRESSES;
2520
- if (apiKey !== void 0) {
2521
- this._addressesMap.clear();
2522
- this.setAddresses(targetAddresses, targetNetwork);
2523
- const response = await this._requestClient.post(
2524
- `/addresses`,
2525
- JSON.stringify({ ...Object.fromEntries(this._addressesMap), memo }),
2526
- {
2527
- headers: {
2528
- "Content-Type": "application/json",
2529
- "api-key": auth || this._auth
2530
- }
2531
- }
2532
- );
2533
- if (response.status === 201) {
2534
- for (const [network2, addresses2] of Object.entries(
2535
- response.data
2536
- )) {
2537
- if (["localnet", "devnet", "testnet", "mainnet"].includes(network2)) {
2538
- if (network2 === this._network)
2539
- this._currentAddresses = addresses2;
2540
- this._addressesMap.set(network2, addresses2);
2541
- }
2542
- }
2543
- this._id = response.data.id;
2544
- return this.getAllAddresses();
2545
- } else {
2546
- throw Error("Failed to create addresses.");
2547
- }
2548
- } else {
2549
- throw Error("You don't have permission to access this request.");
2550
- }
2844
+ };
2845
+ var parseDataFromPythPriceFeed = (feed, address) => {
2846
+ const assetCoinNames = COIN_SET;
2847
+ const assetCoinName = assetCoinNames.find((assetCoinName2) => {
2848
+ return address.get(`core.coins.${assetCoinName2}.oracle.pyth.feed`) === feed.id;
2849
+ });
2850
+ if (assetCoinName) {
2851
+ const price = feed.price.price * 10 ** feed.price.expo;
2852
+ return {
2853
+ coinName: assetCoinName,
2854
+ price,
2855
+ publishTime: Number(feed.price.publishTime) * 10 ** 3
2856
+ };
2857
+ } else {
2858
+ throw new Error("Invalid feed id");
2551
2859
  }
2552
- /**
2553
- * Read and synchronizes all addresses from the API into instance.
2554
- *
2555
- * @param id - The id of the addresses to get.
2556
- * @return All addresses.
2557
- */
2558
- async read(id) {
2559
- const addressesId = id || this._id || void 0;
2560
- if (addressesId !== void 0) {
2561
- const response = await this.cache.queryClient.fetchQuery({
2562
- queryKey: queryKeys.api.getAddresses(addressesId),
2563
- queryFn: async () => {
2564
- return await this._requestClient.get(`/addresses/${addressesId}`, {
2565
- headers: {
2566
- "Content-Type": "application/json"
2567
- }
2568
- });
2569
- }
2570
- });
2571
- if (response.status === 200) {
2572
- for (const [network, addresses] of Object.entries(
2573
- response.data
2574
- )) {
2575
- if (["localnet", "devnet", "testnet", "mainnet"].includes(network)) {
2576
- if (network === this._network)
2577
- this._currentAddresses = addresses;
2578
- this._addressesMap.set(network, addresses);
2579
- }
2580
- }
2581
- this._id = response.data.id;
2582
- return this.getAllAddresses();
2583
- } else {
2584
- throw Error("Failed to create addresses.");
2585
- }
2586
- } else {
2587
- throw Error("Please provide API addresses id.");
2588
- }
2860
+ };
2861
+ var findClosestUnlockRound = (unlockAtInSecondTimestamp) => {
2862
+ const unlockDate = new Date(unlockAtInSecondTimestamp * 1e3);
2863
+ const closestTwelveAM = new Date(unlockAtInSecondTimestamp * 1e3);
2864
+ closestTwelveAM.setUTCHours(0, 0, 0, 0);
2865
+ if (unlockDate.getUTCHours() >= 0) {
2866
+ closestTwelveAM.setUTCDate(closestTwelveAM.getUTCDate() + 1);
2589
2867
  }
2590
- /**
2591
- * Update the addresses through the API and synchronize it back to the
2592
- * instance.
2593
- *
2594
- * @description
2595
- * If the `network` is not specified, the mainnet is used by default.
2596
- * If no `addresses` from instance or parameter is provided, an addresses with
2597
- * all empty strings is created by default.
2598
- *
2599
- * This function only allows for one addresses to be input into a specific network
2600
- * at a time, and does not provide an addresses map for setting addresses
2601
- * across all networks at once.
2602
- *
2603
- * @param params.id - The id of the addresses to update.
2604
- * @param params.addresses - The addresses be setted to the tartget network.
2605
- * @param params.network - Specifies which network's addresses you want to set.
2606
- * @param params.auth - The authentication api key.
2607
- * @param params.memo - Add memo to the addresses created in the API.
2608
- * @return All addresses.
2609
- */
2610
- async update(params) {
2611
- const { id, addresses, network, auth, memo } = params ?? {};
2612
- const apiKey = auth || this._auth || void 0;
2613
- const targetId = id || this._id || void 0;
2614
- const targetNetwork = network || this._network;
2615
- const targetAddresses = addresses || this._currentAddresses || this._addressesMap.get(targetNetwork) || EMPTY_ADDRESSES;
2616
- if (targetId === void 0)
2617
- throw Error("Require specific addresses id to be updated.");
2618
- if (apiKey !== void 0) {
2619
- if (id !== this._id) {
2620
- this._addressesMap.clear();
2621
- }
2622
- this.setAddresses(targetAddresses, targetNetwork);
2623
- const response = await this._requestClient.put(
2624
- `/addresses/${targetId}`,
2625
- JSON.stringify({ ...Object.fromEntries(this._addressesMap), memo }),
2626
- {
2627
- headers: {
2628
- "Content-Type": "application/json",
2629
- "api-key": auth || this._auth
2630
- }
2631
- }
2632
- );
2633
- if (response.status === 200) {
2634
- for (const [network2, addresses2] of Object.entries(
2635
- response.data
2636
- )) {
2637
- if (["localnet", "devnet", "testnet", "mainnet"].includes(network2)) {
2638
- if (network2 === this._network)
2639
- this._currentAddresses = addresses2;
2640
- this._addressesMap.set(network2, addresses2);
2641
- }
2642
- }
2643
- this._id = response.data.id;
2644
- return this.getAllAddresses();
2645
- } else {
2646
- throw Error("Failed to update addresses.");
2647
- }
2648
- } else {
2649
- throw Error("You don't have permission to access this request.");
2650
- }
2868
+ const now = (/* @__PURE__ */ new Date()).getTime();
2869
+ if (closestTwelveAM.getTime() - now > MAX_LOCK_DURATION * 1e3) {
2870
+ closestTwelveAM.setUTCDate(closestTwelveAM.getUTCDate() - 1);
2651
2871
  }
2652
- /**
2653
- * Deletes all addresses of a specified id through the API and clear all
2654
- * addresses in the instance.
2655
- *
2656
- * @param id - The id of the addresses to delete.
2657
- * @param auth - The authentication API key.
2658
- */
2659
- async delete(id, auth) {
2660
- const apiKey = auth || this._auth || void 0;
2661
- const targetId = id || this._id || void 0;
2662
- if (targetId === void 0)
2663
- throw Error("Require specific addresses id to be deleted.");
2664
- if (apiKey !== void 0) {
2665
- const response = await this._requestClient.delete(
2666
- `/addresses/${targetId}`,
2872
+ return Math.floor(closestTwelveAM.getTime() / 1e3);
2873
+ };
2874
+ var partitionArray = (array, chunkSize) => {
2875
+ const result = [];
2876
+ for (let i = 0; i < array.length; i += chunkSize) {
2877
+ result.push(array.slice(i, i + chunkSize));
2878
+ }
2879
+ return result;
2880
+ };
2881
+
2882
+ // src/utils/indexer.ts
2883
+ async function callMethodWithIndexerFallback(method, context, ...args) {
2884
+ const lastArgs = args[args.length - 1];
2885
+ if (typeof lastArgs === "object" && lastArgs.indexer) {
2886
+ try {
2887
+ return await method.apply(context, args);
2888
+ } catch (e) {
2889
+ console.warn(
2890
+ `Indexer requests failed: ${e.message}. Retrying without indexer..`
2891
+ );
2892
+ return await method.apply(context, [
2893
+ ...args.slice(0, -1),
2667
2894
  {
2668
- headers: {
2669
- "Content-Type": "application/json",
2670
- "api-key": auth || this._auth
2671
- }
2895
+ ...lastArgs,
2896
+ indexer: false
2672
2897
  }
2673
- );
2674
- if (response.status === 200) {
2675
- this._id = void 0;
2676
- this._currentAddresses = void 0;
2677
- this._addressesMap.clear();
2678
- } else {
2679
- throw Error("Failed to delete addresses.");
2680
- }
2681
- } else {
2682
- throw Error("You don't have permission to access this request.");
2898
+ ]);
2683
2899
  }
2684
2900
  }
2685
- };
2686
-
2687
- // src/models/scallopClient.ts
2688
- import { normalizeSuiAddress as normalizeSuiAddress3 } from "@mysten/sui/utils";
2901
+ return await method.apply(context, args);
2902
+ }
2903
+ function withIndexerFallback(method) {
2904
+ return (...args) => {
2905
+ return callMethodWithIndexerFallback(method, this, ...args);
2906
+ };
2907
+ }
2689
2908
 
2690
- // src/models/scallopUtils.ts
2691
- import { SUI_TYPE_ARG, normalizeStructTag as normalizeStructTag6 } from "@mysten/sui/utils";
2692
- import { SuiPriceServiceConnection } from "@pythnetwork/pyth-sui-js";
2909
+ // src/utils/core.ts
2910
+ var parseObjectAs = (object) => {
2911
+ if (!(object && object.content && "fields" in object.content))
2912
+ throw new Error(`Failed to parse object`);
2913
+ const fields = object.content.fields;
2914
+ if (typeof fields === "object" && "value" in fields) {
2915
+ const value = fields.value;
2916
+ if (typeof value === "object" && "fields" in value)
2917
+ return value.fields;
2918
+ return value;
2919
+ } else if (typeof fields === "object") {
2920
+ return fields;
2921
+ }
2922
+ return fields;
2923
+ };
2693
2924
 
2694
2925
  // src/queries/borrowIncentiveQuery.ts
2695
- import { normalizeStructTag as normalizeStructTag3 } from "@mysten/sui/utils";
2696
2926
  import BigNumber2 from "bignumber.js";
2697
2927
  var queryBorrowIncentivePools = async (address) => {
2698
2928
  const queryPkgId = address.get("borrowIncentive.query");
@@ -2828,12 +3058,7 @@ var getBindedObligationId = async ({
2828
3058
  const borrowIncentiveObjectId = address.get("borrowIncentive.object");
2829
3059
  const incentivePoolsId = address.get("borrowIncentive.incentivePools");
2830
3060
  const veScaObjId = address.get("vesca.object");
2831
- const incentivePoolsResponse = await address.cache.queryGetObject(
2832
- incentivePoolsId,
2833
- {
2834
- showContent: true
2835
- }
2836
- );
3061
+ const incentivePoolsResponse = await address.cache.queryGetObject(incentivePoolsId);
2837
3062
  if (incentivePoolsResponse?.data?.content?.dataType !== "moveObject")
2838
3063
  return null;
2839
3064
  const incentivePoolFields = incentivePoolsResponse.data.content.fields;
@@ -2860,12 +3085,7 @@ var getBindedVeScaKey = async ({
2860
3085
  const borrowIncentiveObjectId = address.get("borrowIncentive.object");
2861
3086
  const incentiveAccountsId = address.get("borrowIncentive.incentiveAccounts");
2862
3087
  const corePkg = address.get("core.object");
2863
- const incentiveAccountsObject = await address.cache.queryGetObject(
2864
- incentiveAccountsId,
2865
- {
2866
- showContent: true
2867
- }
2868
- );
3088
+ const incentiveAccountsObject = await address.cache.queryGetObject(incentiveAccountsId);
2869
3089
  if (incentiveAccountsObject?.data?.content?.dataType !== "moveObject")
2870
3090
  return null;
2871
3091
  const incentiveAccountsTableId = incentiveAccountsObject.data.content.fields.accounts.fields.id.id;
@@ -3050,11 +3270,11 @@ var getBorrowLimit = async (utils, poolName) => {
3050
3270
  };
3051
3271
 
3052
3272
  // src/queries/objectsQuery.ts
3053
- var queryMultipleObjects = async (cache, objectIds, options, partitionSize = 50) => {
3273
+ var queryMultipleObjects = async (cache, objectIds, partitionSize = 50) => {
3054
3274
  const objectIdsPartition = partitionArray(objectIds, partitionSize);
3055
3275
  const objects = [];
3056
3276
  for (const objectIds2 of objectIdsPartition) {
3057
- const result = await cache.queryGetObjects(objectIds2, options);
3277
+ const result = await cache.queryGetObjects(objectIds2);
3058
3278
  objects.push(...result);
3059
3279
  }
3060
3280
  return objects;
@@ -3249,28 +3469,60 @@ var queryRequiredMarketObjects = async (query, poolCoinNames) => {
3249
3469
  tasks.map((task) => task.isolatedAssetKey).filter((t) => !!t)
3250
3470
  )
3251
3471
  ]);
3252
- const mapObjects = (tasks2, fetchedObjects) => {
3472
+ const mapObjects = (tasks2, fetchedObjects, keyValue) => {
3253
3473
  const resultMap = {};
3254
- let fetchedIndex = 0;
3474
+ const fetchedObjectMap = fetchedObjects.reduce(
3475
+ (acc, obj) => {
3476
+ acc[obj.objectId] = obj;
3477
+ return acc;
3478
+ },
3479
+ {}
3480
+ );
3255
3481
  for (const task of tasks2) {
3256
- const key = task[Object.keys(task)[1]];
3257
- if (key) {
3258
- resultMap[task.poolCoinName] = fetchedObjects[fetchedIndex];
3259
- fetchedIndex++;
3482
+ if (task[keyValue]) {
3483
+ resultMap[task.poolCoinName] = fetchedObjectMap[task[keyValue]];
3260
3484
  }
3261
3485
  }
3262
3486
  return resultMap;
3263
3487
  };
3264
- const balanceSheetMap = mapObjects(tasks, balanceSheetObjects);
3265
- const collateralStatMap = mapObjects(tasks, collateralStatObjects);
3266
- const borrowDynamicMap = mapObjects(tasks, borrowDynamicObjects);
3267
- const interestModelMap = mapObjects(tasks, interestModelObjects);
3268
- const riskModelMap = mapObjects(tasks, riskModelObjects);
3269
- const borrowFeeMap = mapObjects(tasks, borrowFeeObjects);
3270
- const supplyLimitMap = mapObjects(tasks, supplyLimitObjects);
3271
- const borrowLimitMap = mapObjects(tasks, borrowLimitObjects);
3272
- const isolatedAssetMap = mapObjects(tasks, isolatedAssetObjects);
3273
- return poolCoinNames.reduce(
3488
+ const balanceSheetMap = mapObjects(
3489
+ tasks,
3490
+ balanceSheetObjects,
3491
+ "balanceSheet"
3492
+ );
3493
+ const collateralStatMap = mapObjects(
3494
+ tasks,
3495
+ collateralStatObjects,
3496
+ "collateralStat"
3497
+ );
3498
+ const borrowDynamicMap = mapObjects(
3499
+ tasks,
3500
+ borrowDynamicObjects,
3501
+ "borrowDynamic"
3502
+ );
3503
+ const interestModelMap = mapObjects(
3504
+ tasks,
3505
+ interestModelObjects,
3506
+ "interestModel"
3507
+ );
3508
+ const riskModelMap = mapObjects(tasks, riskModelObjects, "riskModel");
3509
+ const borrowFeeMap = mapObjects(tasks, borrowFeeObjects, "borrowFeeKey");
3510
+ const supplyLimitMap = mapObjects(
3511
+ tasks,
3512
+ supplyLimitObjects,
3513
+ "supplyLimitKey"
3514
+ );
3515
+ const borrowLimitMap = mapObjects(
3516
+ tasks,
3517
+ borrowLimitObjects,
3518
+ "borrowLimitKey"
3519
+ );
3520
+ const isolatedAssetMap = mapObjects(
3521
+ tasks,
3522
+ isolatedAssetObjects,
3523
+ "isolatedAssetKey"
3524
+ );
3525
+ const result = poolCoinNames.reduce(
3274
3526
  (acc, name) => {
3275
3527
  acc[name] = {
3276
3528
  balanceSheet: balanceSheetMap[name],
@@ -3287,6 +3539,7 @@ var queryRequiredMarketObjects = async (query, poolCoinNames) => {
3287
3539
  },
3288
3540
  {}
3289
3541
  );
3542
+ return result;
3290
3543
  };
3291
3544
  var getMarketPools = async (query, poolCoinNames, indexer = false, coinPrices) => {
3292
3545
  coinPrices = coinPrices ?? await query.utils.getCoinPrices();
@@ -3492,9 +3745,7 @@ var getMarketCollaterals = async (query, collateralCoinNames = [...SUPPORT_COLLA
3492
3745
  Object.values(marketCollateralsIndexer).forEach(updateMarketCollateral);
3493
3746
  return marketCollaterals;
3494
3747
  }
3495
- const marketObjectResponse = await query.cache.queryGetObject(marketId, {
3496
- showContent: true
3497
- });
3748
+ const marketObjectResponse = await query.cache.queryGetObject(marketId);
3498
3749
  await Promise.allSettled(
3499
3750
  collateralCoinNames.map(async (collateralCoinName) => {
3500
3751
  const marketCollateral = await getMarketCollateral(
@@ -3522,9 +3773,7 @@ var getMarketCollateral = async (query, collateralCoinName, indexer = false, mar
3522
3773
  return marketCollateralIndexer;
3523
3774
  }
3524
3775
  const marketId = query.address.get("core.market");
3525
- marketObject = marketObject || (await query.cache.queryGetObject(marketId, {
3526
- showContent: true
3527
- }))?.data;
3776
+ marketObject = marketObject || (await query.cache.queryGetObject(marketId))?.data;
3528
3777
  if (!(marketObject && marketObject.content?.dataType === "moveObject"))
3529
3778
  throw new Error(`Failed to fetch marketObject`);
3530
3779
  const fields = marketObject.content.fields;
@@ -3623,14 +3872,23 @@ var getObligations = async ({
3623
3872
  } while (hasNextPage);
3624
3873
  const keyObjects = keyObjectsResponse.filter((ref) => !!ref.data);
3625
3874
  const obligations = [];
3875
+ const obligationsObjects = await queryMultipleObjects(
3876
+ address.cache,
3877
+ keyObjects.map((ref) => ref.data?.content).filter(
3878
+ (content) => content?.dataType === "moveObject"
3879
+ ).map((content) => content.fields.ownership.fields.of)
3880
+ );
3626
3881
  await Promise.allSettled(
3627
- keyObjects.map(async ({ data }) => {
3882
+ keyObjects.map(async ({ data }, idx) => {
3628
3883
  const keyId = data?.objectId;
3629
3884
  const content = data?.content;
3630
3885
  if (keyId && content && "fields" in content) {
3631
3886
  const fields = content.fields;
3632
3887
  const obligationId = String(fields.ownership.fields.of);
3633
- const locked = await getObligationLocked(address.cache, obligationId);
3888
+ const locked = await getObligationLocked(
3889
+ address.cache,
3890
+ obligationsObjects[idx]
3891
+ );
3634
3892
  obligations.push({ id: obligationId, keyId, locked });
3635
3893
  }
3636
3894
  })
@@ -3638,14 +3896,10 @@ var getObligations = async ({
3638
3896
  return obligations;
3639
3897
  };
3640
3898
  var getObligationLocked = async (cache, obligation) => {
3641
- const obligationObjectResponse = typeof obligation === "string" ? (await cache.queryGetObject(obligation, {
3642
- showContent: true
3643
- }))?.data : obligation;
3899
+ const obligationObjectData = typeof obligation === "string" ? (await cache.queryGetObject(obligation))?.data : obligation;
3644
3900
  let obligationLocked = false;
3645
- if (obligationObjectResponse && obligationObjectResponse?.content?.dataType === "moveObject" && "lock_key" in obligationObjectResponse.content.fields) {
3646
- obligationLocked = Boolean(
3647
- obligationObjectResponse.content.fields.lock_key
3648
- );
3901
+ if (obligationObjectData && obligationObjectData?.content?.dataType === "moveObject" && "lock_key" in obligationObjectData.content.fields) {
3902
+ obligationLocked = Boolean(obligationObjectData.content.fields.lock_key);
3649
3903
  }
3650
3904
  return obligationLocked;
3651
3905
  };
@@ -3675,11 +3929,11 @@ var getCoinAmounts = async (query, assetCoinNames = [...SUPPORT_POOLS], ownerAdd
3675
3929
  var getCoinAmount = async (query, assetCoinName, ownerAddress) => {
3676
3930
  const owner = ownerAddress ?? query.suiKit.currentAddress();
3677
3931
  const coinType = query.utils.parseCoinType(assetCoinName);
3678
- const amount = await query.cache.queryGetCoinBalance({
3932
+ const coinBalance = await query.cache.queryGetCoinBalance({
3679
3933
  owner,
3680
3934
  coinType
3681
3935
  });
3682
- return BigNumber3(amount).toNumber();
3936
+ return BigNumber3(coinBalance?.totalBalance ?? "0").toNumber();
3683
3937
  };
3684
3938
  var getMarketCoinAmounts = async (query, marketCoinNames, ownerAddress) => {
3685
3939
  marketCoinNames = marketCoinNames || [...SUPPORT_POOLS].map(
@@ -3702,11 +3956,11 @@ var getMarketCoinAmounts = async (query, marketCoinNames, ownerAddress) => {
3702
3956
  var getMarketCoinAmount = async (query, marketCoinName, ownerAddress) => {
3703
3957
  const owner = ownerAddress ?? query.suiKit.currentAddress();
3704
3958
  const marketCoinType = query.utils.parseMarketCoinType(marketCoinName);
3705
- const amount = await query.cache.queryGetCoinBalance({
3959
+ const coinBalance = await query.cache.queryGetCoinBalance({
3706
3960
  owner,
3707
3961
  coinType: marketCoinType
3708
3962
  });
3709
- return BigNumber3(amount).toNumber();
3963
+ return BigNumber3(coinBalance?.totalBalance ?? "0").toNumber();
3710
3964
  };
3711
3965
  var getFlashLoanFees = async (query, assetNames) => {
3712
3966
  const FEE_RATE = 1e4;
@@ -3727,14 +3981,10 @@ var getFlashLoanFees = async (query, assetNames) => {
3727
3981
  return FlashLoanFeeObjectMap[assetName];
3728
3982
  }
3729
3983
  }).filter((t) => !!t);
3730
- const flashloanFeeObjects = await query.cache.queryGetObjects(objIds, {
3731
- showContent: true
3732
- });
3984
+ const flashloanFeeObjects = await query.cache.queryGetObjects(objIds);
3733
3985
  if (missingAssets.length > 0) {
3734
3986
  const marketObjectId = query.address.get("core.market");
3735
- const marketObjectRes = await query.cache.queryGetObject(marketObjectId, {
3736
- showContent: true
3737
- });
3987
+ const marketObjectRes = await query.cache.queryGetObject(marketObjectId);
3738
3988
  if (marketObjectRes?.data?.content?.dataType !== "moveObject")
3739
3989
  throw new Error("Failed to get market object");
3740
3990
  const vault = marketObjectRes.data.content.fields.vault;
@@ -3748,9 +3998,7 @@ var getFlashLoanFees = async (query, assetNames) => {
3748
3998
  return !!assetTypeMap[assetType];
3749
3999
  }).map((field) => field.objectId) ?? [];
3750
4000
  flashloanFeeObjects.push(
3751
- ...await query.cache.queryGetObjects(dynamicFieldObjectIds, {
3752
- showContent: true
3753
- })
4001
+ ...await query.cache.queryGetObjects(dynamicFieldObjectIds)
3754
4002
  );
3755
4003
  }
3756
4004
  return flashloanFeeObjects.reduce(
@@ -3782,9 +4030,7 @@ var userRewardFieldsZod = zod4.object({
3782
4030
  }).transform((value) => BigNumber4(value.value).shiftedBy(-9).toNumber());
3783
4031
  var getLoyaltyProgramInformations = async (query, veScaKey) => {
3784
4032
  const rewardPool = query.address.get("loyaltyProgram.rewardPool");
3785
- const rewardPoolObject = await query.cache.queryGetObject(rewardPool, {
3786
- showContent: true
3787
- });
4033
+ const rewardPoolObject = await query.cache.queryGetObject(rewardPool);
3788
4034
  if (rewardPoolObject?.data?.content?.dataType !== "moveObject")
3789
4035
  return null;
3790
4036
  const rewardPoolFields = rewardPoolObject.data.content.fields;
@@ -3820,15 +4066,16 @@ var getLoyaltyProgramInformations = async (query, veScaKey) => {
3820
4066
 
3821
4067
  // src/queries/portfolioQuery.ts
3822
4068
  import BigNumber5 from "bignumber.js";
3823
- var getLendings = async (query, poolCoinNames = [...SUPPORT_POOLS], ownerAddress, indexer = false) => {
4069
+ import { normalizeStructTag as normalizeStructTag5, SUI_TYPE_ARG } from "@scallop-io/sui-kit";
4070
+ var getLendings = async (query, poolCoinNames = [...SUPPORT_POOLS], ownerAddress, marketPools, coinPrices, indexer = false) => {
3824
4071
  const marketCoinNames = poolCoinNames.map(
3825
4072
  (poolCoinName) => query.utils.parseMarketCoinName(poolCoinName)
3826
4073
  );
3827
4074
  const stakeMarketCoinNames = marketCoinNames.filter(
3828
4075
  (marketCoinName) => SUPPORT_SPOOLS.includes(marketCoinName)
3829
4076
  );
3830
- const coinPrices = await query.utils.getCoinPrices();
3831
- const marketPools = (await query.getMarketPools(poolCoinNames, {
4077
+ coinPrices = coinPrices ?? await query.utils.getCoinPrices();
4078
+ marketPools = marketPools ?? (await query.getMarketPools(poolCoinNames, {
3832
4079
  indexer,
3833
4080
  coinPrices
3834
4081
  })).pools;
@@ -3998,19 +4245,25 @@ var getLending = async (query, poolCoinName, ownerAddress, indexer = false, mark
3998
4245
  };
3999
4246
  return lending;
4000
4247
  };
4001
- var getObligationAccounts = async (query, ownerAddress, indexer = false) => {
4002
- const coinPrices = await query.utils.getCoinPrices();
4003
- const market = await query.getMarketPools(void 0, { coinPrices, indexer });
4248
+ var getObligationAccounts = async (query, ownerAddress, market, coinPrices, indexer = false) => {
4249
+ market = market ?? await query.getMarketPools(void 0, { indexer });
4250
+ coinPrices = coinPrices ?? await query.getAllCoinPrices({
4251
+ marketPools: market.pools
4252
+ });
4004
4253
  const [coinAmounts, obligations] = await Promise.all([
4005
4254
  query.getCoinAmounts(void 0, ownerAddress),
4006
4255
  query.getObligations(ownerAddress)
4007
4256
  ]);
4257
+ const obligationObjects = await queryMultipleObjects(
4258
+ query.cache,
4259
+ obligations.map((obligation) => obligation.id)
4260
+ );
4008
4261
  const obligationAccounts = {};
4009
4262
  await Promise.allSettled(
4010
- obligations.map(async (obligation) => {
4263
+ obligations.map(async (obligation, idx) => {
4011
4264
  obligationAccounts[obligation.keyId] = await getObligationAccount(
4012
4265
  query,
4013
- obligation.id,
4266
+ obligationObjects[idx] ?? obligation.id,
4014
4267
  ownerAddress,
4015
4268
  indexer,
4016
4269
  market,
@@ -4021,7 +4274,7 @@ var getObligationAccounts = async (query, ownerAddress, indexer = false) => {
4021
4274
  );
4022
4275
  return obligationAccounts;
4023
4276
  };
4024
- var getObligationAccount = async (query, obligationId, ownerAddress, indexer = false, market, coinPrices, coinAmounts) => {
4277
+ var getObligationAccount = async (query, obligation, ownerAddress, indexer = false, market, coinPrices, coinAmounts) => {
4025
4278
  const coinNames = Array.from(
4026
4279
  /* @__PURE__ */ new Set([...SUPPORT_POOLS, ...SUPPORT_COLLATERALS])
4027
4280
  );
@@ -4030,15 +4283,14 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
4030
4283
  ];
4031
4284
  market = market ?? await query.getMarketPools(void 0, { indexer });
4032
4285
  coinPrices = coinPrices ?? await query.getAllCoinPrices({ marketPools: market.pools });
4033
- coinAmounts = coinAmounts || await query.getCoinAmounts(coinNames, ownerAddress);
4286
+ coinAmounts = coinAmounts ?? await query.getCoinAmounts(coinNames, ownerAddress);
4034
4287
  const [obligationQuery, borrowIncentivePools, borrowIncentiveAccounts] = await Promise.all([
4035
- query.queryObligation(obligationId),
4288
+ query.queryObligation(obligation),
4036
4289
  query.getBorrowIncentivePools(void 0, {
4037
4290
  coinPrices,
4038
- indexer,
4039
4291
  marketPools: market.pools
4040
4292
  }),
4041
- query.getBorrowIncentiveAccounts(obligationId)
4293
+ query.getBorrowIncentiveAccounts(obligation)
4042
4294
  ]);
4043
4295
  const collaterals = {};
4044
4296
  const debts = {};
@@ -4236,7 +4488,7 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
4236
4488
  const requiredCollateralValue = totalBorrowedValueWithWeight.isGreaterThan(0) ? totalRequiredCollateralValue : BigNumber5(0);
4237
4489
  const unhealthyCollateralValue = totalBorrowedValueWithWeight.minus(requiredCollateralValue).isGreaterThan(0) ? totalBorrowedValueWithWeight.minus(requiredCollateralValue) : BigNumber5(0);
4238
4490
  const obligationAccount = {
4239
- obligationId,
4491
+ obligationId: typeof obligation === "string" ? obligation : obligation.objectId,
4240
4492
  // Deposited collateral value (collateral balance)
4241
4493
  totalDepositedValue: totalDepositedValue.toNumber(),
4242
4494
  // Borrowed debt value (liabilities balance)
@@ -4354,6 +4606,171 @@ var getTotalValueLocked = async (query, indexer = false) => {
4354
4606
  };
4355
4607
  return tvl;
4356
4608
  };
4609
+ var getUserPortfolio = async (query, walletAddress, indexer = false) => {
4610
+ const coinPrices = await query.utils.getCoinPrices();
4611
+ const market = await query.getMarketPools(void 0, { indexer, coinPrices });
4612
+ const [lendings, obligationAccounts, borrowIncentivePools, veScas] = await Promise.all([
4613
+ query.getLendings(void 0, walletAddress, {
4614
+ indexer,
4615
+ marketPools: market.pools,
4616
+ coinPrices
4617
+ }),
4618
+ query.getObligationAccounts(walletAddress, {
4619
+ indexer,
4620
+ market,
4621
+ coinPrices
4622
+ }),
4623
+ query.getBorrowIncentivePools(void 0, {
4624
+ marketPools: market.pools,
4625
+ coinPrices
4626
+ }),
4627
+ query.getVeScas({ walletAddress, excludeEmpty: true })
4628
+ ]);
4629
+ const parsedLendings = Object.values(lendings).filter((t) => t.availableWithdrawCoin > 0).map((lending) => ({
4630
+ suppliedCoin: lending.availableWithdrawCoin,
4631
+ suppliedValue: lending.suppliedValue,
4632
+ stakedCoin: lending.availableUnstakeCoin,
4633
+ coinName: lending.coinName,
4634
+ symbol: lending.symbol,
4635
+ coinType: lending.coinType,
4636
+ coinPrice: lending.coinPrice,
4637
+ coinDecimals: lending.coinDecimal,
4638
+ supplyApr: lending.supplyApr,
4639
+ supplyApy: lending.supplyApy,
4640
+ incentiveApr: isFinite(lending.rewardApr) ? lending.rewardApr : 0
4641
+ }));
4642
+ const parsedObligationAccounts = Object.values(obligationAccounts).filter(
4643
+ (t) => !!t && t.totalBorrowedValueWithWeight > 0
4644
+ ).map((obligationAccount) => {
4645
+ return {
4646
+ obligationId: obligationAccount.obligationId,
4647
+ totalDebtsInUsd: obligationAccount.totalBorrowedValueWithWeight,
4648
+ totalCollateralInUsd: obligationAccount.totalDepositedValue,
4649
+ riskLevel: obligationAccount.totalRiskLevel,
4650
+ availableCollateralInUsd: obligationAccount.totalAvailableCollateralValue,
4651
+ totalUnhealthyCollateralInUsd: obligationAccount.totalUnhealthyCollateralValue,
4652
+ borrowedPools: Object.values(obligationAccount.debts).filter((debt) => debt.borrowedCoin > 0).map((debt) => ({
4653
+ coinName: debt.coinName,
4654
+ symbol: debt.symbol,
4655
+ coinDecimals: debt.coinDecimal,
4656
+ coinType: debt.coinType,
4657
+ coinPrice: debt.coinPrice,
4658
+ borrowedCoin: debt.borrowedCoin,
4659
+ borrowedValueInUsd: debt.borrowedValueWithWeight,
4660
+ borrowApr: market.pools[debt.coinName]?.borrowApr,
4661
+ borrowApy: market.pools[debt.coinName]?.borrowApy,
4662
+ incentiveInfos: Object.values(
4663
+ borrowIncentivePools[debt.coinName]?.points ?? {}
4664
+ ).filter((t) => isFinite(t.rewardApr)).map((t) => ({
4665
+ coinName: t.coinName,
4666
+ symbol: t.symbol,
4667
+ coinType: t.coinType,
4668
+ incentiveApr: t.rewardApr
4669
+ }))
4670
+ }))
4671
+ };
4672
+ });
4673
+ const pendingLendingRewards = Object.values(lendings).reduce(
4674
+ (acc, reward) => {
4675
+ if (reward.availableClaimCoin === 0)
4676
+ return acc;
4677
+ if (!acc[reward.symbol]) {
4678
+ acc[reward.symbol] = {
4679
+ symbol: reward.symbol,
4680
+ coinType: normalizeStructTag5(SUI_TYPE_ARG),
4681
+ // @TODO: for now lending reward is all in SUI
4682
+ coinPrice: reward.coinPrice,
4683
+ pendingRewardInCoin: reward.availableClaimCoin
4684
+ };
4685
+ } else {
4686
+ acc[reward.symbol].pendingRewardInCoin += reward.availableClaimCoin;
4687
+ }
4688
+ return acc;
4689
+ },
4690
+ {}
4691
+ );
4692
+ const pendingBorrowIncentiveRewards = Object.values(obligationAccounts).filter((t) => !!t).reduce(
4693
+ (acc, curr) => {
4694
+ Object.values(curr.borrowIncentives).forEach((incentive) => {
4695
+ incentive.rewards.forEach((reward) => {
4696
+ if (reward.availableClaimCoin === 0)
4697
+ return acc;
4698
+ if (!acc[reward.coinName]) {
4699
+ acc[reward.coinName] = {
4700
+ symbol: reward.symbol,
4701
+ coinType: reward.coinType,
4702
+ coinPrice: reward.coinPrice,
4703
+ pendingRewardInCoin: reward.availableClaimCoin
4704
+ };
4705
+ } else {
4706
+ acc[reward.coinName].pendingRewardInCoin += reward.availableClaimCoin;
4707
+ }
4708
+ });
4709
+ });
4710
+ return acc;
4711
+ },
4712
+ {}
4713
+ );
4714
+ const parsedVeScas = veScas.map(
4715
+ ({ keyId, lockedScaCoin, currentVeScaBalance, unlockAt }) => ({
4716
+ veScaKey: keyId,
4717
+ coinPrice: coinPrices.sca ?? 0,
4718
+ lockedScaInCoin: lockedScaCoin,
4719
+ lockedScaInUsd: lockedScaCoin * (coinPrices.sca ?? 0),
4720
+ currentVeScaBalance,
4721
+ remainingLockPeriodInDays: unlockAt - Date.now() > 0 ? (unlockAt - Date.now()) / 864e5 : 0,
4722
+ unlockAt
4723
+ })
4724
+ );
4725
+ return {
4726
+ totalSupplyValue: parsedLendings.reduce((acc, curr) => {
4727
+ acc += curr.suppliedValue;
4728
+ return acc;
4729
+ }, 0),
4730
+ ...parsedObligationAccounts.reduce(
4731
+ (acc, curr) => {
4732
+ acc.totalDebtValue += curr.totalDebtsInUsd;
4733
+ acc.totalCollateralValue += curr.totalCollateralInUsd;
4734
+ return acc;
4735
+ },
4736
+ {
4737
+ totalDebtValue: 0,
4738
+ totalCollateralValue: 0
4739
+ }
4740
+ ),
4741
+ totalLockedScaValue: parsedVeScas.reduce((acc, curr) => {
4742
+ acc += curr.lockedScaInUsd;
4743
+ return acc;
4744
+ }, 0),
4745
+ lendings: parsedLendings,
4746
+ borrowings: parsedObligationAccounts,
4747
+ pendingRewards: {
4748
+ lendings: Object.entries(pendingLendingRewards).reduce(
4749
+ (acc, [key, value]) => {
4750
+ acc.push({
4751
+ ...value,
4752
+ coinName: key,
4753
+ pendingRewardInUsd: value.coinPrice * value.pendingRewardInCoin
4754
+ });
4755
+ return acc;
4756
+ },
4757
+ []
4758
+ ),
4759
+ borrowIncentives: Object.entries(pendingBorrowIncentiveRewards).reduce(
4760
+ (acc, [key, value]) => {
4761
+ acc.push({
4762
+ coinName: key,
4763
+ ...value,
4764
+ pendingRewardInUsd: value.coinPrice * value.pendingRewardInCoin
4765
+ });
4766
+ return acc;
4767
+ },
4768
+ []
4769
+ )
4770
+ },
4771
+ veScas: parsedVeScas
4772
+ };
4773
+ };
4357
4774
 
4358
4775
  // src/queries/priceQuery.ts
4359
4776
  import BigNumber6 from "bignumber.js";
@@ -4363,9 +4780,7 @@ var getPythPrice = async ({
4363
4780
  const pythFeedObjectId = address.get(
4364
4781
  `core.coins.${assetCoinName}.oracle.pyth.feedObject`
4365
4782
  );
4366
- priceFeedObject = priceFeedObject || (await address.cache.queryGetObject(pythFeedObjectId, {
4367
- showContent: true
4368
- }))?.data;
4783
+ priceFeedObject = priceFeedObject || (await address.cache.queryGetObject(pythFeedObjectId))?.data;
4369
4784
  if (priceFeedObject) {
4370
4785
  const priceFeedPoolObject = priceFeedObject;
4371
4786
  if (priceFeedPoolObject.content && "fields" in priceFeedPoolObject.content) {
@@ -4407,8 +4822,7 @@ var getPythPrices = async ({
4407
4822
  {}
4408
4823
  );
4409
4824
  const priceFeedObjects = await address.cache.queryGetObjects(
4410
- Object.keys(pythPriceFeedIds),
4411
- { showContent: true }
4825
+ Object.keys(pythPriceFeedIds)
4412
4826
  );
4413
4827
  const assetToPriceFeedMapping = priceFeedObjects.reduce(
4414
4828
  (prev, priceFeedObject) => {
@@ -4517,11 +4931,11 @@ var getSCoinAmount = async ({
4517
4931
  }, sCoinName, ownerAddress) => {
4518
4932
  const owner = ownerAddress || utils.suiKit.currentAddress();
4519
4933
  const sCoinType = utils.parseSCoinType(sCoinName);
4520
- const amount = await utils.cache.queryGetCoinBalance({
4934
+ const coinBalance = await utils.cache.queryGetCoinBalance({
4521
4935
  owner,
4522
4936
  coinType: sCoinType
4523
4937
  });
4524
- return BigNumber7(amount).toNumber();
4938
+ return BigNumber7(coinBalance?.totalBalance ?? "0").toNumber();
4525
4939
  };
4526
4940
  var isSupportStakeCoins = (value) => {
4527
4941
  return SUPPORT_SCOIN.includes(value);
@@ -4565,7 +4979,7 @@ var getSCoinSwapRate = async (query, fromSCoin, toSCoin, underlyingCoinPrice) =>
4565
4979
  };
4566
4980
 
4567
4981
  // src/queries/spoolQuery.ts
4568
- import { normalizeStructTag as normalizeStructTag5 } from "@mysten/sui/utils";
4982
+ import { normalizeStructTag as normalizeStructTag6 } from "@mysten/sui/utils";
4569
4983
  var queryRequiredSpoolObjects = async (query, stakePoolCoinNames) => {
4570
4984
  const tasks = stakePoolCoinNames.map((t, idx) => ({
4571
4985
  poolCoinName: stakePoolCoinNames[idx],
@@ -4587,21 +5001,29 @@ var queryRequiredSpoolObjects = async (query, stakePoolCoinNames) => {
4587
5001
  tasks.map((task) => task.sCoinTreasury).filter((t) => !!t)
4588
5002
  )
4589
5003
  ]);
4590
- const mapObjects = (tasks2, fetchedObjects) => {
5004
+ const mapObjects = (tasks2, fetchedObjects, keyValue) => {
4591
5005
  const resultMap = {};
4592
- let fetchedIndex = 0;
5006
+ const fetchedObjectMap = fetchedObjects.reduce(
5007
+ (acc, obj) => {
5008
+ acc[obj.objectId] = obj;
5009
+ return acc;
5010
+ },
5011
+ {}
5012
+ );
4593
5013
  for (const task of tasks2) {
4594
- const key = task[Object.keys(task)[1]];
4595
- if (key) {
4596
- resultMap[task.poolCoinName] = fetchedObjects[fetchedIndex];
4597
- fetchedIndex++;
5014
+ if (task[keyValue]) {
5015
+ resultMap[task.poolCoinName] = fetchedObjectMap[task[keyValue]];
4598
5016
  }
4599
5017
  }
4600
5018
  return resultMap;
4601
5019
  };
4602
- const spoolMap = mapObjects(tasks, spoolObjects);
4603
- const spoolRewardMap = mapObjects(tasks, spoolRewardObjects);
4604
- const sCoinTreasuryMap = mapObjects(tasks, sCoinTreasuryObjects);
5020
+ const spoolMap = mapObjects(tasks, spoolObjects, "spool");
5021
+ const spoolRewardMap = mapObjects(tasks, spoolRewardObjects, "spoolReward");
5022
+ const sCoinTreasuryMap = mapObjects(
5023
+ tasks,
5024
+ sCoinTreasuryObjects,
5025
+ "sCoinTreasury"
5026
+ );
4605
5027
  return stakePoolCoinNames.reduce(
4606
5028
  (acc, name) => {
4607
5029
  acc[name] = {
@@ -4817,14 +5239,14 @@ var getStakeAccounts = async ({
4817
5239
  svsui: stakeAccounts.svsui,
4818
5240
  susdc: stakeAccounts.susdc
4819
5241
  };
4820
- const normalizedType = normalizeStructTag5(type);
5242
+ const normalizedType = normalizeStructTag6(type);
4821
5243
  const stakeAccountArray = stakeMarketCoinTypeMap[reversedStakeMarketCoinTypes[normalizedType]];
4822
5244
  if (stakeAccountArray) {
4823
5245
  stakeAccountArray.push({
4824
5246
  id,
4825
5247
  type: normalizedType,
4826
5248
  stakePoolId,
4827
- stakeType: normalizeStructTag5(stakeType),
5249
+ stakeType: normalizeStructTag6(stakeType),
4828
5250
  staked,
4829
5251
  index,
4830
5252
  points,
@@ -4840,10 +5262,7 @@ var getStakePool = async ({
4840
5262
  }, marketCoinName) => {
4841
5263
  const poolId = utils.address.get(`spool.pools.${marketCoinName}.id`);
4842
5264
  let stakePool = void 0;
4843
- const stakePoolObjectResponse = await utils.cache.queryGetObject(poolId, {
4844
- showContent: true,
4845
- showType: true
4846
- });
5265
+ const stakePoolObjectResponse = await utils.cache.queryGetObject(poolId);
4847
5266
  if (stakePoolObjectResponse?.data) {
4848
5267
  const stakePoolObject = stakePoolObjectResponse.data;
4849
5268
  const id = stakePoolObject.objectId;
@@ -4862,13 +5281,13 @@ var getStakePool = async ({
4862
5281
  const lastUpdate = Number(fields.last_update);
4863
5282
  stakePool = {
4864
5283
  id,
4865
- type: normalizeStructTag5(type),
5284
+ type: normalizeStructTag6(type),
4866
5285
  maxPoint,
4867
5286
  distributedPoint,
4868
5287
  pointPerPeriod,
4869
5288
  period,
4870
5289
  maxStake,
4871
- stakeType: normalizeStructTag5(stakeType),
5290
+ stakeType: normalizeStructTag6(stakeType),
4872
5291
  totalStaked,
4873
5292
  index,
4874
5293
  createdAt,
@@ -4885,13 +5304,7 @@ var getStakeRewardPool = async ({
4885
5304
  `spool.pools.${marketCoinName}.rewardPoolId`
4886
5305
  );
4887
5306
  let stakeRewardPool = void 0;
4888
- const stakeRewardPoolObjectResponse = await utils.cache.queryGetObject(
4889
- poolId,
4890
- {
4891
- showContent: true,
4892
- showType: true
4893
- }
4894
- );
5307
+ const stakeRewardPoolObjectResponse = await utils.cache.queryGetObject(poolId);
4895
5308
  if (stakeRewardPoolObjectResponse?.data) {
4896
5309
  const stakeRewardPoolObject = stakeRewardPoolObjectResponse.data;
4897
5310
  const id = stakeRewardPoolObject.objectId;
@@ -4907,7 +5320,7 @@ var getStakeRewardPool = async ({
4907
5320
  const claimedRewards = Number(rewardPoolFields.claimed_rewards);
4908
5321
  stakeRewardPool = {
4909
5322
  id,
4910
- type: normalizeStructTag5(type),
5323
+ type: normalizeStructTag6(type),
4911
5324
  stakePoolId,
4912
5325
  ratioNumerator,
4913
5326
  ratioDenominator,
@@ -5028,7 +5441,7 @@ var getTotalVeScaTreasuryAmount = async (utils, veScaTreasury) => {
5028
5441
  const resolvedRefreshArgs = await Promise.all(
5029
5442
  refreshArgs.map(async (arg) => {
5030
5443
  if (typeof arg === "string") {
5031
- return (await utils.cache.queryGetObject(arg, { showContent: true }))?.data;
5444
+ return (await utils.cache.queryGetObject(arg))?.data;
5032
5445
  }
5033
5446
  return arg;
5034
5447
  })
@@ -5036,7 +5449,7 @@ var getTotalVeScaTreasuryAmount = async (utils, veScaTreasury) => {
5036
5449
  const resolvedVeScaAmountArgs = await Promise.all(
5037
5450
  veScaAmountArgs.map(async (arg) => {
5038
5451
  if (typeof arg === "string") {
5039
- return (await utils.cache.queryGetObject(arg, { showContent: true }))?.data;
5452
+ return (await utils.cache.queryGetObject(arg))?.data;
5040
5453
  }
5041
5454
  return arg;
5042
5455
  })
@@ -5068,9 +5481,7 @@ var getTotalVeScaTreasuryAmount = async (utils, veScaTreasury) => {
5068
5481
  };
5069
5482
  var getVeScaTreasuryInfo = async (utils) => {
5070
5483
  const veScaTreasuryId = utils.address.get("vesca.treasury");
5071
- const veScaTreasury = await utils.cache.queryGetObject(veScaTreasuryId, {
5072
- showContent: true
5073
- });
5484
+ const veScaTreasury = await utils.cache.queryGetObject(veScaTreasuryId);
5074
5485
  if (!veScaTreasury || veScaTreasury.data?.content?.dataType !== "moveObject")
5075
5486
  return null;
5076
5487
  const treasuryFields = veScaTreasury.data.content.fields;
@@ -5094,9 +5505,7 @@ var getVeScaTreasuryInfo = async (utils) => {
5094
5505
  var getAllAddresses = async (query) => {
5095
5506
  const results = {};
5096
5507
  const marketId = query.address.get("core.market");
5097
- const marketObject = (await query.cache.queryGetObject(marketId, {
5098
- showContent: true
5099
- }))?.data;
5508
+ const marketObject = (await query.cache.queryGetObject(marketId))?.data;
5100
5509
  if (!(marketObject && marketObject.content?.dataType === "moveObject"))
5101
5510
  throw new Error(`Failed to fetch marketObject`);
5102
5511
  const fields = marketObject.content.fields;
@@ -5126,7 +5535,8 @@ var getAllAddresses = async (query) => {
5126
5535
  value
5127
5536
  }
5128
5537
  }))?.data?.objectId;
5129
- } catch (_e) {
5538
+ } catch (e) {
5539
+ console.error(e.message);
5130
5540
  return void 0;
5131
5541
  }
5132
5542
  };
@@ -5161,10 +5571,14 @@ var getAllAddresses = async (query) => {
5161
5571
  // @ts-ignore
5162
5572
  `spool.pools.s${coinName}.rewardPoolId`
5163
5573
  );
5574
+ const sCoinType = query.address.get(`scoin.coins.s${coinName}.coinType`);
5164
5575
  const sCoinTreasury = query.address.get(
5165
5576
  // @ts-ignore
5166
5577
  `scoin.coins.s${coinName}.treasury`
5167
5578
  );
5579
+ const coinMetadataId = query.address.get(
5580
+ `core.coins.${coinName}.metaData`
5581
+ );
5168
5582
  results[coinName] = {
5169
5583
  lendingPoolAddress: addresses[0],
5170
5584
  collateralPoolAddress: addresses[1],
@@ -5177,25 +5591,17 @@ var getAllAddresses = async (query) => {
5177
5591
  isolatedAssetKey: addresses[8],
5178
5592
  spool,
5179
5593
  spoolReward: rewardPool,
5180
- sCoinTreasury
5594
+ sCoinTreasury,
5595
+ sCoinType,
5596
+ coinMetadataId,
5597
+ coinType: `0x${coinType}`
5181
5598
  };
5182
- await new Promise((resolve) => setTimeout(resolve, 200));
5599
+ await new Promise((resolve) => setTimeout(resolve, 500));
5183
5600
  })
5184
5601
  );
5185
5602
  return results;
5186
5603
  };
5187
5604
 
5188
- // src/models/suiKit.ts
5189
- import { SuiKit as SuiKit2 } from "@scallop-io/sui-kit";
5190
- var newSuiKit = (params) => {
5191
- return new SuiKit2({
5192
- ...params,
5193
- fullnodeUrls: Array.from(
5194
- /* @__PURE__ */ new Set([...params.fullnodeUrls ?? [], ...RPC_PROVIDERS])
5195
- )
5196
- });
5197
- };
5198
-
5199
5605
  // src/models/scallopUtils.ts
5200
5606
  var ScallopUtils = class {
5201
5607
  constructor(params, instance) {
@@ -5212,18 +5618,15 @@ var ScallopUtils = class {
5212
5618
  pythEndpoints: params.pythEndpoints ?? PYTH_ENDPOINTS["mainnet"],
5213
5619
  ...params
5214
5620
  };
5215
- this.suiKit = instance?.suiKit ?? instance?.address?.cache._suiKit ?? newSuiKit(params);
5216
- this.walletAddress = params.walletAddress ?? this.suiKit.currentAddress();
5621
+ this.walletAddress = params.walletAddress ?? instance?.suiKit?.currentAddress() ?? "";
5622
+ this.suiKit = instance?.suiKit ?? instance?.address?.cache.suiKit ?? newSuiKit(params);
5217
5623
  if (instance?.address) {
5218
5624
  this.address = instance.address;
5219
5625
  this.cache = this.address.cache;
5220
- this.suiKit = this.address.cache._suiKit;
5221
5626
  } else {
5222
- this.cache = new ScallopCache(
5223
- this.suiKit,
5224
- this.walletAddress,
5225
- DEFAULT_CACHE_OPTIONS
5226
- );
5627
+ this.cache = new ScallopCache(this.params, {
5628
+ suiKit: this.suiKit
5629
+ });
5227
5630
  this.address = instance?.address ?? new ScallopAddress(
5228
5631
  {
5229
5632
  id: params?.addressesId ?? ADDRESSES_ID,
@@ -5287,7 +5690,7 @@ var ScallopUtils = class {
5287
5690
  throw Error(`Coin ${coinName} is not supported`);
5288
5691
  }
5289
5692
  if (coinName === "sui")
5290
- return normalizeStructTag6(`${coinPackageId}::sui::SUI`);
5693
+ return normalizeStructTag7(`${coinPackageId}::sui::SUI`);
5291
5694
  const wormHolePackageIds = [
5292
5695
  this.address.get("core.coins.wusdc.id") ?? wormholeCoinIds.wusdc,
5293
5696
  this.address.get("core.coins.wusdt.id") ?? wormholeCoinIds.wusdt,
@@ -5391,7 +5794,7 @@ var ScallopUtils = class {
5391
5794
  return `${protocolObjectId}::reserve::MarketCoin<${coinType}>`;
5392
5795
  }
5393
5796
  parseCoinNameFromType(coinType) {
5394
- coinType = normalizeStructTag6(coinType);
5797
+ coinType = normalizeStructTag7(coinType);
5395
5798
  if (sCoinTypeToName[coinType]) {
5396
5799
  return sCoinTypeToName[coinType];
5397
5800
  }
@@ -5475,8 +5878,8 @@ var ScallopUtils = class {
5475
5878
  * @param coinType - The coin type, default is 0x2::SUI::SUI.
5476
5879
  * @return The selected transaction coin arguments.
5477
5880
  */
5478
- async selectCoins(amount, coinType = SUI_TYPE_ARG, ownerAddress) {
5479
- ownerAddress = ownerAddress ?? this.suiKit.currentAddress();
5881
+ async selectCoins(amount, coinType = SUI_TYPE_ARG2, ownerAddress) {
5882
+ ownerAddress = ownerAddress ?? this.walletAddress;
5480
5883
  const coins = await this.suiKit.suiInteractor.selectCoins(
5481
5884
  ownerAddress,
5482
5885
  amount,
@@ -5857,23 +6260,31 @@ var generateCoreNormalMethod = ({
5857
6260
  const referralWitnessType = `${referralPkgId}::scallop_referral_program::REFERRAL_WITNESS`;
5858
6261
  return {
5859
6262
  openObligation: () => {
5860
- const [obligation, obligationKey, obligationHotPotato] = txBlock.moveCall(
6263
+ const [obligation, obligationKey, obligationHotPotato] = builder.moveCall(
6264
+ txBlock,
5861
6265
  `${coreIds.protocolPkg}::open_obligation::open_obligation`,
5862
6266
  [coreIds.version]
5863
6267
  );
5864
6268
  return [obligation, obligationKey, obligationHotPotato];
5865
6269
  },
5866
- returnObligation: (obligation, obligationHotPotato) => txBlock.moveCall(
5867
- `${coreIds.protocolPkg}::open_obligation::return_obligation`,
5868
- [coreIds.version, obligation, obligationHotPotato]
5869
- ),
5870
- openObligationEntry: () => txBlock.moveCall(
5871
- `${coreIds.protocolPkg}::open_obligation::open_obligation_entry`,
5872
- [coreIds.version]
5873
- ),
6270
+ returnObligation: (obligation, obligationHotPotato) => {
6271
+ builder.moveCall(
6272
+ txBlock,
6273
+ `${coreIds.protocolPkg}::open_obligation::return_obligation`,
6274
+ [coreIds.version, obligation, obligationHotPotato]
6275
+ );
6276
+ },
6277
+ openObligationEntry: () => {
6278
+ builder.moveCall(
6279
+ txBlock,
6280
+ `${coreIds.protocolPkg}::open_obligation::open_obligation_entry`,
6281
+ [coreIds.version]
6282
+ );
6283
+ },
5874
6284
  addCollateral: (obligation, coin, collateralCoinName) => {
5875
6285
  const coinType = builder.utils.parseCoinType(collateralCoinName);
5876
- return txBlock.moveCall(
6286
+ builder.moveCall(
6287
+ txBlock,
5877
6288
  `${coreIds.protocolPkg}::deposit_collateral::deposit_collateral`,
5878
6289
  [coreIds.version, obligation, coreIds.market, coin],
5879
6290
  [coinType]
@@ -5881,7 +6292,8 @@ var generateCoreNormalMethod = ({
5881
6292
  },
5882
6293
  takeCollateral: (obligation, obligationKey, amount, collateralCoinName) => {
5883
6294
  const coinType = builder.utils.parseCoinType(collateralCoinName);
5884
- return txBlock.moveCall(
6295
+ return builder.moveCall(
6296
+ txBlock,
5885
6297
  `${coreIds.protocolPkg}::withdraw_collateral::withdraw_collateral`,
5886
6298
  [
5887
6299
  coreIds.version,
@@ -5898,7 +6310,8 @@ var generateCoreNormalMethod = ({
5898
6310
  },
5899
6311
  deposit: (coin, poolCoinName) => {
5900
6312
  const coinType = builder.utils.parseCoinType(poolCoinName);
5901
- return txBlock.moveCall(
6313
+ return builder.moveCall(
6314
+ txBlock,
5902
6315
  `${coreIds.protocolPkg}::mint::mint`,
5903
6316
  [coreIds.version, coreIds.market, coin, SUI_CLOCK_OBJECT_ID3],
5904
6317
  [coinType]
@@ -5906,7 +6319,8 @@ var generateCoreNormalMethod = ({
5906
6319
  },
5907
6320
  depositEntry: (coin, poolCoinName) => {
5908
6321
  const coinType = builder.utils.parseCoinType(poolCoinName);
5909
- return txBlock.moveCall(
6322
+ return builder.moveCall(
6323
+ txBlock,
5910
6324
  `${coreIds.protocolPkg}::mint::mint_entry`,
5911
6325
  [coreIds.version, coreIds.market, coin, SUI_CLOCK_OBJECT_ID3],
5912
6326
  [coinType]
@@ -5914,7 +6328,8 @@ var generateCoreNormalMethod = ({
5914
6328
  },
5915
6329
  withdraw: (marketCoin, poolCoinName) => {
5916
6330
  const coinType = builder.utils.parseCoinType(poolCoinName);
5917
- return txBlock.moveCall(
6331
+ return builder.moveCall(
6332
+ txBlock,
5918
6333
  `${coreIds.protocolPkg}::redeem::redeem`,
5919
6334
  [coreIds.version, coreIds.market, marketCoin, SUI_CLOCK_OBJECT_ID3],
5920
6335
  [coinType]
@@ -5922,7 +6337,8 @@ var generateCoreNormalMethod = ({
5922
6337
  },
5923
6338
  withdrawEntry: (marketCoin, poolCoinName) => {
5924
6339
  const coinType = builder.utils.parseCoinType(poolCoinName);
5925
- return txBlock.moveCall(
6340
+ return builder.moveCall(
6341
+ txBlock,
5926
6342
  `${coreIds.protocolPkg}::redeem::redeem_entry`,
5927
6343
  [coreIds.version, coreIds.market, marketCoin, SUI_CLOCK_OBJECT_ID3],
5928
6344
  [coinType]
@@ -5930,7 +6346,8 @@ var generateCoreNormalMethod = ({
5930
6346
  },
5931
6347
  borrow: (obligation, obligationKey, amount, poolCoinName) => {
5932
6348
  const coinType = builder.utils.parseCoinType(poolCoinName);
5933
- return txBlock.moveCall(
6349
+ return builder.moveCall(
6350
+ txBlock,
5934
6351
  `${coreIds.protocolPkg}::borrow::borrow`,
5935
6352
  [
5936
6353
  coreIds.version,
@@ -5947,7 +6364,8 @@ var generateCoreNormalMethod = ({
5947
6364
  },
5948
6365
  borrowWithReferral: (obligation, obligationKey, borrowReferral, amount, poolCoinName) => {
5949
6366
  const coinType = builder.utils.parseCoinType(poolCoinName);
5950
- return txBlock.moveCall(
6367
+ return builder.moveCall(
6368
+ txBlock,
5951
6369
  `${coreIds.protocolPkg}::borrow::borrow_with_referral`,
5952
6370
  [
5953
6371
  coreIds.version,
@@ -5956,7 +6374,7 @@ var generateCoreNormalMethod = ({
5956
6374
  coreIds.market,
5957
6375
  coreIds.coinDecimalsRegistry,
5958
6376
  borrowReferral,
5959
- txBlock.pure.u64(amount),
6377
+ typeof amount === "number" ? txBlock.pure.u64(amount) : amount,
5960
6378
  coreIds.xOracle,
5961
6379
  SUI_CLOCK_OBJECT_ID3
5962
6380
  ],
@@ -5965,7 +6383,8 @@ var generateCoreNormalMethod = ({
5965
6383
  },
5966
6384
  borrowEntry: (obligation, obligationKey, amount, poolCoinName) => {
5967
6385
  const coinType = builder.utils.parseCoinType(poolCoinName);
5968
- return txBlock.moveCall(
6386
+ return builder.moveCall(
6387
+ txBlock,
5969
6388
  `${coreIds.protocolPkg}::borrow::borrow_entry`,
5970
6389
  [
5971
6390
  coreIds.version,
@@ -5982,7 +6401,8 @@ var generateCoreNormalMethod = ({
5982
6401
  },
5983
6402
  repay: (obligation, coin, poolCoinName) => {
5984
6403
  const coinType = builder.utils.parseCoinType(poolCoinName);
5985
- return txBlock.moveCall(
6404
+ builder.moveCall(
6405
+ txBlock,
5986
6406
  `${coreIds.protocolPkg}::repay::repay`,
5987
6407
  [
5988
6408
  coreIds.version,
@@ -5996,7 +6416,8 @@ var generateCoreNormalMethod = ({
5996
6416
  },
5997
6417
  borrowFlashLoan: (amount, poolCoinName) => {
5998
6418
  const coinType = builder.utils.parseCoinType(poolCoinName);
5999
- return txBlock.moveCall(
6419
+ return builder.moveCall(
6420
+ txBlock,
6000
6421
  `${coreIds.protocolPkg}::flash_loan::borrow_flash_loan`,
6001
6422
  [coreIds.version, coreIds.market, amount],
6002
6423
  [coinType]
@@ -6004,7 +6425,8 @@ var generateCoreNormalMethod = ({
6004
6425
  },
6005
6426
  repayFlashLoan: (coin, loan, poolCoinName) => {
6006
6427
  const coinType = builder.utils.parseCoinType(poolCoinName);
6007
- return txBlock.moveCall(
6428
+ builder.moveCall(
6429
+ txBlock,
6008
6430
  `${coreIds.protocolPkg}::flash_loan::repay_flash_loan`,
6009
6431
  [coreIds.version, coreIds.market, coin, loan],
6010
6432
  [coinType]
@@ -6026,7 +6448,7 @@ var generateCoreQuickMethod = ({
6026
6448
  );
6027
6449
  if (collateralCoinName === "sui") {
6028
6450
  const [suiCoin] = txBlock.splitSUIFromGas([amount]);
6029
- txBlock.addCollateral(obligationArg, suiCoin, collateralCoinName);
6451
+ await txBlock.addCollateral(obligationArg, suiCoin, collateralCoinName);
6030
6452
  } else {
6031
6453
  const { leftCoin, takeCoin } = await builder.selectCoin(
6032
6454
  txBlock,
@@ -6034,7 +6456,11 @@ var generateCoreQuickMethod = ({
6034
6456
  amount,
6035
6457
  sender
6036
6458
  );
6037
- txBlock.addCollateral(obligationArg, takeCoin, collateralCoinName);
6459
+ await txBlock.addCollateral(
6460
+ obligationArg,
6461
+ takeCoin,
6462
+ collateralCoinName
6463
+ );
6038
6464
  txBlock.transferObjects([leftCoin], sender);
6039
6465
  }
6040
6466
  },
@@ -6049,7 +6475,7 @@ var generateCoreQuickMethod = ({
6049
6475
  obligationInfo.obligationId
6050
6476
  );
6051
6477
  await updateOracles(builder, txBlock, updateCoinNames);
6052
- return txBlock.takeCollateral(
6478
+ return await txBlock.takeCollateral(
6053
6479
  obligationInfo.obligationId,
6054
6480
  obligationInfo.obligationKey,
6055
6481
  amount,
@@ -6061,7 +6487,7 @@ var generateCoreQuickMethod = ({
6061
6487
  let marketCoinDeposit;
6062
6488
  if (poolCoinName === "sui") {
6063
6489
  const [suiCoin] = txBlock.splitSUIFromGas([amount]);
6064
- marketCoinDeposit = txBlock.deposit(suiCoin, poolCoinName);
6490
+ marketCoinDeposit = await txBlock.deposit(suiCoin, poolCoinName);
6065
6491
  } else {
6066
6492
  const { leftCoin, takeCoin } = await builder.selectCoin(
6067
6493
  txBlock,
@@ -6070,9 +6496,9 @@ var generateCoreQuickMethod = ({
6070
6496
  sender
6071
6497
  );
6072
6498
  txBlock.transferObjects([leftCoin], sender);
6073
- marketCoinDeposit = txBlock.deposit(takeCoin, poolCoinName);
6499
+ marketCoinDeposit = await txBlock.deposit(takeCoin, poolCoinName);
6074
6500
  }
6075
- return returnSCoin ? txBlock.mintSCoin(
6501
+ return returnSCoin ? await txBlock.mintSCoin(
6076
6502
  builder.utils.parseMarketCoinName(poolCoinName),
6077
6503
  marketCoinDeposit
6078
6504
  ) : marketCoinDeposit;
@@ -6090,7 +6516,7 @@ var generateCoreQuickMethod = ({
6090
6516
  totalAmount
6091
6517
  } = await builder.selectSCoin(txBlock, sCoinName, amount, sender);
6092
6518
  txBlock.transferObjects([leftCoin], sender);
6093
- const marketCoins2 = txBlock.burnSCoin(sCoinName, sCoins2);
6519
+ const marketCoins2 = await txBlock.burnSCoin(sCoinName, sCoins2);
6094
6520
  amount -= totalAmount;
6095
6521
  try {
6096
6522
  if (amount > 0) {
@@ -6114,7 +6540,7 @@ var generateCoreQuickMethod = ({
6114
6540
  sender
6115
6541
  );
6116
6542
  txBlock.transferObjects([leftCoin], sender);
6117
- return txBlock.withdraw(walletMarketCoins, poolCoinName);
6543
+ return await txBlock.withdraw(walletMarketCoins, poolCoinName);
6118
6544
  }
6119
6545
  },
6120
6546
  borrowQuick: async (amount, poolCoinName, obligationId, obligationKey) => {
@@ -6129,7 +6555,7 @@ var generateCoreQuickMethod = ({
6129
6555
  ) ?? [];
6130
6556
  const updateCoinNames = [...obligationCoinNames, poolCoinName];
6131
6557
  await updateOracles(builder, txBlock, updateCoinNames);
6132
- return txBlock.borrow(
6558
+ return await txBlock.borrow(
6133
6559
  obligationInfo.obligationId,
6134
6560
  obligationInfo.obligationKey,
6135
6561
  amount,
@@ -6148,7 +6574,7 @@ var generateCoreQuickMethod = ({
6148
6574
  ) ?? [];
6149
6575
  const updateCoinNames = [...obligationCoinNames, poolCoinName];
6150
6576
  await updateOracles(builder, txBlock, updateCoinNames);
6151
- return txBlock.borrowWithReferral(
6577
+ return await txBlock.borrowWithReferral(
6152
6578
  obligationInfo.obligationId,
6153
6579
  obligationInfo.obligationKey,
6154
6580
  borrowReferral,
@@ -6165,7 +6591,7 @@ var generateCoreQuickMethod = ({
6165
6591
  );
6166
6592
  if (poolCoinName === "sui") {
6167
6593
  const [suiCoin] = txBlock.splitSUIFromGas([amount]);
6168
- return txBlock.repay(
6594
+ return await txBlock.repay(
6169
6595
  obligationInfo.obligationId,
6170
6596
  suiCoin,
6171
6597
  poolCoinName
@@ -6178,7 +6604,7 @@ var generateCoreQuickMethod = ({
6178
6604
  sender
6179
6605
  );
6180
6606
  txBlock.transferObjects([leftCoin], sender);
6181
- return txBlock.repay(
6607
+ return await txBlock.repay(
6182
6608
  obligationInfo.obligationId,
6183
6609
  takeCoin,
6184
6610
  poolCoinName
@@ -6186,7 +6612,7 @@ var generateCoreQuickMethod = ({
6186
6612
  }
6187
6613
  },
6188
6614
  updateAssetPricesQuick: async (assetCoinNames) => {
6189
- return updateOracles(builder, txBlock, assetCoinNames);
6615
+ return await updateOracles(builder, txBlock, assetCoinNames);
6190
6616
  }
6191
6617
  };
6192
6618
  };
@@ -6273,7 +6699,8 @@ var generateSpoolNormalMethod = ({
6273
6699
  const stakePoolId = builder.address.get(
6274
6700
  `spool.pools.${stakeMarketCoinName}.id`
6275
6701
  );
6276
- return txBlock.moveCall(
6702
+ return builder.moveCall(
6703
+ txBlock,
6277
6704
  `${spoolIds.spoolPkg}::user::new_spool_account`,
6278
6705
  [stakePoolId, SUI_CLOCK_OBJECT_ID4],
6279
6706
  [marketCoinType]
@@ -6284,7 +6711,8 @@ var generateSpoolNormalMethod = ({
6284
6711
  const stakePoolId = builder.address.get(
6285
6712
  `spool.pools.${stakeMarketCoinName}.id`
6286
6713
  );
6287
- txBlock.moveCall(
6714
+ builder.moveCall(
6715
+ txBlock,
6288
6716
  `${spoolIds.spoolPkg}::user::stake`,
6289
6717
  [stakePoolId, stakeAccount, coin, SUI_CLOCK_OBJECT_ID4],
6290
6718
  [marketCoinType]
@@ -6295,7 +6723,8 @@ var generateSpoolNormalMethod = ({
6295
6723
  const stakePoolId = builder.address.get(
6296
6724
  `spool.pools.${stakeMarketCoinName}.id`
6297
6725
  );
6298
- return txBlock.moveCall(
6726
+ return builder.moveCall(
6727
+ txBlock,
6299
6728
  `${spoolIds.spoolPkg}::user::unstake`,
6300
6729
  [stakePoolId, stakeAccount, amount, SUI_CLOCK_OBJECT_ID4],
6301
6730
  [marketCoinType]
@@ -6311,7 +6740,8 @@ var generateSpoolNormalMethod = ({
6311
6740
  const marketCoinType = builder.utils.parseMarketCoinType(stakeMarketCoinName);
6312
6741
  const rewardCoinName = spoolRewardCoins[stakeMarketCoinName];
6313
6742
  const rewardCoinType = builder.utils.parseCoinType(rewardCoinName);
6314
- return txBlock.moveCall(
6743
+ return builder.moveCall(
6744
+ txBlock,
6315
6745
  `${spoolIds.spoolPkg}::user::redeem_rewards`,
6316
6746
  [stakePoolId, rewardPoolId, stakeAccount, SUI_CLOCK_OBJECT_ID4],
6317
6747
  [marketCoinType, rewardCoinType]
@@ -6376,13 +6806,16 @@ var generateSpoolQuickMethod = ({
6376
6806
  if (account.staked === 0)
6377
6807
  continue;
6378
6808
  const amountToUnstake = Math.min(amount, account.staked);
6379
- const marketCoin = txBlock.unstake(
6809
+ const marketCoin = await txBlock.unstake(
6380
6810
  account.id,
6381
6811
  amountToUnstake,
6382
6812
  stakeMarketCoinName
6383
6813
  );
6384
6814
  if (returnSCoin) {
6385
- const sCoin = txBlock.mintSCoin(stakeMarketCoinName, marketCoin);
6815
+ const sCoin = await txBlock.mintSCoin(
6816
+ stakeMarketCoinName,
6817
+ marketCoin
6818
+ );
6386
6819
  toTransfer.push(sCoin);
6387
6820
  } else {
6388
6821
  toTransfer.push(marketCoin);
@@ -6408,7 +6841,7 @@ var generateSpoolQuickMethod = ({
6408
6841
  );
6409
6842
  const rewardCoins = [];
6410
6843
  for (const accountId of stakeAccountIds) {
6411
- const rewardCoin = txBlock.claim(accountId, stakeMarketCoinName);
6844
+ const rewardCoin = await txBlock.claim(accountId, stakeMarketCoinName);
6412
6845
  rewardCoins.push(rewardCoin);
6413
6846
  }
6414
6847
  return rewardCoins;
@@ -6488,7 +6921,8 @@ var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
6488
6921
  };
6489
6922
  return {
6490
6923
  stakeObligation: (obligationId, obligationKey) => {
6491
- txBlock.moveCall(
6924
+ builder.moveCall(
6925
+ txBlock,
6492
6926
  `${borrowIncentiveIds.borrowIncentivePkg}::user::stake`,
6493
6927
  [
6494
6928
  borrowIncentiveIds.config,
@@ -6502,7 +6936,8 @@ var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
6502
6936
  );
6503
6937
  },
6504
6938
  stakeObligationWithVesca: (obligationId, obligationKey, veScaKey) => {
6505
- txBlock.moveCall(
6939
+ builder.moveCall(
6940
+ txBlock,
6506
6941
  `${borrowIncentiveIds.borrowIncentivePkg}::user::stake_with_ve_sca`,
6507
6942
  [
6508
6943
  borrowIncentiveIds.config,
@@ -6521,7 +6956,8 @@ var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
6521
6956
  );
6522
6957
  },
6523
6958
  unstakeObligation: (obligationId, obligationKey) => {
6524
- txBlock.moveCall(
6959
+ builder.moveCall(
6960
+ txBlock,
6525
6961
  `${borrowIncentiveIds.borrowIncentivePkg}::user::unstake`,
6526
6962
  [
6527
6963
  borrowIncentiveIds.config,
@@ -6535,7 +6971,8 @@ var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
6535
6971
  },
6536
6972
  claimBorrowIncentive: (obligationId, obligationKey, rewardCoinName) => {
6537
6973
  const rewardType = builder.utils.parseCoinType(rewardCoinName);
6538
- return txBlock.moveCall(
6974
+ return builder.moveCall(
6975
+ txBlock,
6539
6976
  `${borrowIncentiveIds.borrowIncentivePkg}::user::redeem_rewards`,
6540
6977
  [
6541
6978
  borrowIncentiveIds.config,
@@ -6549,7 +6986,8 @@ var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
6549
6986
  );
6550
6987
  },
6551
6988
  deactivateBoost: (obligation, veScaKey) => {
6552
- return txBlock.moveCall(
6989
+ builder.moveCall(
6990
+ txBlock,
6553
6991
  `${borrowIncentiveIds.borrowIncentivePkg}::user::deactivate_boost`,
6554
6992
  [
6555
6993
  borrowIncentiveIds.config,
@@ -6703,7 +7141,8 @@ var generateNormalVeScaMethod = ({
6703
7141
  };
6704
7142
  return {
6705
7143
  lockSca: (scaCoin, unlockAtInSecondTimestamp) => {
6706
- return txBlock.moveCall(
7144
+ return builder.moveCall(
7145
+ txBlock,
6707
7146
  `${veScaIds.pkgId}::ve_sca::mint_ve_sca_key`,
6708
7147
  [
6709
7148
  veScaIds.config,
@@ -6717,7 +7156,8 @@ var generateNormalVeScaMethod = ({
6717
7156
  );
6718
7157
  },
6719
7158
  extendLockPeriod: (veScaKey, newUnlockAtInSecondTimestamp) => {
6720
- txBlock.moveCall(
7159
+ builder.moveCall(
7160
+ txBlock,
6721
7161
  `${veScaIds.pkgId}::ve_sca::extend_lock_period`,
6722
7162
  [
6723
7163
  veScaIds.config,
@@ -6731,7 +7171,8 @@ var generateNormalVeScaMethod = ({
6731
7171
  );
6732
7172
  },
6733
7173
  extendLockAmount: (veScaKey, scaCoin) => {
6734
- txBlock.moveCall(
7174
+ builder.moveCall(
7175
+ txBlock,
6735
7176
  `${veScaIds.pkgId}::ve_sca::lock_more_sca`,
6736
7177
  [
6737
7178
  veScaIds.config,
@@ -6745,7 +7186,8 @@ var generateNormalVeScaMethod = ({
6745
7186
  );
6746
7187
  },
6747
7188
  renewExpiredVeSca: (veScaKey, scaCoin, newUnlockAtInSecondTimestamp) => {
6748
- txBlock.moveCall(
7189
+ builder.moveCall(
7190
+ txBlock,
6749
7191
  `${veScaIds.pkgId}::ve_sca::renew_expired_ve_sca`,
6750
7192
  [
6751
7193
  veScaIds.config,
@@ -6760,7 +7202,8 @@ var generateNormalVeScaMethod = ({
6760
7202
  );
6761
7203
  },
6762
7204
  redeemSca: (veScaKey) => {
6763
- return txBlock.moveCall(
7205
+ return builder.moveCall(
7206
+ txBlock,
6764
7207
  `${veScaIds.pkgId}::ve_sca::redeem`,
6765
7208
  [
6766
7209
  veScaIds.config,
@@ -6773,7 +7216,8 @@ var generateNormalVeScaMethod = ({
6773
7216
  );
6774
7217
  },
6775
7218
  mintEmptyVeSca: () => {
6776
- return txBlock.moveCall(
7219
+ return builder.moveCall(
7220
+ txBlock,
6777
7221
  `${veScaIds.pkgId}::ve_sca::mint_ve_sca_placeholder_key`,
6778
7222
  [veScaIds.config, veScaIds.table],
6779
7223
  []
@@ -6911,7 +7355,7 @@ var generateQuickVeScaMethod = ({
6911
7355
  const veSca = await requireVeSca(builder, txBlock, veScaKey);
6912
7356
  checkVesca(veSca?.unlockAt);
6913
7357
  if (veSca) {
6914
- const sca = txBlock.redeemSca(veSca.keyId);
7358
+ const sca = await txBlock.redeemSca(veSca.keyId);
6915
7359
  if (transferSca) {
6916
7360
  txBlock.transferObjects([sca], sender);
6917
7361
  return;
@@ -6972,7 +7416,8 @@ var generateReferralNormalMethod = ({
6972
7416
  const veScaTable = builder.address.get("vesca.table");
6973
7417
  return {
6974
7418
  bindToReferral: (veScaKeyId) => {
6975
- return txBlock.moveCall(
7419
+ builder.moveCall(
7420
+ txBlock,
6976
7421
  `${referralIds.referralPgkId}::referral_bindings::bind_ve_sca_referrer`,
6977
7422
  [
6978
7423
  referralIds.referralBindings,
@@ -6985,7 +7430,8 @@ var generateReferralNormalMethod = ({
6985
7430
  },
6986
7431
  claimReferralTicket: (poolCoinName) => {
6987
7432
  const coinType = builder.utils.parseCoinType(poolCoinName);
6988
- return txBlock.moveCall(
7433
+ return builder.moveCall(
7434
+ txBlock,
6989
7435
  `${referralIds.referralPgkId}::scallop_referral_program::claim_ve_sca_referral_ticket`,
6990
7436
  [
6991
7437
  referralIds.version,
@@ -7000,7 +7446,8 @@ var generateReferralNormalMethod = ({
7000
7446
  },
7001
7447
  burnReferralTicket: (ticket, poolCoinName) => {
7002
7448
  const coinType = builder.utils.parseCoinType(poolCoinName);
7003
- return txBlock.moveCall(
7449
+ builder.moveCall(
7450
+ txBlock,
7004
7451
  `${referralIds.referralPgkId}::scallop_referral_program::burn_ve_sca_referral_ticket`,
7005
7452
  [
7006
7453
  referralIds.version,
@@ -7013,7 +7460,8 @@ var generateReferralNormalMethod = ({
7013
7460
  },
7014
7461
  claimReferralRevenue: (veScaKey, poolCoinName) => {
7015
7462
  const coinType = builder.utils.parseCoinType(poolCoinName);
7016
- return txBlock.moveCall(
7463
+ return builder.moveCall(
7464
+ txBlock,
7017
7465
  `${referralIds.referralPgkId}::referral_revenue_pool::claim_revenue_with_ve_sca_key`,
7018
7466
  [
7019
7467
  referralIds.version,
@@ -7036,10 +7484,16 @@ var generateReferralQuickMethod = ({
7036
7484
  const objToTransfer = [];
7037
7485
  for (const coinName of coinNames) {
7038
7486
  if (coinName === "sui") {
7039
- const rewardCoin = txBlock.claimReferralRevenue(veScaKey, coinName);
7487
+ const rewardCoin = await txBlock.claimReferralRevenue(
7488
+ veScaKey,
7489
+ coinName
7490
+ );
7040
7491
  objToTransfer.push(rewardCoin);
7041
7492
  } else {
7042
- const rewardCoin = txBlock.claimReferralRevenue(veScaKey, coinName);
7493
+ const rewardCoin = await txBlock.claimReferralRevenue(
7494
+ veScaKey,
7495
+ coinName
7496
+ );
7043
7497
  try {
7044
7498
  const coins = await builder.suiKit.suiInteractor.selectCoins(
7045
7499
  sender,
@@ -7100,7 +7554,8 @@ var generateLoyaltyProgramNormalMethod = ({ builder, txBlock }) => {
7100
7554
  };
7101
7555
  return {
7102
7556
  claimLoyaltyRevenue: (veScaKey) => {
7103
- return txBlock.moveCall(
7557
+ return builder.moveCall(
7558
+ txBlock,
7104
7559
  `${loyaltyProgramIds.loyaltyProgramPkgId}::reward_pool::redeem_reward`,
7105
7560
  [loyaltyProgramIds.rewardPool, veScaKey]
7106
7561
  );
@@ -7117,7 +7572,7 @@ var generateLoyaltyProgramQuickMethod = ({
7117
7572
  const sender = requireSender(txBlock);
7118
7573
  if (!veScaKey)
7119
7574
  throw new Error(`No veScaKey found for user ${sender}`);
7120
- const rewardCoin = txBlock.claimLoyaltyRevenue(veScaKey);
7575
+ const rewardCoin = await txBlock.claimLoyaltyRevenue(veScaKey);
7121
7576
  await builder.utils.mergeSimilarCoins(
7122
7577
  txBlock,
7123
7578
  rewardCoin,
@@ -7167,7 +7622,8 @@ var generateSCoinNormalMethod = ({
7167
7622
  };
7168
7623
  return {
7169
7624
  mintSCoin: (marketCoinName, marketCoin) => {
7170
- return txBlock.moveCall(
7625
+ return builder.moveCall(
7626
+ txBlock,
7171
7627
  `${sCoinPkgIds.pkgId}::s_coin_converter::mint_s_coin`,
7172
7628
  [builder.utils.getSCoinTreasury(marketCoinName), marketCoin],
7173
7629
  [
@@ -7177,7 +7633,8 @@ var generateSCoinNormalMethod = ({
7177
7633
  );
7178
7634
  },
7179
7635
  burnSCoin: (sCoinName, sCoin) => {
7180
- return txBlock.moveCall(
7636
+ return builder.moveCall(
7637
+ txBlock,
7181
7638
  `${sCoinPkgIds.pkgId}::s_coin_converter::burn_s_coin`,
7182
7639
  [builder.utils.getSCoinTreasury(sCoinName), sCoin],
7183
7640
  [
@@ -7202,7 +7659,7 @@ var generateSCoinQuickMethod = ({
7202
7659
  sender
7203
7660
  );
7204
7661
  txBlock.transferObjects([leftCoin], sender);
7205
- return txBlock.mintSCoin(marketCoinName, takeCoin);
7662
+ return await txBlock.mintSCoin(marketCoinName, takeCoin);
7206
7663
  },
7207
7664
  burnSCoinQuick: async (sCoinName, amount) => {
7208
7665
  const sender = requireSender(txBlock);
@@ -7213,7 +7670,7 @@ var generateSCoinQuickMethod = ({
7213
7670
  sender
7214
7671
  );
7215
7672
  txBlock.transferObjects([leftCoin], sender);
7216
- return txBlock.burnSCoin(sCoinName, takeCoin);
7673
+ return await txBlock.burnSCoin(sCoinName, takeCoin);
7217
7674
  }
7218
7675
  };
7219
7676
  };
@@ -7279,11 +7736,10 @@ var newScallopTxBlock = (builder, initTxBlock) => {
7279
7736
 
7280
7737
  // src/models/scallopIndexer.ts
7281
7738
  import axios2 from "axios";
7282
- import { SuiKit as SuiKit3 } from "@scallop-io/sui-kit";
7283
7739
  var ScallopIndexer = class {
7284
7740
  constructor(params, instance) {
7285
7741
  this.params = params;
7286
- this.cache = instance?.cache ?? new ScallopCache(new SuiKit3({}), void 0, DEFAULT_CACHE_OPTIONS);
7742
+ this.cache = instance?.cache ?? new ScallopCache(this.params);
7287
7743
  this._requestClient = axios2.create({
7288
7744
  baseURL: SDK_API_BASE_URL,
7289
7745
  headers: {
@@ -7468,11 +7924,9 @@ var ScallopQuery = class {
7468
7924
  this.address = instance.utils.address;
7469
7925
  this.cache = this.address.cache;
7470
7926
  } else {
7471
- this.cache = new ScallopCache(
7472
- this.suiKit,
7473
- this.walletAddress,
7474
- DEFAULT_CACHE_OPTIONS
7475
- );
7927
+ this.cache = new ScallopCache(this.params, {
7928
+ suiKit: this.suiKit
7929
+ });
7476
7930
  this.address = new ScallopAddress(
7477
7931
  {
7478
7932
  id: params?.addressesId ?? ADDRESSES_ID,
@@ -7827,7 +8281,14 @@ var ScallopQuery = class {
7827
8281
  * @return All lending and spool infomation.
7828
8282
  */
7829
8283
  async getLendings(poolCoinNames, ownerAddress = this.walletAddress, args) {
7830
- return await getLendings(this, poolCoinNames, ownerAddress, args?.indexer);
8284
+ return await getLendings(
8285
+ this,
8286
+ poolCoinNames,
8287
+ ownerAddress,
8288
+ args?.marketPools,
8289
+ args?.coinPrices,
8290
+ args?.indexer
8291
+ );
7831
8292
  }
7832
8293
  /**
7833
8294
  * Get user lending and spool information for specific pool.
@@ -7851,7 +8312,13 @@ var ScallopQuery = class {
7851
8312
  * @return All obligation accounts information.
7852
8313
  */
7853
8314
  async getObligationAccounts(ownerAddress = this.walletAddress, args) {
7854
- return await getObligationAccounts(this, ownerAddress, args?.indexer);
8315
+ return await getObligationAccounts(
8316
+ this,
8317
+ ownerAddress,
8318
+ args?.market,
8319
+ args?.coinPrices,
8320
+ args?.indexer
8321
+ );
7855
8322
  }
7856
8323
  /**
7857
8324
  * Get obligation account information for specific id.
@@ -7865,11 +8332,9 @@ var ScallopQuery = class {
7865
8332
  * @return Borrowing and collateral information.
7866
8333
  */
7867
8334
  async getObligationAccount(obligationId, ownerAddress = this.walletAddress, args) {
7868
- return await getObligationAccount(
7869
- this,
7870
- obligationId,
7871
- ownerAddress,
7872
- args?.indexer
8335
+ const results = await this.getObligationAccounts(ownerAddress, args);
8336
+ return Object.values(results).find(
8337
+ (obligation) => obligation?.obligationId === obligationId
7873
8338
  );
7874
8339
  }
7875
8340
  /**
@@ -8028,12 +8493,22 @@ var ScallopQuery = class {
8028
8493
  return getAllCoinPrices(this, args?.marketPools, args?.coinPrices);
8029
8494
  }
8030
8495
  /**
8031
- * Query all address (lending pool, collateral pool, borrow dynamics, interest models) of all pool
8496
+ * Query all address (lending pool, collateral pool, borrow dynamics, interest models, etc.) of all pool
8032
8497
  * @returns
8033
8498
  */
8034
8499
  async getPoolAddresses() {
8035
8500
  return getAllAddresses(this);
8036
8501
  }
8502
+ /**
8503
+ * Get user portfolio
8504
+ */
8505
+ async getUserPortfolio(args) {
8506
+ return getUserPortfolio(
8507
+ this,
8508
+ args?.walletAddress ?? this.walletAddress,
8509
+ args?.indexer ?? false
8510
+ );
8511
+ }
8037
8512
  };
8038
8513
 
8039
8514
  // src/models/scallopBuilder.ts
@@ -8050,11 +8525,9 @@ var ScallopBuilder = class {
8050
8525
  this.address = this.utils.address;
8051
8526
  this.cache = this.address.cache;
8052
8527
  } else {
8053
- this.cache = new ScallopCache(
8054
- this.suiKit,
8055
- this.walletAddress,
8056
- DEFAULT_CACHE_OPTIONS
8057
- );
8528
+ this.cache = new ScallopCache(this.params, {
8529
+ suiKit: this.suiKit
8530
+ });
8058
8531
  this.address = new ScallopAddress(
8059
8532
  {
8060
8533
  id: params?.addressesId ?? ADDRESSES_ID,
@@ -8092,7 +8565,6 @@ var ScallopBuilder = class {
8092
8565
  await this.address.read();
8093
8566
  }
8094
8567
  await this.query.init(force, this.address);
8095
- await this.utils.init(force, this.address);
8096
8568
  }
8097
8569
  /**
8098
8570
  * Create a scallop txBlock instance that enhances transaction block.
@@ -8181,6 +8653,9 @@ var ScallopBuilder = class {
8181
8653
  txBlock
8182
8654
  );
8183
8655
  }
8656
+ moveCall(txb, target, args, typeArgs) {
8657
+ return txb.moveCall(target, args, typeArgs);
8658
+ }
8184
8659
  };
8185
8660
 
8186
8661
  // src/models/scallopClient.ts
@@ -8198,11 +8673,9 @@ var ScallopClient = class {
8198
8673
  this.address = this.utils.address;
8199
8674
  this.cache = this.address.cache;
8200
8675
  } else {
8201
- this.cache = new ScallopCache(
8202
- this.suiKit,
8203
- this.walletAddress,
8204
- DEFAULT_CACHE_OPTIONS
8205
- );
8676
+ this.cache = new ScallopCache(this.params, {
8677
+ suiKit: this.suiKit
8678
+ });
8206
8679
  this.address = new ScallopAddress(
8207
8680
  {
8208
8681
  id: params?.addressesId ?? ADDRESSES_ID,
@@ -8698,6 +9171,8 @@ var ScallopClient = class {
8698
9171
  txBlock.setSender(sender);
8699
9172
  const rewardCoinsCollection = {};
8700
9173
  const obligationAccount = await this.query.getObligationAccount(obligationId);
9174
+ if (!obligationAccount)
9175
+ throw new Error("Obligation not found");
8701
9176
  const rewardCoinNames = Object.values(obligationAccount.borrowIncentives).flatMap(
8702
9177
  ({ rewards }) => rewards.filter(({ availableClaimAmount }) => availableClaimAmount > 0)
8703
9178
  ).flatMap(({ coinName }) => coinName);
@@ -8874,15 +9349,18 @@ var ScallopClient = class {
8874
9349
 
8875
9350
  // src/models/scallop.ts
8876
9351
  var Scallop = class {
8877
- constructor(params, cacheOptions, tokenBucket, queryClient) {
9352
+ constructor(params, cacheOptions, queryClient) {
8878
9353
  this.params = params;
8879
9354
  this.suiKit = newSuiKit(params);
8880
9355
  this.cache = new ScallopCache(
8881
- this.suiKit,
8882
- params.walletAddress,
8883
- cacheOptions ?? DEFAULT_CACHE_OPTIONS,
8884
- tokenBucket ?? new TokenBucket(DEFAULT_TOKENS_PER_INTERVAL, DEFAULT_INTERVAL_IN_MS),
8885
- queryClient
9356
+ {
9357
+ ...this.params,
9358
+ cacheOptions
9359
+ },
9360
+ {
9361
+ suiKit: this.suiKit,
9362
+ queryClient
9363
+ }
8886
9364
  );
8887
9365
  this.address = new ScallopAddress(
8888
9366
  {
@@ -8980,7 +9458,8 @@ var Scallop = class {
8980
9458
  ...params
8981
9459
  },
8982
9460
  {
8983
- address: this.address
9461
+ address: this.address,
9462
+ suiKit: this.suiKit
8984
9463
  }
8985
9464
  );
8986
9465
  return scallopUtils;
@@ -8992,8 +9471,6 @@ export {
8992
9471
  BORROW_FEE_PROTOCOL_ID,
8993
9472
  COIN_GECKGO_IDS,
8994
9473
  DEFAULT_CACHE_OPTIONS,
8995
- DEFAULT_INTERVAL_IN_MS,
8996
- DEFAULT_TOKENS_PER_INTERVAL,
8997
9474
  FlashLoanFeeObjectMap,
8998
9475
  IS_VE_SCA_TEST,
8999
9476
  MAX_LOCK_DURATION,
@@ -9028,11 +9505,9 @@ export {
9028
9505
  ScallopQuery,
9029
9506
  ScallopUtils,
9030
9507
  TEST_ADDRESSES,
9031
- TokenBucket,
9032
9508
  UNLOCK_ROUND_DURATION,
9033
9509
  USE_TEST_ADDRESS,
9034
9510
  assetCoins,
9035
- callWithRateLimit,
9036
9511
  coinDecimals,
9037
9512
  coinIds,
9038
9513
  marketCoins,