@scallop-io/sui-scallop-sdk 1.3.3-alpha.2 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants/index.d.ts +0 -1
- package/dist/constants/queryKeys.d.ts +1 -2
- package/dist/index.js +1011 -1022
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1011 -1021
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopIndexer.d.ts +6 -0
- package/dist/models/scallopPrice.d.ts +0 -0
- package/dist/models/scallopQuery.d.ts +6 -0
- package/dist/queries/vescaQuery.d.ts +2 -2
- package/dist/types/query/core.d.ts +0 -1
- package/dist/types/query/portfolio.d.ts +1 -1
- package/dist/types/query/spool.d.ts +1 -0
- package/dist/types/query/vesca.d.ts +1 -1
- package/package.json +1 -1
- package/src/builders/borrowIncentiveBuilder.ts +3 -2
- package/src/constants/enum.ts +4 -11
- package/src/constants/index.ts +0 -1
- package/src/constants/queryKeys.ts +2 -2
- package/src/constants/testAddress.ts +35 -76
- package/src/models/scallopBuilder.ts +3 -2
- package/src/models/scallopClient.ts +3 -3
- package/src/models/scallopIndexer.ts +9 -0
- package/src/models/scallopPrice.ts +0 -0
- package/src/models/scallopQuery.ts +12 -4
- package/src/models/scallopUtils.ts +28 -39
- package/src/queries/coreQuery.ts +225 -230
- package/src/queries/isolatedAsset.ts +4 -4
- package/src/queries/portfolioQuery.ts +10 -6
- package/src/queries/referralQuery.ts +1 -0
- package/src/queries/spoolQuery.ts +2 -1
- package/src/queries/vescaQuery.ts +4 -6
- package/src/types/query/core.ts +0 -1
- package/src/types/query/portfolio.ts +1 -0
- package/src/types/query/spool.ts +1 -0
- package/src/types/query/vesca.ts +1 -1
package/dist/index.mjs
CHANGED
|
@@ -254,20 +254,11 @@ var voloCoinIds = {
|
|
|
254
254
|
var sCoinIds = {
|
|
255
255
|
susdc: "0x854950aa624b1df59fe64e630b2ba7c550642e9342267a33061d59fb31582da5::scallop_usdc::SCALLOP_USDC",
|
|
256
256
|
ssbeth: "0xb14f82d8506d139eacef109688d1b71e7236bcce9b2c0ad526abcd6aa5be7de0::scallop_sb_eth::SCALLOP_SB_ETH",
|
|
257
|
-
|
|
258
|
-
ssui: "0xf569919046f19a0c40b519ecfbb6ca0319698cd5908716c29b62ef56541f298b::scallop_sui::SCALLOP_SUI",
|
|
259
|
-
// ssui: '0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI',
|
|
257
|
+
ssui: "0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI",
|
|
260
258
|
scetus: "0xea346ce428f91ab007210443efcea5f5cdbbb3aae7e9affc0ca93f9203c31f0c::scallop_cetus::SCALLOP_CETUS",
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
// TODO: Change this to the correct value on production release
|
|
265
|
-
swusdc: "0xf5447c4305a486d8c8557559887c2c39449ddb5e748f15d33946d02a1663c158::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC",
|
|
266
|
-
// '0xad4d71551d31092230db1fd482008ea42867dbf27b286e9c70a79d2a6191d58d::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC',
|
|
267
|
-
swusdt: (
|
|
268
|
-
// '0xe6e5a012ec20a49a3d1d57bd2b67140b96cd4d3400b9d79e541f7bdbab661f95::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT',
|
|
269
|
-
"0xac781d9f73058ff5e69f9bf8dde32f2e8c71c66d7fe8497fc83b2d9182254b22::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT"
|
|
270
|
-
),
|
|
259
|
+
ssca: "0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA",
|
|
260
|
+
swusdc: "0xad4d71551d31092230db1fd482008ea42867dbf27b286e9c70a79d2a6191d58d::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC",
|
|
261
|
+
swusdt: "0xe6e5a012ec20a49a3d1d57bd2b67140b96cd4d3400b9d79e541f7bdbab661f95::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT",
|
|
271
262
|
sweth: "0x67540ceb850d418679e69f1fb6b2093d6df78a2a699ffc733f7646096d552e9b::scallop_wormhole_eth::SCALLOP_WORMHOLE_ETH",
|
|
272
263
|
safsui: "0x00671b1fa2a124f5be8bdae8b91ee711462c5d9e31bda232e70fd9607b523c88::scallop_af_sui::SCALLOP_AF_SUI",
|
|
273
264
|
shasui: "0x9a2376943f7d22f88087c259c5889925f332ca4347e669dc37d54c2bf651af3c::scallop_ha_sui::SCALLOP_HA_SUI",
|
|
@@ -368,10 +359,10 @@ var queryKeys = {
|
|
|
368
359
|
]
|
|
369
360
|
},
|
|
370
361
|
oracle: {
|
|
371
|
-
getPythLatestPriceFeed: (pythPriceId
|
|
362
|
+
getPythLatestPriceFeed: (pythPriceId) => [
|
|
372
363
|
"oracle",
|
|
373
364
|
"getPythPriceId",
|
|
374
|
-
{ pythPriceId
|
|
365
|
+
{ pythPriceId }
|
|
375
366
|
]
|
|
376
367
|
}
|
|
377
368
|
};
|
|
@@ -383,430 +374,6 @@ var MAX_LOCK_DURATION = MAX_LOCK_ROUNDS * UNLOCK_ROUND_DURATION;
|
|
|
383
374
|
var MIN_INITIAL_LOCK_AMOUNT = 1e10;
|
|
384
375
|
var MIN_TOP_UP_AMOUNT = 1e9;
|
|
385
376
|
|
|
386
|
-
// src/constants/testAddress.ts
|
|
387
|
-
var TEST_ADDRESSES = {
|
|
388
|
-
core: {
|
|
389
|
-
// version:
|
|
390
|
-
// '0x07871c4b3c847a0f674510d4978d5cf6f960452795e8ff6f189fd2088a3f6ac7',
|
|
391
|
-
version: "0xd318de9b0f6873879a82cbfcc2daa1d1591a8b54e7cea9f4b567da63c692a52b",
|
|
392
|
-
versionCap: "0x590a4011cb649b3878f3ea14b3a78674642a9548d79b7e091ef679574b158a07",
|
|
393
|
-
// object:
|
|
394
|
-
// '0xefe8b36d5b2e43728cc323298626b83177803521d195cfb11e15b910e892fddf',
|
|
395
|
-
object: "0x6c23585e940a989588432509107e98bae06dbca4e333f26d0635d401b3c7c76d",
|
|
396
|
-
// market:
|
|
397
|
-
// '0xa757975255146dc9686aa823b7838b507f315d704f428cbadad2f4ea061939d9',
|
|
398
|
-
market: "0x9d6434e97f3f98fd9b0c0e1dca22632073985abcd22541feae7ee1e34cbe3af2",
|
|
399
|
-
adminCap: "0x09689d018e71c337d9db6d67cbca06b74ed92196103624028ccc3ecea411777c",
|
|
400
|
-
coinDecimalsRegistry: "0x200abe9bf19751cc566ae35aa58e2b7e4ff688fc1130f8d8909ea09bc137d668",
|
|
401
|
-
// obligationAccessStore:
|
|
402
|
-
// '0x733e30b7c94d619d78cb8f5bc4bfbb759ced9a531239028caabb2474e5be59c9',
|
|
403
|
-
obligationAccessStore: "0x46e9b44a77ee9c9d33cc2689ecdfbb8f681935cbc6bdf6ac3df048e396c36c82",
|
|
404
|
-
coins: {
|
|
405
|
-
usdc: {
|
|
406
|
-
id: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7",
|
|
407
|
-
metaData: "0x69b7a7c3c200439c1b5f3b19d7d495d5966d5f08de66c69276152f8db3992ec6",
|
|
408
|
-
treasury: "",
|
|
409
|
-
oracle: {
|
|
410
|
-
supra: "",
|
|
411
|
-
switchboard: "",
|
|
412
|
-
pyth: {
|
|
413
|
-
feed: "eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a",
|
|
414
|
-
feedObject: "0x5dec622733a204ca27f5a90d8c2fad453cc6665186fd5dff13a83d0b6c9027ab"
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
},
|
|
418
|
-
cetus: {
|
|
419
|
-
id: "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b",
|
|
420
|
-
metaData: "0x4c0dce55eff2db5419bbd2d239d1aa22b4a400c01bbb648b058a9883989025da",
|
|
421
|
-
treasury: "",
|
|
422
|
-
oracle: {
|
|
423
|
-
supra: "",
|
|
424
|
-
switchboard: "",
|
|
425
|
-
pyth: {
|
|
426
|
-
feed: "e5b274b2611143df055d6e7cd8d93fe1961716bcd4dca1cad87a83bc1e78c1ef",
|
|
427
|
-
feedObject: "0x24c0247fb22457a719efac7f670cdc79be321b521460bd6bd2ccfa9f80713b14"
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
},
|
|
431
|
-
wapt: {
|
|
432
|
-
id: "0x3a5143bb1196e3bcdfab6203d1683ae29edd26294fc8bfeafe4aaa9d2704df37",
|
|
433
|
-
metaData: "0xc969c5251f372c0f34c32759f1d315cf1ea0ee5e4454b52aea08778eacfdd0a8",
|
|
434
|
-
treasury: "",
|
|
435
|
-
oracle: {
|
|
436
|
-
supra: "",
|
|
437
|
-
switchboard: "",
|
|
438
|
-
pyth: {
|
|
439
|
-
feed: "03ae4db29ed4ae33d323568895aa00337e658e348b37509f5372ae51f0af00d5",
|
|
440
|
-
feedObject: "0x7c5b7837c44a69b469325463ac0673ac1aa8435ff44ddb4191c9ae380463647f"
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
},
|
|
444
|
-
wsol: {
|
|
445
|
-
id: "0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8",
|
|
446
|
-
metaData: "0x4d2c39082b4477e3e79dc4562d939147ab90c42fc5f3e4acf03b94383cd69b6e",
|
|
447
|
-
treasury: "",
|
|
448
|
-
oracle: {
|
|
449
|
-
supra: "",
|
|
450
|
-
switchboard: "",
|
|
451
|
-
pyth: {
|
|
452
|
-
feed: "ef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d",
|
|
453
|
-
feedObject: "0x9d0d275efbd37d8a8855f6f2c761fa5983293dd8ce202ee5196626de8fcd4469"
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
},
|
|
457
|
-
wbtc: {
|
|
458
|
-
id: "0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881",
|
|
459
|
-
metaData: "0x5d3c6e60eeff8a05b693b481539e7847dfe33013e7070cdcb387f5c0cac05dfd",
|
|
460
|
-
treasury: "",
|
|
461
|
-
oracle: {
|
|
462
|
-
supra: "",
|
|
463
|
-
switchboard: "",
|
|
464
|
-
pyth: {
|
|
465
|
-
feed: "e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43",
|
|
466
|
-
feedObject: "0x9a62b4863bdeaabdc9500fce769cf7e72d5585eeb28a6d26e4cafadc13f76ab2"
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
},
|
|
470
|
-
weth: {
|
|
471
|
-
id: "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5",
|
|
472
|
-
metaData: "0x8900e4ceede3363bef086d6b50ca89d816d0e90bf6bc46efefe1f8455e08f50f",
|
|
473
|
-
treasury: "",
|
|
474
|
-
oracle: {
|
|
475
|
-
supra: "",
|
|
476
|
-
switchboard: "",
|
|
477
|
-
pyth: {
|
|
478
|
-
feed: "ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace",
|
|
479
|
-
feedObject: "0x9193fd47f9a0ab99b6e365a464c8a9ae30e6150fc37ed2a89c1586631f6fc4ab"
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
},
|
|
483
|
-
wusdc: {
|
|
484
|
-
id: "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf",
|
|
485
|
-
metaData: "0x4fbf84f3029bd0c0b77164b587963be957f853eccf834a67bb9ecba6ec80f189",
|
|
486
|
-
treasury: "",
|
|
487
|
-
oracle: {
|
|
488
|
-
supra: "",
|
|
489
|
-
switchboard: "",
|
|
490
|
-
pyth: {
|
|
491
|
-
feed: "eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a",
|
|
492
|
-
feedObject: "0x5dec622733a204ca27f5a90d8c2fad453cc6665186fd5dff13a83d0b6c9027ab"
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
},
|
|
496
|
-
wusdt: {
|
|
497
|
-
id: "0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c",
|
|
498
|
-
metaData: "0xfb0e3eb97dd158a5ae979dddfa24348063843c5b20eb8381dd5fa7c93699e45c",
|
|
499
|
-
treasury: "",
|
|
500
|
-
oracle: {
|
|
501
|
-
supra: "",
|
|
502
|
-
switchboard: "",
|
|
503
|
-
pyth: {
|
|
504
|
-
feed: "2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b",
|
|
505
|
-
feedObject: "0x985e3db9f93f76ee8bace7c3dd5cc676a096accd5d9e09e9ae0fb6e492b14572"
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
},
|
|
509
|
-
sui: {
|
|
510
|
-
id: "0x0000000000000000000000000000000000000000000000000000000000000002",
|
|
511
|
-
metaData: "0x9258181f5ceac8dbffb7030890243caed69a9599d2886d957a9cb7656af3bdb3",
|
|
512
|
-
treasury: "",
|
|
513
|
-
oracle: {
|
|
514
|
-
supra: "",
|
|
515
|
-
switchboard: "0xbca474133638352ba83ccf7b5c931d50f764b09550e16612c9f70f1e21f3f594",
|
|
516
|
-
pyth: {
|
|
517
|
-
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
518
|
-
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
},
|
|
522
|
-
afsui: {
|
|
523
|
-
id: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc",
|
|
524
|
-
metaData: "0x2f9217f533e51334873a39b8026a4aa6919497b47f49d0986a4f1aec66f8a34d",
|
|
525
|
-
treasury: "",
|
|
526
|
-
oracle: {
|
|
527
|
-
supra: "",
|
|
528
|
-
switchboard: "",
|
|
529
|
-
pyth: {
|
|
530
|
-
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
531
|
-
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
},
|
|
535
|
-
hasui: {
|
|
536
|
-
id: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d",
|
|
537
|
-
metaData: "0x2c5f33af93f6511df699aaaa5822d823aac6ed99d4a0de2a4a50b3afa0172e24",
|
|
538
|
-
treasury: "",
|
|
539
|
-
oracle: {
|
|
540
|
-
supra: "",
|
|
541
|
-
switchboard: "",
|
|
542
|
-
pyth: {
|
|
543
|
-
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
544
|
-
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
},
|
|
548
|
-
vsui: {
|
|
549
|
-
id: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55",
|
|
550
|
-
metaData: "0xabd84a23467b33854ab25cf862006fd97479f8f6f53e50fe732c43a274d939bd",
|
|
551
|
-
treasury: "",
|
|
552
|
-
oracle: {
|
|
553
|
-
supra: "",
|
|
554
|
-
switchboard: "",
|
|
555
|
-
pyth: {
|
|
556
|
-
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
557
|
-
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
},
|
|
561
|
-
sca: {
|
|
562
|
-
id: "0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6",
|
|
563
|
-
metaData: "0x5d26a1e9a55c88147ac870bfa31b729d7f49f8804b8b3adfdf3582d301cca844",
|
|
564
|
-
treasury: "",
|
|
565
|
-
oracle: {
|
|
566
|
-
supra: "",
|
|
567
|
-
switchboard: "",
|
|
568
|
-
pyth: {
|
|
569
|
-
feed: "7e17f0ac105abe9214deb9944c30264f5986bf292869c6bd8e8da3ccd92d79bc",
|
|
570
|
-
feedObject: "0xf6de1d3279a269a597d813cbaca59aa906543ab9a8c64e84a4722f1a20863985"
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
},
|
|
574
|
-
sbeth: {
|
|
575
|
-
id: "0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29",
|
|
576
|
-
metaData: "0x89b04ba87f8832d4d76e17a1c9dce72eb3e64d372cf02012b8d2de5384faeef0",
|
|
577
|
-
treasury: "",
|
|
578
|
-
oracle: {
|
|
579
|
-
supra: "",
|
|
580
|
-
switchboard: "",
|
|
581
|
-
pyth: {
|
|
582
|
-
feed: "ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace",
|
|
583
|
-
feedObject: "0x9193fd47f9a0ab99b6e365a464c8a9ae30e6150fc37ed2a89c1586631f6fc4ab"
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
},
|
|
588
|
-
oracles: {
|
|
589
|
-
xOracle: "0x93d5bf0936b71eb27255941e532fac33b5a5c7759e377b4923af0a1359ad494f",
|
|
590
|
-
xOracleCap: "0x1edeae568fde99e090dbdec4bcdbd33a15f53a1ce1f87aeef1a560dedf4b4a90",
|
|
591
|
-
supra: { registry: "", registryCap: "", holder: "" },
|
|
592
|
-
switchboard: { registry: "", registryCap: "" },
|
|
593
|
-
pyth: {
|
|
594
|
-
registry: "0xedc293f9413a5a7a5d53bdba1fd889d0a4030894469228f0acdae4aa3c55a213",
|
|
595
|
-
registryCap: "0xbcb07141eb1f7e01fbda4130ecf5f5adaeabb77f5d9c32158b7532bcd2197acd",
|
|
596
|
-
state: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8",
|
|
597
|
-
wormhole: "0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a",
|
|
598
|
-
wormholeState: "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c"
|
|
599
|
-
}
|
|
600
|
-
},
|
|
601
|
-
packages: {
|
|
602
|
-
coinDecimalsRegistry: {
|
|
603
|
-
id: "0xca5a5a62f01c79a104bf4d31669e29daa387f325c241de4edbe30986a9bc8b0d",
|
|
604
|
-
upgradeCap: "0x34e76a945d29f195bc53ca704fa70877d1cf3a5d7bbfdda1b13e633fff13c0f6"
|
|
605
|
-
},
|
|
606
|
-
math: {
|
|
607
|
-
id: "0xad013d5fde39e15eabda32b3dbdafd67dac32b798ce63237c27a8f73339b9b6f",
|
|
608
|
-
upgradeCap: "0x3a329598231de02e6135c62284b66005b41cad1d9ab7ca2dc79c08293aba2ec6"
|
|
609
|
-
},
|
|
610
|
-
whitelist: {
|
|
611
|
-
id: "0x1318fdc90319ec9c24df1456d960a447521b0a658316155895014a6e39b5482f",
|
|
612
|
-
upgradeCap: "0xf5a22aea23db664f7b69855b6a546747f17c1ec4230319cfc17225e462b05761"
|
|
613
|
-
},
|
|
614
|
-
x: {
|
|
615
|
-
id: "0x779b5c547976899f5474f3a5bc0db36ddf4697ad7e5a901db0415c2281d28162",
|
|
616
|
-
upgradeCap: "0x3f203f6fff6a69d151e4f1cd931f22b68c489ef2759765662fc7baf673943c9e"
|
|
617
|
-
},
|
|
618
|
-
protocol: {
|
|
619
|
-
id: "0x6c23585e940a989588432509107e98bae06dbca4e333f26d0635d401b3c7c76d",
|
|
620
|
-
upgradeCap: "0x38527d154618d1fd5a644b90717fe07cf0e9f26b46b63e9568e611a3f86d5c1a"
|
|
621
|
-
},
|
|
622
|
-
// protocol: {
|
|
623
|
-
// id: '0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e',
|
|
624
|
-
// upgradeCap:
|
|
625
|
-
// '0x38527d154618d1fd5a644b90717fe07cf0e9f26b46b63e9568e611a3f86d5c1a',
|
|
626
|
-
// },
|
|
627
|
-
protocolWhitelist: {
|
|
628
|
-
id: "0x4c262d9343dac53ecb28f482a2a3f62c73d0ebac5b5f03d57383d56ff219acdf",
|
|
629
|
-
upgradeCap: "0x4a5e88a75039b00988f633f811f58117f31b8627a46bf822aa114d9010049449"
|
|
630
|
-
},
|
|
631
|
-
// query: {
|
|
632
|
-
// id: '0xb8d603a39114a5efef3dd0bf84df0bed1be1fbd39b78b7dd6e8a61ccc5e6006f',
|
|
633
|
-
// upgradeCap:
|
|
634
|
-
// '0x0d535c35f608b9b01b7ccce11acf43b1dd80c1b72bf8b541744a6e28e8d2745f',
|
|
635
|
-
// },
|
|
636
|
-
query: {
|
|
637
|
-
id: "0x89706958f43fb170de134579e3fbc53972b946ee78bd2442d8e1adc36074fbdc",
|
|
638
|
-
upgradeCap: "0x0d535c35f608b9b01b7ccce11acf43b1dd80c1b72bf8b541744a6e28e8d2745f"
|
|
639
|
-
},
|
|
640
|
-
supra: { id: "", upgradeCap: "" },
|
|
641
|
-
pyth: {
|
|
642
|
-
id: "0x910f30cbc7f601f75a5141a01265cd47c62d468707c5e1aecb32a18f448cb25a",
|
|
643
|
-
upgradeCap: "0xdf0ffbae1ea5bb25fbca5efba433dcf00c7cced65679af2f04728901275c6157"
|
|
644
|
-
},
|
|
645
|
-
switchboard: { id: "", upgradeCap: "" },
|
|
646
|
-
xOracle: {
|
|
647
|
-
id: "0x1478a432123e4b3d61878b629f2c692969fdb375644f1251cd278a4b1e7d7cd6",
|
|
648
|
-
upgradeCap: "0x0f928a6b2e26b73330fecaf9b44acfc9800a4a9794d6415c2a3153bc70e3c1f0"
|
|
649
|
-
},
|
|
650
|
-
testCoin: { id: "", upgradeCap: "" }
|
|
651
|
-
}
|
|
652
|
-
},
|
|
653
|
-
spool: {
|
|
654
|
-
// id: '0x7c4fdabe81c31b19a45d1e572a52a539997a90903fbb5bfab71480abe0fa62c3',
|
|
655
|
-
id: "0x1742655fe5872dfa6456673f9e38612a4965e6979e6cd7696a7f1225f28bae21",
|
|
656
|
-
adminCap: "0xdd8a047cbbf802bfcde5288b8ef1910965d789cc614da11d39af05fca0bd020a",
|
|
657
|
-
// object:
|
|
658
|
-
// '0xe87f1b2d498106a2c61421cec75b7b5c5e348512b0dc263949a0e7a3c256571a',
|
|
659
|
-
object: "0x1742655fe5872dfa6456673f9e38612a4965e6979e6cd7696a7f1225f28bae21",
|
|
660
|
-
pools: {
|
|
661
|
-
sweth: {
|
|
662
|
-
id: "0xeec40beccb07c575bebd842eeaabb835f77cd3dab73add433477e57f583a6787",
|
|
663
|
-
rewardPoolId: "0x957de68a18d87817de8309b30c1ec269a4d87ae513abbeed86b5619cb9ce1077"
|
|
664
|
-
},
|
|
665
|
-
ssui: {
|
|
666
|
-
// id: '0x4f0ba970d3c11db05c8f40c64a15b6a33322db3702d634ced6536960ab6f3ee4',
|
|
667
|
-
id: "0xb9617f83c06ebdeac0a8834782b1015e1cc7ea23739e30c132c4bfb95c37a579",
|
|
668
|
-
rewardPoolId: (
|
|
669
|
-
// '0x162250ef72393a4ad3d46294c4e1bdfcb03f04c869d390e7efbfc995353a7ee9',
|
|
670
|
-
"0xc3206071a8d43212efb6e3b5504f2321f8df97ab122b466c0bc7cfdf398dc13a"
|
|
671
|
-
)
|
|
672
|
-
},
|
|
673
|
-
susdc: {
|
|
674
|
-
id: "0x0b5f5f413bd3799e4052c37311966c77f3a4545eb125d2e93e67a68478021918",
|
|
675
|
-
rewardPoolId: "0x85ed6ed72ea97c35dbf0cdc7ed6fbc48d8ec15de9b17c74bf4512df8a6d7f166"
|
|
676
|
-
},
|
|
677
|
-
swusdc: {
|
|
678
|
-
// id: '0x4ace6648ddc64e646ba47a957c562c32c9599b3bba8f5ac1aadb2ae23a2f8ca0',
|
|
679
|
-
id: "0xf1b383b9cf2e9f515fc69567df1053098f273849d09cd84b0278a773429bd2b2",
|
|
680
|
-
rewardPoolId: (
|
|
681
|
-
// '0xf4268cc9b9413b9bfe09e8966b8de650494c9e5784bf0930759cfef4904daff8',
|
|
682
|
-
"0xc71c53ee6505d928ba15bea4fe4f45d98c9c31eced94b72d00a7827d4b7ba3ff"
|
|
683
|
-
)
|
|
684
|
-
},
|
|
685
|
-
swusdt: {
|
|
686
|
-
// id: '0xcb328f7ffa7f9342ed85af3fdb2f22919e1a06dfb2f713c04c73543870d7548f',
|
|
687
|
-
id: "0xb5567dfa5c7fc17a249e959732664c50713dd8c23db1a11376b27df800c17418",
|
|
688
|
-
rewardPoolId: (
|
|
689
|
-
// '0x2c9f934d67a5baa586ceec2cc24163a2f049a6af3d5ba36b84d8ac40f25c4080',
|
|
690
|
-
"0x60768b0687ff0235e376a039709a683e4c436098785e473b67b32dbab47b69ab"
|
|
691
|
-
)
|
|
692
|
-
},
|
|
693
|
-
scetus: {
|
|
694
|
-
id: "0xac1bb13bf4472a637c18c2415fb0e3c1227ea2bcf35242e50563c98215bd298e",
|
|
695
|
-
rewardPoolId: "0x6835c1224126a45086fc6406adc249e3f30df18d779ca4f4e570e38716a17f3f"
|
|
696
|
-
},
|
|
697
|
-
safsui: {
|
|
698
|
-
// id: '0xeedf438abcaa6ce4d9625ffca110920592d5867e4c5637d84ad9f466c4feb800',
|
|
699
|
-
id: "0xc568bb4c991258e839aa54802ecda04fcd9838c826bc3b42b40af81b23c458c8",
|
|
700
|
-
rewardPoolId: (
|
|
701
|
-
// '0x89255a2f86ed7fbfef35ab8b7be48cc7667015975be2685dd9a55a9a64baf76e',
|
|
702
|
-
"0x389a3cbeda742b918941bb24fd00e077bad3367484394d6234f8209b9a6aa03d"
|
|
703
|
-
)
|
|
704
|
-
},
|
|
705
|
-
shasui: {
|
|
706
|
-
// id: '0xa6148bc1b623e936d39a952ceb5bea79e8b37228a8f595067bf1852efd3c34aa',
|
|
707
|
-
id: "0x93f3f4499bf89f2d05ddc1f8b15f51701a7c6c4d0ac0b9c3bc99462cbbd8e321",
|
|
708
|
-
rewardPoolId: (
|
|
709
|
-
// '0x6f3563644d3e2ef13176dbf9d865bd93479df60ccbe07b7e66db57f6309f5a66',
|
|
710
|
-
"0x94cee1be7f5ff34193f3aabef0b14142cb28af4d905fe487a9a7d85a15edb6aa"
|
|
711
|
-
)
|
|
712
|
-
},
|
|
713
|
-
svsui: {
|
|
714
|
-
// id: '0x69ce8e537e750a95381e6040794afa5ab1758353a1a2e1de7760391b01f91670',
|
|
715
|
-
id: "0xa970e9087f80cb59e9299b8e7af7175d977ad6c9af0322aa4440e138fbd7ae00",
|
|
716
|
-
rewardPoolId: (
|
|
717
|
-
// '0xbca914adce058ad0902c7f3cfcd698392a475f00dcfdc3f76001d0370b98777a',
|
|
718
|
-
"0x38eee9699c4fc132a6623e54b865f047df4fc6eb83af807300f44e8f4b235ff0"
|
|
719
|
-
)
|
|
720
|
-
}
|
|
721
|
-
},
|
|
722
|
-
config: ""
|
|
723
|
-
},
|
|
724
|
-
borrowIncentive: {
|
|
725
|
-
id: "0x85769d63565ce99c7622f8e336ca1460926ddf29738ad2a39407b5cac29f61fe",
|
|
726
|
-
adminCap: "0x56ac8e6f2b360b2b35c0168d72cc6cd17d9592afb83709865cb87af24bb2025b",
|
|
727
|
-
object: "0x85769d63565ce99c7622f8e336ca1460926ddf29738ad2a39407b5cac29f61fe",
|
|
728
|
-
query: "0x8e0d00f8ff1199d7c5fe56cea0e901a525daeefff0445a1635ace8282ae3302c",
|
|
729
|
-
incentivePools: "0x9d564c93128c6ab0c0d3e050a47f11df0b91494f3bb779bdc1301c1c637f15eb",
|
|
730
|
-
incentiveAccounts: "0x09e6040e798246de04941bc79a3ba62d3eca6d7a218cc30f21fb07f478fa2926",
|
|
731
|
-
config: "0x43d4ca1dfc90b161c4240facd119e74e4b850cca2957f88c2ec289c9380da064"
|
|
732
|
-
},
|
|
733
|
-
referral: {
|
|
734
|
-
id: "0x1bf5a8ce77050d8052549d743e16b469f15aa6b81b752b78b6ebb65179665f5a",
|
|
735
|
-
object: "0x5658d4bf5ddcba27e4337b4262108b3ad1716643cac8c2054ac341538adc72ec",
|
|
736
|
-
adminCap: "0xc5dc06b9074291259f2cac460c940012c781c4430e42125c541cc43101c3bcbd",
|
|
737
|
-
referralBindings: "0xcf184487782bed962bf678001efe775d31fb94b9992333a57594cf15d79d5ced",
|
|
738
|
-
bindingTableId: "0x41a50e258c0a266ce84e0e1a618dbf70b878cc943909e613089a50afcceb2bc0",
|
|
739
|
-
referralRevenuePool: "0xc24e3e5e37032f29a3dd91a9a1f057af8821b7e6c148e9683900ac8b6d30f0c6",
|
|
740
|
-
revenueTableId: "0x595baa3654c297bff84ab7786a2d250f019cefc66e8df8e89fd9d41e02bd30dd",
|
|
741
|
-
referralTiers: "0x144350f3db9b46d11b140084cd54e6de0b9c3b8d265ce8059b51d0ef58ea464b",
|
|
742
|
-
tiersTableId: "0xeac755a7a8b7798530905ac79e8c114f19d0f130f6eab012954f08faac29c75d",
|
|
743
|
-
// authorizedWitnessList:
|
|
744
|
-
// '0xf21b0ed043c9bb70842c0129159f4943dbcc3c9ef2f2f808af65f8be25cfd20e',
|
|
745
|
-
authorizedWitnessList: "0x9d6223dc52015b8a3986a573590ef2af8f1b8f3e4685513888c052f001b87e7f",
|
|
746
|
-
version: "0x3545849eb97723e676a476ec9d4fe5f2eb0eb2c6b78972851114fd4c7ed4639f"
|
|
747
|
-
},
|
|
748
|
-
vesca: {
|
|
749
|
-
id: "0x1158813b32962c2d22888fae257d5f2365b03631f0cd5d5b912ccdf51ff4e2f2",
|
|
750
|
-
object: "0x1158813b32962c2d22888fae257d5f2365b03631f0cd5d5b912ccdf51ff4e2f2",
|
|
751
|
-
adminCap: "0x8ffa76135c5b85c5fbd73a6448a4a733d826cb63a267ab817656acb77c72d4a5",
|
|
752
|
-
tableId: "0x0a0b7f749baeb61e3dfee2b42245e32d0e6b484063f0a536b33e771d573d7246",
|
|
753
|
-
table: "0xd3a4632b1080f7d96e1c2487d4dabf2c1196916937c505a69954ac9f393be8d0",
|
|
754
|
-
treasury: "0xafa4b6231e49c15a22d641ce33fda761baaf650fa21899dfa2eb1716146e7306",
|
|
755
|
-
config: "0x7cbcb0a342179577a117dfdff974cf1ab765d3b571067bf22ddf5f9e3a667922"
|
|
756
|
-
},
|
|
757
|
-
loyaltyProgram: {
|
|
758
|
-
id: "0xd17bcf8b5a59652c36225d478564a8593ae0ed7d650bcacdda1d6fe179127907",
|
|
759
|
-
object: "0xd17bcf8b5a59652c36225d478564a8593ae0ed7d650bcacdda1d6fe179127907",
|
|
760
|
-
rewardPool: "0xf9c090492ef476bd542109d0913ffe871cbfa28578b7114eca2a8c0e5671786f",
|
|
761
|
-
userRewardTableId: "0x748a80395849ed37db1b0e14f2ab5d1d96458d2359ab3a84eb079d0f4ac7cf2e"
|
|
762
|
-
},
|
|
763
|
-
scoin: {
|
|
764
|
-
id: "0x773dab39c90fe05439b06a2d061795e52a974ff92c2aef90b2ee467acf7f33c8",
|
|
765
|
-
coins: {
|
|
766
|
-
ssui: {
|
|
767
|
-
coinType: "0xf569919046f19a0c40b519ecfbb6ca0319698cd5908716c29b62ef56541f298b::scallop_sui::SCALLOP_SUI",
|
|
768
|
-
treasury: "0x0e499640a12c38dd9cc44532f5bc5fd1b6da86d2f9a8810357250f4b26e9e5c7"
|
|
769
|
-
},
|
|
770
|
-
scetus: {
|
|
771
|
-
coinType: "0x8b71e6d323ed78515af2bead13bf3d0da1562ba4a99234eb7c4f14fd39ef0427::scallop_cetus::SCALLOP_CETUS",
|
|
772
|
-
treasury: "0xd786f4b2d26278cc7911a3445b1b085eab60f269ef9dbb6b87e803d52f155003"
|
|
773
|
-
},
|
|
774
|
-
ssca: {
|
|
775
|
-
coinType: "0x958428555e778e55918a59eb1c92c77f32b5c554fa3a5e56cd0815086b5072e7::scallop_sca::SCALLOP_SCA",
|
|
776
|
-
treasury: "0x5f1c5de1df7341075d119570269b7b452af50afe8363080638f1ae29a554c038"
|
|
777
|
-
},
|
|
778
|
-
swusdc: {
|
|
779
|
-
coinType: "0xf5447c4305a486d8c8557559887c2c39449ddb5e748f15d33946d02a1663c158::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC",
|
|
780
|
-
treasury: "0x471fbab72578bab577263006fe32543b6e76153fffa2bef69affe4bc4934258f"
|
|
781
|
-
},
|
|
782
|
-
swusdt: {
|
|
783
|
-
coinType: "0xac781d9f73058ff5e69f9bf8dde32f2e8c71c66d7fe8497fc83b2d9182254b22::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT",
|
|
784
|
-
treasury: "0x921a4ed4bb4b4f11f51a462c83f4c0f6b60a90e441d1bc0d26d6fd893146bf4d"
|
|
785
|
-
},
|
|
786
|
-
sweth: {
|
|
787
|
-
coinType: "0x27d54f43e3eda701be56b82e5756e41c84467cd202f5cf713d5f9e45a9f1b6bc::scallop_wormhole_eth::SCALLOP_WORMHOLE_ETH",
|
|
788
|
-
treasury: "0x032b4c8fac94c038dbe986f7587e9b1e4ef580b5ee06d2ef249d85459b7ef05d"
|
|
789
|
-
},
|
|
790
|
-
safsui: {
|
|
791
|
-
coinType: "0xb75b46d975d8d80670b53a6bee90baaa8ce2e0b7d397f079447d641eef6b44ad::scallop_af_sui::SCALLOP_AF_SUI",
|
|
792
|
-
treasury: "0x21450ef0570ef3d224ffa3b873ab802e439ece7b93cc7efad10ae0c1e3b3fcfe"
|
|
793
|
-
},
|
|
794
|
-
shasui: {
|
|
795
|
-
coinType: "0xd973a723874e2c7cde196602a79155a1343a933f8cf87d9b1bb7408bc1acbc58::scallop_ha_sui::SCALLOP_HA_SUI",
|
|
796
|
-
treasury: "0xf822fc1402207e47d2e3ba8ff6e1e594bf1de777dc5ebd2744619cd2726e3b0d"
|
|
797
|
-
},
|
|
798
|
-
svsui: {
|
|
799
|
-
coinType: "0x97023a317320c4498cc4cd239dd02fd30c28246e5e8f81325d63f2bd8d70f6b3::scallop_v_sui::SCALLOP_V_SUI",
|
|
800
|
-
treasury: "0x327114f0bf3559d7e2de10282147ed76a236c7c6775029165c4db09a6062ead6"
|
|
801
|
-
},
|
|
802
|
-
ssbeth: {
|
|
803
|
-
coinType: "0xb14f82d8506d139eacef109688d1b71e7236bcce9b2c0ad526abcd6aa5be7de0::scallop_sb_eth::SCALLOP_SB_ETH",
|
|
804
|
-
treasury: "0xfd0f02def6358a1f266acfa1493d4707ee8387460d434fb667d63d755ff907ed"
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
}
|
|
808
|
-
};
|
|
809
|
-
|
|
810
377
|
// src/models/scallop.ts
|
|
811
378
|
import { SuiKit as SuiKit7 } from "@scallop-io/sui-kit";
|
|
812
379
|
|
|
@@ -1382,268 +949,660 @@ var findClosestUnlockRound = (unlockAtInSecondTimestamp) => {
|
|
|
1382
949
|
if (unlockDate.getUTCHours() >= 0) {
|
|
1383
950
|
closestTwelveAM.setUTCDate(closestTwelveAM.getUTCDate() + 1);
|
|
1384
951
|
}
|
|
1385
|
-
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
1386
|
-
if (closestTwelveAM.getTime() - now > MAX_LOCK_DURATION * 1e3) {
|
|
1387
|
-
closestTwelveAM.setUTCDate(closestTwelveAM.getUTCDate() - 1);
|
|
952
|
+
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
953
|
+
if (closestTwelveAM.getTime() - now > MAX_LOCK_DURATION * 1e3) {
|
|
954
|
+
closestTwelveAM.setUTCDate(closestTwelveAM.getUTCDate() - 1);
|
|
955
|
+
}
|
|
956
|
+
return Math.floor(closestTwelveAM.getTime() / 1e3);
|
|
957
|
+
};
|
|
958
|
+
|
|
959
|
+
// src/constants/tokenBucket.ts
|
|
960
|
+
var DEFAULT_TOKENS_PER_INTERVAL = 50;
|
|
961
|
+
var DEFAULT_INTERVAL_IN_MS = 300;
|
|
962
|
+
|
|
963
|
+
// src/utils/tokenBucket.ts
|
|
964
|
+
var TokenBucket = class {
|
|
965
|
+
constructor(tokensPerInterval, intervalInMs) {
|
|
966
|
+
this.tokensPerInterval = tokensPerInterval;
|
|
967
|
+
this.interval = intervalInMs;
|
|
968
|
+
this.tokens = tokensPerInterval;
|
|
969
|
+
this.lastRefill = Date.now();
|
|
970
|
+
}
|
|
971
|
+
refill() {
|
|
972
|
+
const now = Date.now();
|
|
973
|
+
const elapsed = now - this.lastRefill;
|
|
974
|
+
if (elapsed > this.interval) {
|
|
975
|
+
const tokensToAdd = Math.floor(elapsed / this.interval) * this.tokensPerInterval;
|
|
976
|
+
this.tokens = Math.min(this.tokens + tokensToAdd, this.tokensPerInterval);
|
|
977
|
+
this.lastRefill = now;
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
removeTokens(count) {
|
|
981
|
+
this.refill();
|
|
982
|
+
if (this.tokens >= count) {
|
|
983
|
+
this.tokens -= count;
|
|
984
|
+
return true;
|
|
985
|
+
}
|
|
986
|
+
return false;
|
|
987
|
+
}
|
|
988
|
+
};
|
|
989
|
+
var callWithRateLimit = async (tokenBucket, fn, retryDelayInMs = DEFAULT_INTERVAL_IN_MS, maxRetries = 15, backoffFactor = 1.25) => {
|
|
990
|
+
let retries = 0;
|
|
991
|
+
const tryRequest = async () => {
|
|
992
|
+
if (tokenBucket.removeTokens(1)) {
|
|
993
|
+
try {
|
|
994
|
+
const result = await fn();
|
|
995
|
+
if (result && result.status === 429) {
|
|
996
|
+
throw new Error("Unexpected status code: 429");
|
|
997
|
+
}
|
|
998
|
+
return result;
|
|
999
|
+
} catch (error) {
|
|
1000
|
+
if (error.message === "Unexpected status code: 429" && retries < maxRetries) {
|
|
1001
|
+
retries++;
|
|
1002
|
+
const delay = retryDelayInMs * Math.pow(backoffFactor, retries);
|
|
1003
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
1004
|
+
return tryRequest();
|
|
1005
|
+
} else {
|
|
1006
|
+
console.error("An error occurred:", error.message);
|
|
1007
|
+
return null;
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
} else if (retries < maxRetries) {
|
|
1011
|
+
retries++;
|
|
1012
|
+
const delay = retryDelayInMs * Math.pow(backoffFactor, retries);
|
|
1013
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
1014
|
+
return tryRequest();
|
|
1015
|
+
} else {
|
|
1016
|
+
console.error("Maximum retries reached");
|
|
1017
|
+
return null;
|
|
1018
|
+
}
|
|
1019
|
+
};
|
|
1020
|
+
return tryRequest();
|
|
1021
|
+
};
|
|
1022
|
+
|
|
1023
|
+
// src/utils/indexer.ts
|
|
1024
|
+
async function callMethodWithIndexerFallback(method, context, ...args) {
|
|
1025
|
+
const indexer = args[args.length - 1];
|
|
1026
|
+
if (indexer) {
|
|
1027
|
+
try {
|
|
1028
|
+
return await method.apply(context, args);
|
|
1029
|
+
} catch (e) {
|
|
1030
|
+
console.warn(`Indexer requests failed: ${e}. Retrying without indexer..`);
|
|
1031
|
+
return await method.apply(context, [...args.slice(0, -1), false]);
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
return await method.apply(context, args);
|
|
1035
|
+
}
|
|
1036
|
+
function withIndexerFallback(method) {
|
|
1037
|
+
return (...args) => {
|
|
1038
|
+
return callMethodWithIndexerFallback(method, this, ...args);
|
|
1039
|
+
};
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
// src/models/scallopCache.ts
|
|
1043
|
+
var ScallopCache = class {
|
|
1044
|
+
constructor(suiKit, walletAddress, cacheOptions, tokenBucket, queryClient) {
|
|
1045
|
+
this.queryClient = queryClient ?? new QueryClient(cacheOptions ?? DEFAULT_CACHE_OPTIONS);
|
|
1046
|
+
this._suiKit = suiKit;
|
|
1047
|
+
this.tokenBucket = tokenBucket ?? new TokenBucket(DEFAULT_TOKENS_PER_INTERVAL, DEFAULT_INTERVAL_IN_MS);
|
|
1048
|
+
this.walletAddress = walletAddress ?? suiKit.currentAddress();
|
|
1049
|
+
}
|
|
1050
|
+
get suiKit() {
|
|
1051
|
+
if (!this._suiKit) {
|
|
1052
|
+
throw new Error("SuiKit instance is not initialized");
|
|
1053
|
+
}
|
|
1054
|
+
return this._suiKit;
|
|
1055
|
+
}
|
|
1056
|
+
get client() {
|
|
1057
|
+
return this.suiKit.client();
|
|
1058
|
+
}
|
|
1059
|
+
/**
|
|
1060
|
+
* @description Invalidate cache based on the refetchType parameter
|
|
1061
|
+
* @param refetchType Determines the type of queries to be refetched. Defaults to `active`.
|
|
1062
|
+
*
|
|
1063
|
+
* - `active`: Only queries that match the refetch predicate and are actively being rendered via useQuery and related functions will be refetched in the background.
|
|
1064
|
+
* - `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.
|
|
1065
|
+
* - `all`: All queries that match the refetch predicate will be refetched in the background.
|
|
1066
|
+
* - `none`: No queries will be refetched. Queries that match the refetch predicate will only be marked as invalid.
|
|
1067
|
+
*/
|
|
1068
|
+
async invalidateAllCache() {
|
|
1069
|
+
return Object.values(queryKeys.rpc).map(
|
|
1070
|
+
(t) => this.queryClient.invalidateQueries({
|
|
1071
|
+
queryKey: t(),
|
|
1072
|
+
type: "all"
|
|
1073
|
+
})
|
|
1074
|
+
);
|
|
1075
|
+
}
|
|
1076
|
+
/**
|
|
1077
|
+
* @description Provides cache for inspectTxn of the SuiKit.
|
|
1078
|
+
* @param QueryInspectTxnParams
|
|
1079
|
+
* @param txBlock
|
|
1080
|
+
* @returns Promise<DevInspectResults>
|
|
1081
|
+
*/
|
|
1082
|
+
async queryInspectTxn({
|
|
1083
|
+
queryTarget,
|
|
1084
|
+
args,
|
|
1085
|
+
typeArgs
|
|
1086
|
+
}) {
|
|
1087
|
+
const txBlock = new SuiTxBlock();
|
|
1088
|
+
txBlock.moveCall(queryTarget, args, typeArgs);
|
|
1089
|
+
const query = await this.queryClient.fetchQuery({
|
|
1090
|
+
queryKey: queryKeys.rpc.getInspectTxn(queryTarget, args, typeArgs),
|
|
1091
|
+
queryFn: async () => {
|
|
1092
|
+
return await callWithRateLimit(
|
|
1093
|
+
this.tokenBucket,
|
|
1094
|
+
() => this.suiKit.inspectTxn(txBlock)
|
|
1095
|
+
);
|
|
1096
|
+
}
|
|
1097
|
+
});
|
|
1098
|
+
return query;
|
|
1099
|
+
}
|
|
1100
|
+
/**
|
|
1101
|
+
* @description Provides cache for getObject of the SuiKit.
|
|
1102
|
+
* @param objectId
|
|
1103
|
+
* @param QueryObjectParams
|
|
1104
|
+
* @returns Promise<SuiObjectResponse>
|
|
1105
|
+
*/
|
|
1106
|
+
async queryGetObject(objectId, options) {
|
|
1107
|
+
return this.queryClient.fetchQuery({
|
|
1108
|
+
queryKey: queryKeys.rpc.getObject(objectId, this.walletAddress, options),
|
|
1109
|
+
queryFn: async () => {
|
|
1110
|
+
return await callWithRateLimit(
|
|
1111
|
+
this.tokenBucket,
|
|
1112
|
+
() => this.client.getObject({
|
|
1113
|
+
id: objectId,
|
|
1114
|
+
options
|
|
1115
|
+
})
|
|
1116
|
+
);
|
|
1117
|
+
}
|
|
1118
|
+
});
|
|
1119
|
+
}
|
|
1120
|
+
/**
|
|
1121
|
+
* @description Provides cache for getObjects of the SuiKit.
|
|
1122
|
+
* @param objectIds
|
|
1123
|
+
* @returns Promise<SuiObjectData[]>
|
|
1124
|
+
*/
|
|
1125
|
+
async queryGetObjects(objectIds, options = {
|
|
1126
|
+
showContent: true
|
|
1127
|
+
}) {
|
|
1128
|
+
if (objectIds.length === 0)
|
|
1129
|
+
return [];
|
|
1130
|
+
return this.queryClient.fetchQuery({
|
|
1131
|
+
queryKey: queryKeys.rpc.getObjects(
|
|
1132
|
+
objectIds,
|
|
1133
|
+
this.walletAddress,
|
|
1134
|
+
options
|
|
1135
|
+
),
|
|
1136
|
+
queryFn: async () => {
|
|
1137
|
+
return await callWithRateLimit(
|
|
1138
|
+
this.tokenBucket,
|
|
1139
|
+
() => this.suiKit.getObjects(objectIds, options)
|
|
1140
|
+
);
|
|
1141
|
+
}
|
|
1142
|
+
});
|
|
1143
|
+
}
|
|
1144
|
+
/**
|
|
1145
|
+
* @description Provides cache for getOwnedObjects of the SuiKit.
|
|
1146
|
+
* @param input
|
|
1147
|
+
* @returns Promise<PaginatedObjectsResponse>
|
|
1148
|
+
*/
|
|
1149
|
+
async queryGetOwnedObjects(input) {
|
|
1150
|
+
return this.queryClient.fetchQuery({
|
|
1151
|
+
queryKey: queryKeys.rpc.getOwnedObjects(input),
|
|
1152
|
+
queryFn: async () => {
|
|
1153
|
+
return await callWithRateLimit(
|
|
1154
|
+
this.tokenBucket,
|
|
1155
|
+
() => this.client.getOwnedObjects(input)
|
|
1156
|
+
);
|
|
1157
|
+
}
|
|
1158
|
+
});
|
|
1159
|
+
}
|
|
1160
|
+
async queryGetDynamicFields(input) {
|
|
1161
|
+
return this.queryClient.fetchQuery({
|
|
1162
|
+
queryKey: queryKeys.rpc.getDynamicFields(input),
|
|
1163
|
+
queryFn: async () => {
|
|
1164
|
+
return await callWithRateLimit(
|
|
1165
|
+
this.tokenBucket,
|
|
1166
|
+
() => this.client.getDynamicFields(input)
|
|
1167
|
+
);
|
|
1168
|
+
}
|
|
1169
|
+
});
|
|
1388
1170
|
}
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
this.tokensPerInterval = tokensPerInterval;
|
|
1400
|
-
this.interval = intervalInMs;
|
|
1401
|
-
this.tokens = tokensPerInterval;
|
|
1402
|
-
this.lastRefill = Date.now();
|
|
1171
|
+
async queryGetDynamicFieldObject(input) {
|
|
1172
|
+
return this.queryClient.fetchQuery({
|
|
1173
|
+
queryKey: queryKeys.rpc.getDynamicFieldObject(input),
|
|
1174
|
+
queryFn: async () => {
|
|
1175
|
+
return await callWithRateLimit(
|
|
1176
|
+
this.tokenBucket,
|
|
1177
|
+
() => this.client.getDynamicFieldObject(input)
|
|
1178
|
+
);
|
|
1179
|
+
}
|
|
1180
|
+
});
|
|
1403
1181
|
}
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1182
|
+
async queryGetAllCoinBalances(owner) {
|
|
1183
|
+
return this.queryClient.fetchQuery({
|
|
1184
|
+
queryKey: queryKeys.rpc.getAllCoinBalances(owner),
|
|
1185
|
+
queryFn: async () => {
|
|
1186
|
+
const allBalances = await callWithRateLimit(
|
|
1187
|
+
this.tokenBucket,
|
|
1188
|
+
() => this.client.getAllBalances({ owner })
|
|
1189
|
+
);
|
|
1190
|
+
if (!allBalances)
|
|
1191
|
+
return {};
|
|
1192
|
+
const balances = allBalances.reduce(
|
|
1193
|
+
(acc, coinBalance) => {
|
|
1194
|
+
if (coinBalance.totalBalance !== "0") {
|
|
1195
|
+
acc[normalizeStructTag2(coinBalance.coinType)] = coinBalance.totalBalance;
|
|
1196
|
+
}
|
|
1197
|
+
return acc;
|
|
1198
|
+
},
|
|
1199
|
+
{}
|
|
1200
|
+
);
|
|
1201
|
+
return balances;
|
|
1202
|
+
}
|
|
1203
|
+
});
|
|
1412
1204
|
}
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
return true;
|
|
1418
|
-
}
|
|
1419
|
-
return false;
|
|
1205
|
+
async queryGetCoinBalance(input) {
|
|
1206
|
+
if (!input.coinType)
|
|
1207
|
+
return "0";
|
|
1208
|
+
return (await this.queryGetAllCoinBalances(input.owner) || {})[normalizeStructTag2(input.coinType)] ?? "0";
|
|
1420
1209
|
}
|
|
1421
1210
|
};
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1211
|
+
|
|
1212
|
+
// src/models/scallopAddress.ts
|
|
1213
|
+
import axios from "axios";
|
|
1214
|
+
|
|
1215
|
+
// src/constants/testAddress.ts
|
|
1216
|
+
var TEST_ADDRESSES = {
|
|
1217
|
+
core: {
|
|
1218
|
+
// version:
|
|
1219
|
+
// '0x07871c4b3c847a0f674510d4978d5cf6f960452795e8ff6f189fd2088a3f6ac7',
|
|
1220
|
+
version: "0x6156d5cd1538bec8a167a40fe1209a4ec9cf8137921fe0a697f191ac561f0b09",
|
|
1221
|
+
versionCap: "0x590a4011cb649b3878f3ea14b3a78674642a9548d79b7e091ef679574b158a07",
|
|
1222
|
+
// object:
|
|
1223
|
+
// '0xefe8b36d5b2e43728cc323298626b83177803521d195cfb11e15b910e892fddf',
|
|
1224
|
+
object: "0x87ddec2984645dbbe2403a509cc6edf393a43acdba9b77d45da2bcbefcf733c1",
|
|
1225
|
+
// market:
|
|
1226
|
+
// '0xa757975255146dc9686aa823b7838b507f315d704f428cbadad2f4ea061939d9',
|
|
1227
|
+
market: "0x8606ed145cc887985b8ed793f7753ff5dc762a42c379dac035f568e1bac58490",
|
|
1228
|
+
adminCap: "0x09689d018e71c337d9db6d67cbca06b74ed92196103624028ccc3ecea411777c",
|
|
1229
|
+
coinDecimalsRegistry: "0x200abe9bf19751cc566ae35aa58e2b7e4ff688fc1130f8d8909ea09bc137d668",
|
|
1230
|
+
// obligationAccessStore:
|
|
1231
|
+
// '0x733e30b7c94d619d78cb8f5bc4bfbb759ced9a531239028caabb2474e5be59c9',
|
|
1232
|
+
obligationAccessStore: "0x48b472d68ca910c45f7f3b6c26836b6aa6d2569810d94b1b939023da05ae0a23",
|
|
1233
|
+
coins: {
|
|
1234
|
+
cetus: {
|
|
1235
|
+
id: "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b",
|
|
1236
|
+
metaData: "0x4c0dce55eff2db5419bbd2d239d1aa22b4a400c01bbb648b058a9883989025da",
|
|
1237
|
+
treasury: "",
|
|
1238
|
+
oracle: {
|
|
1239
|
+
supra: "",
|
|
1240
|
+
switchboard: "",
|
|
1241
|
+
pyth: {
|
|
1242
|
+
feed: "e5b274b2611143df055d6e7cd8d93fe1961716bcd4dca1cad87a83bc1e78c1ef",
|
|
1243
|
+
feedObject: "0x24c0247fb22457a719efac7f670cdc79be321b521460bd6bd2ccfa9f80713b14"
|
|
1244
|
+
}
|
|
1430
1245
|
}
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1246
|
+
},
|
|
1247
|
+
wapt: {
|
|
1248
|
+
id: "0x3a5143bb1196e3bcdfab6203d1683ae29edd26294fc8bfeafe4aaa9d2704df37",
|
|
1249
|
+
metaData: "0xc969c5251f372c0f34c32759f1d315cf1ea0ee5e4454b52aea08778eacfdd0a8",
|
|
1250
|
+
treasury: "",
|
|
1251
|
+
oracle: {
|
|
1252
|
+
supra: "",
|
|
1253
|
+
switchboard: "",
|
|
1254
|
+
pyth: {
|
|
1255
|
+
feed: "03ae4db29ed4ae33d323568895aa00337e658e348b37509f5372ae51f0af00d5",
|
|
1256
|
+
feedObject: "0x7c5b7837c44a69b469325463ac0673ac1aa8435ff44ddb4191c9ae380463647f"
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
},
|
|
1260
|
+
wsol: {
|
|
1261
|
+
id: "0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8",
|
|
1262
|
+
metaData: "0x4d2c39082b4477e3e79dc4562d939147ab90c42fc5f3e4acf03b94383cd69b6e",
|
|
1263
|
+
treasury: "",
|
|
1264
|
+
oracle: {
|
|
1265
|
+
supra: "",
|
|
1266
|
+
switchboard: "",
|
|
1267
|
+
pyth: {
|
|
1268
|
+
feed: "ef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d",
|
|
1269
|
+
feedObject: "0x9d0d275efbd37d8a8855f6f2c761fa5983293dd8ce202ee5196626de8fcd4469"
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
},
|
|
1273
|
+
wbtc: {
|
|
1274
|
+
id: "0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881",
|
|
1275
|
+
metaData: "0x5d3c6e60eeff8a05b693b481539e7847dfe33013e7070cdcb387f5c0cac05dfd",
|
|
1276
|
+
treasury: "",
|
|
1277
|
+
oracle: {
|
|
1278
|
+
supra: "",
|
|
1279
|
+
switchboard: "",
|
|
1280
|
+
pyth: {
|
|
1281
|
+
feed: "e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43",
|
|
1282
|
+
feedObject: "0x9a62b4863bdeaabdc9500fce769cf7e72d5585eeb28a6d26e4cafadc13f76ab2"
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
},
|
|
1286
|
+
weth: {
|
|
1287
|
+
id: "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5",
|
|
1288
|
+
metaData: "0x8900e4ceede3363bef086d6b50ca89d816d0e90bf6bc46efefe1f8455e08f50f",
|
|
1289
|
+
treasury: "",
|
|
1290
|
+
oracle: {
|
|
1291
|
+
supra: "",
|
|
1292
|
+
switchboard: "",
|
|
1293
|
+
pyth: {
|
|
1294
|
+
feed: "ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace",
|
|
1295
|
+
feedObject: "0x9193fd47f9a0ab99b6e365a464c8a9ae30e6150fc37ed2a89c1586631f6fc4ab"
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
},
|
|
1299
|
+
wusdc: {
|
|
1300
|
+
id: "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf",
|
|
1301
|
+
metaData: "0x4fbf84f3029bd0c0b77164b587963be957f853eccf834a67bb9ecba6ec80f189",
|
|
1302
|
+
treasury: "",
|
|
1303
|
+
oracle: {
|
|
1304
|
+
supra: "",
|
|
1305
|
+
switchboard: "",
|
|
1306
|
+
pyth: {
|
|
1307
|
+
feed: "eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a",
|
|
1308
|
+
feedObject: "0x5dec622733a204ca27f5a90d8c2fad453cc6665186fd5dff13a83d0b6c9027ab"
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
},
|
|
1312
|
+
wusdt: {
|
|
1313
|
+
id: "0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c",
|
|
1314
|
+
metaData: "0xfb0e3eb97dd158a5ae979dddfa24348063843c5b20eb8381dd5fa7c93699e45c",
|
|
1315
|
+
treasury: "",
|
|
1316
|
+
oracle: {
|
|
1317
|
+
supra: "",
|
|
1318
|
+
switchboard: "",
|
|
1319
|
+
pyth: {
|
|
1320
|
+
feed: "2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b",
|
|
1321
|
+
feedObject: "0x985e3db9f93f76ee8bace7c3dd5cc676a096accd5d9e09e9ae0fb6e492b14572"
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
},
|
|
1325
|
+
sui: {
|
|
1326
|
+
id: "0x0000000000000000000000000000000000000000000000000000000000000002",
|
|
1327
|
+
metaData: "0x9258181f5ceac8dbffb7030890243caed69a9599d2886d957a9cb7656af3bdb3",
|
|
1328
|
+
treasury: "",
|
|
1329
|
+
oracle: {
|
|
1330
|
+
supra: "",
|
|
1331
|
+
switchboard: "0xbca474133638352ba83ccf7b5c931d50f764b09550e16612c9f70f1e21f3f594",
|
|
1332
|
+
pyth: {
|
|
1333
|
+
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
1334
|
+
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
},
|
|
1338
|
+
afsui: {
|
|
1339
|
+
id: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc",
|
|
1340
|
+
metaData: "0x2f9217f533e51334873a39b8026a4aa6919497b47f49d0986a4f1aec66f8a34d",
|
|
1341
|
+
treasury: "",
|
|
1342
|
+
oracle: {
|
|
1343
|
+
supra: "",
|
|
1344
|
+
switchboard: "",
|
|
1345
|
+
pyth: {
|
|
1346
|
+
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
1347
|
+
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
},
|
|
1351
|
+
hasui: {
|
|
1352
|
+
id: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d",
|
|
1353
|
+
metaData: "0x2c5f33af93f6511df699aaaa5822d823aac6ed99d4a0de2a4a50b3afa0172e24",
|
|
1354
|
+
treasury: "",
|
|
1355
|
+
oracle: {
|
|
1356
|
+
supra: "",
|
|
1357
|
+
switchboard: "",
|
|
1358
|
+
pyth: {
|
|
1359
|
+
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
1360
|
+
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
},
|
|
1364
|
+
vsui: {
|
|
1365
|
+
id: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55",
|
|
1366
|
+
metaData: "0xabd84a23467b33854ab25cf862006fd97479f8f6f53e50fe732c43a274d939bd",
|
|
1367
|
+
treasury: "",
|
|
1368
|
+
oracle: {
|
|
1369
|
+
supra: "",
|
|
1370
|
+
switchboard: "",
|
|
1371
|
+
pyth: {
|
|
1372
|
+
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
1373
|
+
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
},
|
|
1377
|
+
sca: {
|
|
1378
|
+
id: "0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6",
|
|
1379
|
+
metaData: "0x5d26a1e9a55c88147ac870bfa31b729d7f49f8804b8b3adfdf3582d301cca844",
|
|
1380
|
+
treasury: "",
|
|
1381
|
+
oracle: {
|
|
1382
|
+
supra: "",
|
|
1383
|
+
switchboard: "",
|
|
1384
|
+
pyth: {
|
|
1385
|
+
feed: "7e17f0ac105abe9214deb9944c30264f5986bf292869c6bd8e8da3ccd92d79bc",
|
|
1386
|
+
feedObject: "0xf6de1d3279a269a597d813cbaca59aa906543ab9a8c64e84a4722f1a20863985"
|
|
1387
|
+
}
|
|
1441
1388
|
}
|
|
1442
1389
|
}
|
|
1443
|
-
}
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
// src/utils/indexer.ts
|
|
1457
|
-
async function callMethodWithIndexerFallback(method, context, ...args) {
|
|
1458
|
-
const indexer = args[args.length - 1];
|
|
1459
|
-
if (indexer) {
|
|
1460
|
-
try {
|
|
1461
|
-
return await method.apply(context, args);
|
|
1462
|
-
} catch (e) {
|
|
1463
|
-
console.warn(`Indexer requests failed: ${e}. Retrying without indexer..`);
|
|
1464
|
-
return await method.apply(context, [...args.slice(0, -1), false]);
|
|
1465
|
-
}
|
|
1466
|
-
}
|
|
1467
|
-
return await method.apply(context, args);
|
|
1468
|
-
}
|
|
1469
|
-
function withIndexerFallback(method) {
|
|
1470
|
-
return (...args) => {
|
|
1471
|
-
return callMethodWithIndexerFallback(method, this, ...args);
|
|
1472
|
-
};
|
|
1473
|
-
}
|
|
1474
|
-
|
|
1475
|
-
// src/models/scallopCache.ts
|
|
1476
|
-
var ScallopCache = class {
|
|
1477
|
-
constructor(suiKit, walletAddress, cacheOptions, tokenBucket, queryClient) {
|
|
1478
|
-
this.queryClient = queryClient ?? new QueryClient(cacheOptions ?? DEFAULT_CACHE_OPTIONS);
|
|
1479
|
-
this._suiKit = suiKit;
|
|
1480
|
-
this.tokenBucket = tokenBucket ?? new TokenBucket(DEFAULT_TOKENS_PER_INTERVAL, DEFAULT_INTERVAL_IN_MS);
|
|
1481
|
-
this.walletAddress = walletAddress ?? suiKit.currentAddress();
|
|
1482
|
-
}
|
|
1483
|
-
get suiKit() {
|
|
1484
|
-
if (!this._suiKit) {
|
|
1485
|
-
throw new Error("SuiKit instance is not initialized");
|
|
1486
|
-
}
|
|
1487
|
-
return this._suiKit;
|
|
1488
|
-
}
|
|
1489
|
-
get client() {
|
|
1490
|
-
return this.suiKit.client();
|
|
1491
|
-
}
|
|
1492
|
-
/**
|
|
1493
|
-
* @description Invalidate cache based on the refetchType parameter
|
|
1494
|
-
* @param refetchType Determines the type of queries to be refetched. Defaults to `active`.
|
|
1495
|
-
*
|
|
1496
|
-
* - `active`: Only queries that match the refetch predicate and are actively being rendered via useQuery and related functions will be refetched in the background.
|
|
1497
|
-
* - `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.
|
|
1498
|
-
* - `all`: All queries that match the refetch predicate will be refetched in the background.
|
|
1499
|
-
* - `none`: No queries will be refetched. Queries that match the refetch predicate will only be marked as invalid.
|
|
1500
|
-
*/
|
|
1501
|
-
async invalidateAllCache() {
|
|
1502
|
-
return Object.values(queryKeys.rpc).map(
|
|
1503
|
-
(t) => this.queryClient.invalidateQueries({
|
|
1504
|
-
queryKey: t(),
|
|
1505
|
-
type: "all"
|
|
1506
|
-
})
|
|
1507
|
-
);
|
|
1508
|
-
}
|
|
1509
|
-
/**
|
|
1510
|
-
* @description Provides cache for inspectTxn of the SuiKit.
|
|
1511
|
-
* @param QueryInspectTxnParams
|
|
1512
|
-
* @param txBlock
|
|
1513
|
-
* @returns Promise<DevInspectResults>
|
|
1514
|
-
*/
|
|
1515
|
-
async queryInspectTxn({
|
|
1516
|
-
queryTarget,
|
|
1517
|
-
args,
|
|
1518
|
-
typeArgs
|
|
1519
|
-
}) {
|
|
1520
|
-
const txBlock = new SuiTxBlock();
|
|
1521
|
-
txBlock.moveCall(queryTarget, args, typeArgs);
|
|
1522
|
-
const query = await this.queryClient.fetchQuery({
|
|
1523
|
-
queryKey: queryKeys.rpc.getInspectTxn(queryTarget, args, typeArgs),
|
|
1524
|
-
queryFn: async () => {
|
|
1525
|
-
return await callWithRateLimit(
|
|
1526
|
-
this.tokenBucket,
|
|
1527
|
-
() => this.suiKit.inspectTxn(txBlock)
|
|
1528
|
-
);
|
|
1529
|
-
}
|
|
1530
|
-
});
|
|
1531
|
-
return query;
|
|
1532
|
-
}
|
|
1533
|
-
/**
|
|
1534
|
-
* @description Provides cache for getObject of the SuiKit.
|
|
1535
|
-
* @param objectId
|
|
1536
|
-
* @param QueryObjectParams
|
|
1537
|
-
* @returns Promise<SuiObjectResponse>
|
|
1538
|
-
*/
|
|
1539
|
-
async queryGetObject(objectId, options) {
|
|
1540
|
-
return this.queryClient.fetchQuery({
|
|
1541
|
-
queryKey: queryKeys.rpc.getObject(objectId, this.walletAddress, options),
|
|
1542
|
-
queryFn: async () => {
|
|
1543
|
-
return await callWithRateLimit(
|
|
1544
|
-
this.tokenBucket,
|
|
1545
|
-
() => this.client.getObject({
|
|
1546
|
-
id: objectId,
|
|
1547
|
-
options
|
|
1548
|
-
})
|
|
1549
|
-
);
|
|
1550
|
-
}
|
|
1551
|
-
});
|
|
1552
|
-
}
|
|
1553
|
-
/**
|
|
1554
|
-
* @description Provides cache for getObjects of the SuiKit.
|
|
1555
|
-
* @param objectIds
|
|
1556
|
-
* @returns Promise<SuiObjectData[]>
|
|
1557
|
-
*/
|
|
1558
|
-
async queryGetObjects(objectIds, options = {
|
|
1559
|
-
showContent: true
|
|
1560
|
-
}) {
|
|
1561
|
-
if (objectIds.length === 0)
|
|
1562
|
-
return [];
|
|
1563
|
-
return this.queryClient.fetchQuery({
|
|
1564
|
-
queryKey: queryKeys.rpc.getObjects(
|
|
1565
|
-
objectIds,
|
|
1566
|
-
this.walletAddress,
|
|
1567
|
-
options
|
|
1568
|
-
),
|
|
1569
|
-
queryFn: async () => {
|
|
1570
|
-
return await callWithRateLimit(
|
|
1571
|
-
this.tokenBucket,
|
|
1572
|
-
() => this.suiKit.getObjects(objectIds, options)
|
|
1573
|
-
);
|
|
1574
|
-
}
|
|
1575
|
-
});
|
|
1576
|
-
}
|
|
1577
|
-
/**
|
|
1578
|
-
* @description Provides cache for getOwnedObjects of the SuiKit.
|
|
1579
|
-
* @param input
|
|
1580
|
-
* @returns Promise<PaginatedObjectsResponse>
|
|
1581
|
-
*/
|
|
1582
|
-
async queryGetOwnedObjects(input) {
|
|
1583
|
-
return this.queryClient.fetchQuery({
|
|
1584
|
-
queryKey: queryKeys.rpc.getOwnedObjects(input),
|
|
1585
|
-
queryFn: async () => {
|
|
1586
|
-
return await callWithRateLimit(
|
|
1587
|
-
this.tokenBucket,
|
|
1588
|
-
() => this.client.getOwnedObjects(input)
|
|
1589
|
-
);
|
|
1590
|
-
}
|
|
1591
|
-
});
|
|
1592
|
-
}
|
|
1593
|
-
async queryGetDynamicFields(input) {
|
|
1594
|
-
return this.queryClient.fetchQuery({
|
|
1595
|
-
queryKey: queryKeys.rpc.getDynamicFields(input),
|
|
1596
|
-
queryFn: async () => {
|
|
1597
|
-
return await callWithRateLimit(
|
|
1598
|
-
this.tokenBucket,
|
|
1599
|
-
() => this.client.getDynamicFields(input)
|
|
1600
|
-
);
|
|
1390
|
+
},
|
|
1391
|
+
oracles: {
|
|
1392
|
+
xOracle: "0x93d5bf0936b71eb27255941e532fac33b5a5c7759e377b4923af0a1359ad494f",
|
|
1393
|
+
xOracleCap: "0x1edeae568fde99e090dbdec4bcdbd33a15f53a1ce1f87aeef1a560dedf4b4a90",
|
|
1394
|
+
supra: { registry: "", registryCap: "", holder: "" },
|
|
1395
|
+
switchboard: { registry: "", registryCap: "" },
|
|
1396
|
+
pyth: {
|
|
1397
|
+
registry: "0xedc293f9413a5a7a5d53bdba1fd889d0a4030894469228f0acdae4aa3c55a213",
|
|
1398
|
+
registryCap: "0xbcb07141eb1f7e01fbda4130ecf5f5adaeabb77f5d9c32158b7532bcd2197acd",
|
|
1399
|
+
state: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8",
|
|
1400
|
+
wormhole: "0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a",
|
|
1401
|
+
wormholeState: "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c"
|
|
1601
1402
|
}
|
|
1602
|
-
}
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1403
|
+
},
|
|
1404
|
+
packages: {
|
|
1405
|
+
coinDecimalsRegistry: {
|
|
1406
|
+
id: "0xca5a5a62f01c79a104bf4d31669e29daa387f325c241de4edbe30986a9bc8b0d",
|
|
1407
|
+
upgradeCap: "0x34e76a945d29f195bc53ca704fa70877d1cf3a5d7bbfdda1b13e633fff13c0f6"
|
|
1408
|
+
},
|
|
1409
|
+
math: {
|
|
1410
|
+
id: "0xad013d5fde39e15eabda32b3dbdafd67dac32b798ce63237c27a8f73339b9b6f",
|
|
1411
|
+
upgradeCap: "0x3a329598231de02e6135c62284b66005b41cad1d9ab7ca2dc79c08293aba2ec6"
|
|
1412
|
+
},
|
|
1413
|
+
whitelist: {
|
|
1414
|
+
id: "0x1318fdc90319ec9c24df1456d960a447521b0a658316155895014a6e39b5482f",
|
|
1415
|
+
upgradeCap: "0xf5a22aea23db664f7b69855b6a546747f17c1ec4230319cfc17225e462b05761"
|
|
1416
|
+
},
|
|
1417
|
+
x: {
|
|
1418
|
+
id: "0x779b5c547976899f5474f3a5bc0db36ddf4697ad7e5a901db0415c2281d28162",
|
|
1419
|
+
upgradeCap: "0x3f203f6fff6a69d151e4f1cd931f22b68c489ef2759765662fc7baf673943c9e"
|
|
1420
|
+
},
|
|
1421
|
+
protocol: {
|
|
1422
|
+
id: "0x87ddec2984645dbbe2403a509cc6edf393a43acdba9b77d45da2bcbefcf733c1",
|
|
1423
|
+
upgradeCap: "0x38527d154618d1fd5a644b90717fe07cf0e9f26b46b63e9568e611a3f86d5c1a"
|
|
1424
|
+
},
|
|
1425
|
+
// protocol: {
|
|
1426
|
+
// id: '0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e',
|
|
1427
|
+
// upgradeCap:
|
|
1428
|
+
// '0x38527d154618d1fd5a644b90717fe07cf0e9f26b46b63e9568e611a3f86d5c1a',
|
|
1429
|
+
// },
|
|
1430
|
+
protocolWhitelist: {
|
|
1431
|
+
id: "0x4c262d9343dac53ecb28f482a2a3f62c73d0ebac5b5f03d57383d56ff219acdf",
|
|
1432
|
+
upgradeCap: "0x4a5e88a75039b00988f633f811f58117f31b8627a46bf822aa114d9010049449"
|
|
1433
|
+
},
|
|
1434
|
+
// query: {
|
|
1435
|
+
// id: '0xb8d603a39114a5efef3dd0bf84df0bed1be1fbd39b78b7dd6e8a61ccc5e6006f',
|
|
1436
|
+
// upgradeCap:
|
|
1437
|
+
// '0x0d535c35f608b9b01b7ccce11acf43b1dd80c1b72bf8b541744a6e28e8d2745f',
|
|
1438
|
+
// },
|
|
1439
|
+
query: {
|
|
1440
|
+
id: "0xe4f9d62d17746d5b9dbf0d5557747430021a71575780b515161210cdba0a4c1c",
|
|
1441
|
+
upgradeCap: "0x0d535c35f608b9b01b7ccce11acf43b1dd80c1b72bf8b541744a6e28e8d2745f"
|
|
1442
|
+
},
|
|
1443
|
+
supra: { id: "", upgradeCap: "" },
|
|
1444
|
+
pyth: {
|
|
1445
|
+
id: "0x910f30cbc7f601f75a5141a01265cd47c62d468707c5e1aecb32a18f448cb25a",
|
|
1446
|
+
upgradeCap: "0xdf0ffbae1ea5bb25fbca5efba433dcf00c7cced65679af2f04728901275c6157"
|
|
1447
|
+
},
|
|
1448
|
+
switchboard: { id: "", upgradeCap: "" },
|
|
1449
|
+
xOracle: {
|
|
1450
|
+
id: "0x1478a432123e4b3d61878b629f2c692969fdb375644f1251cd278a4b1e7d7cd6",
|
|
1451
|
+
upgradeCap: "0x0f928a6b2e26b73330fecaf9b44acfc9800a4a9794d6415c2a3153bc70e3c1f0"
|
|
1452
|
+
},
|
|
1453
|
+
testCoin: { id: "", upgradeCap: "" }
|
|
1454
|
+
}
|
|
1455
|
+
},
|
|
1456
|
+
spool: {
|
|
1457
|
+
// id: '0x7c4fdabe81c31b19a45d1e572a52a539997a90903fbb5bfab71480abe0fa62c3',
|
|
1458
|
+
id: "0x1742655fe5872dfa6456673f9e38612a4965e6979e6cd7696a7f1225f28bae21",
|
|
1459
|
+
adminCap: "0xdd8a047cbbf802bfcde5288b8ef1910965d789cc614da11d39af05fca0bd020a",
|
|
1460
|
+
// object:
|
|
1461
|
+
// '0xe87f1b2d498106a2c61421cec75b7b5c5e348512b0dc263949a0e7a3c256571a',
|
|
1462
|
+
object: "0x1742655fe5872dfa6456673f9e38612a4965e6979e6cd7696a7f1225f28bae21",
|
|
1463
|
+
pools: {
|
|
1464
|
+
sweth: {
|
|
1465
|
+
id: "0xeec40beccb07c575bebd842eeaabb835f77cd3dab73add433477e57f583a6787",
|
|
1466
|
+
rewardPoolId: "0x957de68a18d87817de8309b30c1ec269a4d87ae513abbeed86b5619cb9ce1077"
|
|
1467
|
+
},
|
|
1468
|
+
ssui: {
|
|
1469
|
+
// id: '0x4f0ba970d3c11db05c8f40c64a15b6a33322db3702d634ced6536960ab6f3ee4',
|
|
1470
|
+
id: "0xb9617f83c06ebdeac0a8834782b1015e1cc7ea23739e30c132c4bfb95c37a579",
|
|
1471
|
+
rewardPoolId: (
|
|
1472
|
+
// '0x162250ef72393a4ad3d46294c4e1bdfcb03f04c869d390e7efbfc995353a7ee9',
|
|
1473
|
+
"0xc3206071a8d43212efb6e3b5504f2321f8df97ab122b466c0bc7cfdf398dc13a"
|
|
1474
|
+
)
|
|
1475
|
+
},
|
|
1476
|
+
swusdc: {
|
|
1477
|
+
// id: '0x4ace6648ddc64e646ba47a957c562c32c9599b3bba8f5ac1aadb2ae23a2f8ca0',
|
|
1478
|
+
id: "0xf1b383b9cf2e9f515fc69567df1053098f273849d09cd84b0278a773429bd2b2",
|
|
1479
|
+
rewardPoolId: (
|
|
1480
|
+
// '0xf4268cc9b9413b9bfe09e8966b8de650494c9e5784bf0930759cfef4904daff8',
|
|
1481
|
+
"0xc71c53ee6505d928ba15bea4fe4f45d98c9c31eced94b72d00a7827d4b7ba3ff"
|
|
1482
|
+
)
|
|
1483
|
+
},
|
|
1484
|
+
swusdt: {
|
|
1485
|
+
// id: '0xcb328f7ffa7f9342ed85af3fdb2f22919e1a06dfb2f713c04c73543870d7548f',
|
|
1486
|
+
id: "0xb5567dfa5c7fc17a249e959732664c50713dd8c23db1a11376b27df800c17418",
|
|
1487
|
+
rewardPoolId: (
|
|
1488
|
+
// '0x2c9f934d67a5baa586ceec2cc24163a2f049a6af3d5ba36b84d8ac40f25c4080',
|
|
1489
|
+
"0x60768b0687ff0235e376a039709a683e4c436098785e473b67b32dbab47b69ab"
|
|
1490
|
+
)
|
|
1491
|
+
},
|
|
1492
|
+
scetus: {
|
|
1493
|
+
id: "0xac1bb13bf4472a637c18c2415fb0e3c1227ea2bcf35242e50563c98215bd298e",
|
|
1494
|
+
rewardPoolId: "0x6835c1224126a45086fc6406adc249e3f30df18d779ca4f4e570e38716a17f3f"
|
|
1495
|
+
},
|
|
1496
|
+
safsui: {
|
|
1497
|
+
// id: '0xeedf438abcaa6ce4d9625ffca110920592d5867e4c5637d84ad9f466c4feb800',
|
|
1498
|
+
id: "0xc568bb4c991258e839aa54802ecda04fcd9838c826bc3b42b40af81b23c458c8",
|
|
1499
|
+
rewardPoolId: (
|
|
1500
|
+
// '0x89255a2f86ed7fbfef35ab8b7be48cc7667015975be2685dd9a55a9a64baf76e',
|
|
1501
|
+
"0x389a3cbeda742b918941bb24fd00e077bad3367484394d6234f8209b9a6aa03d"
|
|
1502
|
+
)
|
|
1503
|
+
},
|
|
1504
|
+
shasui: {
|
|
1505
|
+
// id: '0xa6148bc1b623e936d39a952ceb5bea79e8b37228a8f595067bf1852efd3c34aa',
|
|
1506
|
+
id: "0x93f3f4499bf89f2d05ddc1f8b15f51701a7c6c4d0ac0b9c3bc99462cbbd8e321",
|
|
1507
|
+
rewardPoolId: (
|
|
1508
|
+
// '0x6f3563644d3e2ef13176dbf9d865bd93479df60ccbe07b7e66db57f6309f5a66',
|
|
1509
|
+
"0x94cee1be7f5ff34193f3aabef0b14142cb28af4d905fe487a9a7d85a15edb6aa"
|
|
1510
|
+
)
|
|
1511
|
+
},
|
|
1512
|
+
svsui: {
|
|
1513
|
+
// id: '0x69ce8e537e750a95381e6040794afa5ab1758353a1a2e1de7760391b01f91670',
|
|
1514
|
+
id: "0xa970e9087f80cb59e9299b8e7af7175d977ad6c9af0322aa4440e138fbd7ae00",
|
|
1515
|
+
rewardPoolId: (
|
|
1516
|
+
// '0xbca914adce058ad0902c7f3cfcd698392a475f00dcfdc3f76001d0370b98777a',
|
|
1517
|
+
"0x38eee9699c4fc132a6623e54b865f047df4fc6eb83af807300f44e8f4b235ff0"
|
|
1518
|
+
)
|
|
1612
1519
|
}
|
|
1613
|
-
}
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1520
|
+
},
|
|
1521
|
+
config: ""
|
|
1522
|
+
},
|
|
1523
|
+
borrowIncentive: {
|
|
1524
|
+
id: "0x6152f696fc3a658f33c4b891764731a59153125ffedfa8bff7167c42823f58a9",
|
|
1525
|
+
adminCap: "0xc486afa253646f4d381e81d7f1df8aa4723b845a6bb356f69bad635ffefffe2c",
|
|
1526
|
+
object: "0x002875153e09f8145ab63527bc85c00f2bd102e12f9573c47f8cdf1a1cb62934",
|
|
1527
|
+
query: "0x529edc54a3dce2207703ceebbccb0ac14133f7825c1f528775ba0d85a4063489",
|
|
1528
|
+
incentivePools: "0x6547e143d406b5ccd5f46aae482497de279cc1a68c406f701df70a05f9212ab4",
|
|
1529
|
+
incentiveAccounts: "0xc4701fdbc1c92f9a636d334d66012b3027659e9fb8aff27279a82edfb6b77d02",
|
|
1530
|
+
config: "0xdf5d04b4691cc67e82fd4db8394d89ff44823a9de29716c924f74bb4f11cc1f7"
|
|
1531
|
+
},
|
|
1532
|
+
referral: {
|
|
1533
|
+
id: "0xa3654ebb63eb06c0f4ff52f8aa6512df9f164f7772bdf15dac3709bd3798dda9",
|
|
1534
|
+
object: "0x5658d4bf5ddcba27e4337b4262108b3ad1716643cac8c2054ac341538adc72ec",
|
|
1535
|
+
adminCap: "0xc5dc06b9074291259f2cac460c940012c781c4430e42125c541cc43101c3bcbd",
|
|
1536
|
+
referralBindings: "0xf63299d58789d99de94092b9011323466e55ca0c1ea1a7a3786a589af46e1c09",
|
|
1537
|
+
bindingTableId: "0x1c8202b17267ec8d6cf97ca013615354181a04f179570e42601ff2dae19294b1",
|
|
1538
|
+
referralRevenuePool: "0x6abd852caf90769c1b185cdf636d841673fa95528f0550f018b8a138bd283c07",
|
|
1539
|
+
revenueTableId: "0x595baa3654c297bff84ab7786a2d250f019cefc66e8df8e89fd9d41e02bd30dd",
|
|
1540
|
+
referralTiers: "0x962cb903d8d7346190c5204785ccbb91b61086aa764f674c8145df82335cf83e",
|
|
1541
|
+
tiersTableId: "0xeac755a7a8b7798530905ac79e8c114f19d0f130f6eab012954f08faac29c75d",
|
|
1542
|
+
// authorizedWitnessList:
|
|
1543
|
+
// '0xf21b0ed043c9bb70842c0129159f4943dbcc3c9ef2f2f808af65f8be25cfd20e',
|
|
1544
|
+
authorizedWitnessList: "0x9d6223dc52015b8a3986a573590ef2af8f1b8f3e4685513888c052f001b87e7f",
|
|
1545
|
+
version: "0x1bd4b7285f72e11c316b828c7c47b3f4da18dcec9f9b3dba6d8629cbb6f93e5e"
|
|
1546
|
+
},
|
|
1547
|
+
vesca: {
|
|
1548
|
+
id: "0xb15b6e0cdd85afb5028bea851dd249405e734d800a259147bbc24980629723a4",
|
|
1549
|
+
object: "0xb15b6e0cdd85afb5028bea851dd249405e734d800a259147bbc24980629723a4",
|
|
1550
|
+
adminCap: "0x8ffa76135c5b85c5fbd73a6448a4a733d826cb63a267ab817656acb77c72d4a5",
|
|
1551
|
+
tableId: "0xe3153b2bf124be0b86cb8bd468346a861efd0da52fc42197b54d2f616488a311",
|
|
1552
|
+
table: "0x611cb8d9d4d90867467b5ebdf4cc447a0047ed5b01334a28a29fcfe733e3d609",
|
|
1553
|
+
treasury: "0xe8c112c09b88158dc6c8e23d1fbae5b3c7136cdee54b7dafc08e65db28c4a5bc",
|
|
1554
|
+
config: "0xe0a2ff281e73c1d53cfa85807080f87e833e4f1a7f93dcf8800b3865269a76b9"
|
|
1555
|
+
},
|
|
1556
|
+
loyaltyProgram: {
|
|
1557
|
+
id: "0xd17bcf8b5a59652c36225d478564a8593ae0ed7d650bcacdda1d6fe179127907",
|
|
1558
|
+
object: "0xd17bcf8b5a59652c36225d478564a8593ae0ed7d650bcacdda1d6fe179127907",
|
|
1559
|
+
rewardPool: "0xf9c090492ef476bd542109d0913ffe871cbfa28578b7114eca2a8c0e5671786f",
|
|
1560
|
+
userRewardTableId: "0x748a80395849ed37db1b0e14f2ab5d1d96458d2359ab3a84eb079d0f4ac7cf2e"
|
|
1561
|
+
},
|
|
1562
|
+
scoin: {
|
|
1563
|
+
id: "0xad2ca2aa5089df94bb2d444d5eb3520378c2f2dfb3a0bd2a2c994145ac4b0a53",
|
|
1564
|
+
coins: {
|
|
1565
|
+
ssui: {
|
|
1566
|
+
coinType: "0xfac769100bccc0caebcf4f4e2d00ac2f8883f07f724be28940df90605f5e7e9a::scallop_sui::SCALLOP_SUI",
|
|
1567
|
+
treasury: "0x9cb4551b36c17d37e19d700147fa819ea1c487ff8bcf18374de2cceb2e9d4845"
|
|
1568
|
+
},
|
|
1569
|
+
scetus: {
|
|
1570
|
+
coinType: "0x8b71e6d323ed78515af2bead13bf3d0da1562ba4a99234eb7c4f14fd39ef0427::scallop_cetus::SCALLOP_CETUS",
|
|
1571
|
+
treasury: "0xd786f4b2d26278cc7911a3445b1b085eab60f269ef9dbb6b87e803d52f155003"
|
|
1572
|
+
},
|
|
1573
|
+
ssca: {
|
|
1574
|
+
coinType: "0x0a9d3c6c9af9f6e8def82921541bcbd17f73ed31bed3adcb684f2a4c267e42f0::scallop_sca::SCALLOP_SCA",
|
|
1575
|
+
treasury: "0xe818636d1d6c46d6ea1a2dce9d94696d7cbc18ce27451b603eeaa47aba8d75e0"
|
|
1576
|
+
},
|
|
1577
|
+
swusdc: {
|
|
1578
|
+
coinType: "0xaedc3ab75db8680b81a755015fa90124d217be93457b893c05bac033817defaf::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC",
|
|
1579
|
+
treasury: "0xfc6971648f867f7fd6928d1b873af71577e2eaf2c7543ef8bc82c431d833ae78"
|
|
1580
|
+
},
|
|
1581
|
+
swusdt: {
|
|
1582
|
+
coinType: "0xbf02fc87ddc104b342ad8414c85ceadf5b0c823c055a06fb0ed776272c01a52a::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT",
|
|
1583
|
+
treasury: "0xb9593e2c3a0ba796ee815012b75ae46468ea78cda0188b9ac6816efe65503521"
|
|
1584
|
+
},
|
|
1585
|
+
sweth: {
|
|
1586
|
+
coinType: "0x27d54f43e3eda701be56b82e5756e41c84467cd202f5cf713d5f9e45a9f1b6bc::scallop_wormhole_eth::SCALLOP_WORMHOLE_ETH",
|
|
1587
|
+
treasury: "0x032b4c8fac94c038dbe986f7587e9b1e4ef580b5ee06d2ef249d85459b7ef05d"
|
|
1588
|
+
},
|
|
1589
|
+
safsui: {
|
|
1590
|
+
coinType: "0xb75b46d975d8d80670b53a6bee90baaa8ce2e0b7d397f079447d641eef6b44ad::scallop_af_sui::SCALLOP_AF_SUI",
|
|
1591
|
+
treasury: "0x21450ef0570ef3d224ffa3b873ab802e439ece7b93cc7efad10ae0c1e3b3fcfe"
|
|
1592
|
+
},
|
|
1593
|
+
shasui: {
|
|
1594
|
+
coinType: "0xd973a723874e2c7cde196602a79155a1343a933f8cf87d9b1bb7408bc1acbc58::scallop_ha_sui::SCALLOP_HA_SUI",
|
|
1595
|
+
treasury: "0xf822fc1402207e47d2e3ba8ff6e1e594bf1de777dc5ebd2744619cd2726e3b0d"
|
|
1596
|
+
},
|
|
1597
|
+
svsui: {
|
|
1598
|
+
coinType: "0x97023a317320c4498cc4cd239dd02fd30c28246e5e8f81325d63f2bd8d70f6b3::scallop_v_sui::SCALLOP_V_SUI",
|
|
1599
|
+
treasury: "0x327114f0bf3559d7e2de10282147ed76a236c7c6775029165c4db09a6062ead6\u0192"
|
|
1635
1600
|
}
|
|
1636
|
-
}
|
|
1637
|
-
}
|
|
1638
|
-
async queryGetCoinBalance(input) {
|
|
1639
|
-
if (!input.coinType)
|
|
1640
|
-
return "0";
|
|
1641
|
-
return (await this.queryGetAllCoinBalances(input.owner) || {})[normalizeStructTag2(input.coinType)] ?? "0";
|
|
1601
|
+
}
|
|
1642
1602
|
}
|
|
1643
1603
|
};
|
|
1644
1604
|
|
|
1645
1605
|
// src/models/scallopAddress.ts
|
|
1646
|
-
import axios from "axios";
|
|
1647
1606
|
var EMPTY_ADDRESSES = {
|
|
1648
1607
|
core: {
|
|
1649
1608
|
version: "",
|
|
@@ -2289,153 +2248,70 @@ var ScallopAddress = class {
|
|
|
2289
2248
|
headers: {
|
|
2290
2249
|
"Content-Type": "application/json",
|
|
2291
2250
|
"api-key": auth || this._auth
|
|
2292
|
-
}
|
|
2293
|
-
}
|
|
2294
|
-
);
|
|
2295
|
-
if (response.status === 200) {
|
|
2296
|
-
this._id = void 0;
|
|
2297
|
-
this._currentAddresses = void 0;
|
|
2298
|
-
this._addressesMap.clear();
|
|
2299
|
-
} else {
|
|
2300
|
-
throw Error("Failed to delete addresses.");
|
|
2301
|
-
}
|
|
2302
|
-
} else {
|
|
2303
|
-
throw Error("You don't have permission to access this request.");
|
|
2304
|
-
}
|
|
2305
|
-
}
|
|
2306
|
-
};
|
|
2307
|
-
|
|
2308
|
-
// src/models/scallopClient.ts
|
|
2309
|
-
import { normalizeSuiAddress as normalizeSuiAddress3 } from "@mysten/sui/utils";
|
|
2310
|
-
import { SuiKit as SuiKit6 } from "@scallop-io/sui-kit";
|
|
2311
|
-
|
|
2312
|
-
// src/models/scallopUtils.ts
|
|
2313
|
-
import { SUI_TYPE_ARG, normalizeStructTag as normalizeStructTag6 } from "@mysten/sui/utils";
|
|
2314
|
-
import { SuiKit as SuiKit2 } from "@scallop-io/sui-kit";
|
|
2315
|
-
import { SuiPriceServiceConnection } from "@pythnetwork/pyth-sui-js";
|
|
2316
|
-
|
|
2317
|
-
// src/queries/coreQuery.ts
|
|
2318
|
-
import { normalizeStructTag as normalizeStructTag3 } from "@mysten/sui/utils";
|
|
2319
|
-
import BigNumber2 from "bignumber.js";
|
|
2320
|
-
|
|
2321
|
-
// src/queries/supplyLimit.ts
|
|
2322
|
-
import { z as zod } from "zod";
|
|
2323
|
-
var supplyLimitZod = zod.object({
|
|
2324
|
-
dataType: zod.string(),
|
|
2325
|
-
type: zod.string(),
|
|
2326
|
-
hasPublicTransfer: zod.boolean(),
|
|
2327
|
-
fields: zod.object({
|
|
2328
|
-
id: zod.object({
|
|
2329
|
-
id: zod.string()
|
|
2330
|
-
}),
|
|
2331
|
-
name: zod.object({
|
|
2332
|
-
type: zod.string()
|
|
2333
|
-
}),
|
|
2334
|
-
value: zod.string()
|
|
2335
|
-
})
|
|
2336
|
-
});
|
|
2337
|
-
var SUPPLY_LIMIT_KEY = "0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e::market_dynamic_keys::SupplyLimitKey";
|
|
2338
|
-
var getSupplyLimit = async (utils, poolName) => {
|
|
2339
|
-
const poolCoinType = utils.parseCoinType(poolName).slice(2);
|
|
2340
|
-
const marketObject = utils.address.get("core.market");
|
|
2341
|
-
if (!marketObject)
|
|
2342
|
-
return null;
|
|
2343
|
-
const object = await utils.cache.queryGetDynamicFieldObject({
|
|
2344
|
-
parentId: marketObject,
|
|
2345
|
-
name: {
|
|
2346
|
-
type: SUPPLY_LIMIT_KEY,
|
|
2347
|
-
value: poolCoinType
|
|
2348
|
-
}
|
|
2349
|
-
});
|
|
2350
|
-
const parsedData = supplyLimitZod.safeParse(object?.data?.content);
|
|
2351
|
-
if (!parsedData.success)
|
|
2352
|
-
return null;
|
|
2353
|
-
return parsedData.data.fields.value;
|
|
2354
|
-
};
|
|
2355
|
-
|
|
2356
|
-
// src/queries/isolatedAsset.ts
|
|
2357
|
-
import { z as zod2 } from "zod";
|
|
2358
|
-
var isolatedAssetZod = zod2.object({
|
|
2359
|
-
dataType: zod2.string(),
|
|
2360
|
-
type: zod2.string(),
|
|
2361
|
-
hasPublicTransfer: zod2.boolean(),
|
|
2362
|
-
fields: zod2.object({
|
|
2363
|
-
id: zod2.object({
|
|
2364
|
-
id: zod2.string()
|
|
2365
|
-
}),
|
|
2366
|
-
name: zod2.object({
|
|
2367
|
-
type: zod2.string()
|
|
2368
|
-
}),
|
|
2369
|
-
value: zod2.boolean()
|
|
2370
|
-
})
|
|
2371
|
-
});
|
|
2372
|
-
var getIsolatedAssets = async (address) => {
|
|
2373
|
-
try {
|
|
2374
|
-
const marketObject = address.get("core.market");
|
|
2375
|
-
const protocolObject = address.get("core.packages.protocol.id");
|
|
2376
|
-
const ISOLATED_ASSET_KEY = `${protocolObject}::market_dynamic_keys::IsolatedAssetKey`;
|
|
2377
|
-
const isolatedAssets = [];
|
|
2378
|
-
if (!marketObject)
|
|
2379
|
-
return isolatedAssets;
|
|
2380
|
-
let hasNextPage = false;
|
|
2381
|
-
let nextCursor = null;
|
|
2382
|
-
const isIsolatedDynamicField = (dynamicField) => {
|
|
2383
|
-
return dynamicField.name.type === ISOLATED_ASSET_KEY;
|
|
2384
|
-
};
|
|
2385
|
-
do {
|
|
2386
|
-
const response = await address.cache.queryGetDynamicFields({
|
|
2387
|
-
parentId: marketObject,
|
|
2388
|
-
cursor: nextCursor,
|
|
2389
|
-
limit: 10
|
|
2390
|
-
});
|
|
2391
|
-
if (!response)
|
|
2392
|
-
break;
|
|
2393
|
-
const isolatedAssetCoinTypes = response.data.filter(isIsolatedDynamicField).map(({ name }) => `0x${name.value.type.name}`);
|
|
2394
|
-
isolatedAssets.push(...isolatedAssetCoinTypes);
|
|
2395
|
-
if (response && response.hasNextPage && response.nextCursor) {
|
|
2396
|
-
hasNextPage = true;
|
|
2397
|
-
nextCursor = response.nextCursor;
|
|
2398
|
-
} else {
|
|
2399
|
-
hasNextPage = false;
|
|
2400
|
-
}
|
|
2401
|
-
} while (hasNextPage);
|
|
2402
|
-
return isolatedAssets;
|
|
2403
|
-
} catch (e) {
|
|
2404
|
-
console.error(e);
|
|
2405
|
-
return [];
|
|
2406
|
-
}
|
|
2407
|
-
};
|
|
2408
|
-
var isIsolatedAsset = async (utils, coinName) => {
|
|
2409
|
-
try {
|
|
2410
|
-
const marketObject = utils.address.get("core.market");
|
|
2411
|
-
const protocolObject = utils.address.get("core.packages.protocol.id");
|
|
2412
|
-
const ISOLATED_ASSET_KEY = `${protocolObject}::market_dynamic_keys::IsolatedAssetKey`;
|
|
2413
|
-
const cachedData = utils.address.cache.queryClient.getQueryData([
|
|
2414
|
-
"getDynamicFields",
|
|
2415
|
-
marketObject
|
|
2416
|
-
]);
|
|
2417
|
-
if (cachedData) {
|
|
2418
|
-
const coinType2 = utils.parseCoinType(coinName);
|
|
2419
|
-
return cachedData.includes(coinType2);
|
|
2420
|
-
}
|
|
2421
|
-
const coinType = utils.parseCoinType(coinName).slice(2);
|
|
2422
|
-
const object = await utils.cache.queryGetDynamicFieldObject({
|
|
2423
|
-
parentId: marketObject,
|
|
2424
|
-
name: {
|
|
2425
|
-
type: ISOLATED_ASSET_KEY,
|
|
2426
|
-
value: coinType
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
);
|
|
2254
|
+
if (response.status === 200) {
|
|
2255
|
+
this._id = void 0;
|
|
2256
|
+
this._currentAddresses = void 0;
|
|
2257
|
+
this._addressesMap.clear();
|
|
2258
|
+
} else {
|
|
2259
|
+
throw Error("Failed to delete addresses.");
|
|
2427
2260
|
}
|
|
2428
|
-
}
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
return false;
|
|
2432
|
-
return parsedData.data.fields.value;
|
|
2433
|
-
} catch (e) {
|
|
2434
|
-
console.error(e);
|
|
2435
|
-
return false;
|
|
2261
|
+
} else {
|
|
2262
|
+
throw Error("You don't have permission to access this request.");
|
|
2263
|
+
}
|
|
2436
2264
|
}
|
|
2437
2265
|
};
|
|
2438
2266
|
|
|
2267
|
+
// src/models/scallopClient.ts
|
|
2268
|
+
import { normalizeSuiAddress as normalizeSuiAddress3 } from "@mysten/sui/utils";
|
|
2269
|
+
import { SuiKit as SuiKit6 } from "@scallop-io/sui-kit";
|
|
2270
|
+
|
|
2271
|
+
// src/models/scallopUtils.ts
|
|
2272
|
+
import { SUI_TYPE_ARG, normalizeStructTag as normalizeStructTag6 } from "@mysten/sui/utils";
|
|
2273
|
+
import { SuiKit as SuiKit2 } from "@scallop-io/sui-kit";
|
|
2274
|
+
import { SuiPriceServiceConnection } from "@pythnetwork/pyth-sui-js";
|
|
2275
|
+
|
|
2276
|
+
// src/queries/coreQuery.ts
|
|
2277
|
+
import { normalizeStructTag as normalizeStructTag3 } from "@mysten/sui/utils";
|
|
2278
|
+
import BigNumber2 from "bignumber.js";
|
|
2279
|
+
|
|
2280
|
+
// src/queries/supplyLimit.ts
|
|
2281
|
+
import { z as zod } from "zod";
|
|
2282
|
+
var supplyLimitZod = zod.object({
|
|
2283
|
+
dataType: zod.string(),
|
|
2284
|
+
type: zod.string(),
|
|
2285
|
+
hasPublicTransfer: zod.boolean(),
|
|
2286
|
+
fields: zod.object({
|
|
2287
|
+
id: zod.object({
|
|
2288
|
+
id: zod.string()
|
|
2289
|
+
}),
|
|
2290
|
+
name: zod.object({
|
|
2291
|
+
type: zod.string()
|
|
2292
|
+
}),
|
|
2293
|
+
value: zod.string()
|
|
2294
|
+
})
|
|
2295
|
+
});
|
|
2296
|
+
var SUPPLY_LIMIT_KEY = "0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e::market_dynamic_keys::SupplyLimitKey";
|
|
2297
|
+
var getSupplyLimit = async (utils, poolName) => {
|
|
2298
|
+
const poolCoinType = utils.parseCoinType(poolName).slice(2);
|
|
2299
|
+
const marketObject = utils.address.get("core.market");
|
|
2300
|
+
if (!marketObject)
|
|
2301
|
+
return null;
|
|
2302
|
+
const object = await utils.cache.queryGetDynamicFieldObject({
|
|
2303
|
+
parentId: marketObject,
|
|
2304
|
+
name: {
|
|
2305
|
+
type: SUPPLY_LIMIT_KEY,
|
|
2306
|
+
value: poolCoinType
|
|
2307
|
+
}
|
|
2308
|
+
});
|
|
2309
|
+
const parsedData = supplyLimitZod.safeParse(object?.data?.content);
|
|
2310
|
+
if (!parsedData.success)
|
|
2311
|
+
return null;
|
|
2312
|
+
return parsedData.data.fields.value;
|
|
2313
|
+
};
|
|
2314
|
+
|
|
2439
2315
|
// src/queries/coreQuery.ts
|
|
2440
2316
|
var queryMarket = async (query, indexer = false) => {
|
|
2441
2317
|
const coinPrices = await query.utils.getCoinPrices();
|
|
@@ -2520,8 +2396,8 @@ var queryMarket = async (query, indexer = false) => {
|
|
|
2520
2396
|
borrowFee: parsedMarketPoolData.borrowFee,
|
|
2521
2397
|
marketCoinSupplyAmount: parsedMarketPoolData.marketCoinSupplyAmount,
|
|
2522
2398
|
minBorrowAmount: parsedMarketPoolData.minBorrowAmount,
|
|
2523
|
-
isIsolated: await isIsolatedAsset(query.utils, poolCoinName),
|
|
2524
|
-
|
|
2399
|
+
// isIsolated: await isIsolatedAsset(query.utils, poolCoinName),
|
|
2400
|
+
isIsolated: false,
|
|
2525
2401
|
maxSupplyCoin,
|
|
2526
2402
|
...calculatedMarketPoolData
|
|
2527
2403
|
};
|
|
@@ -2560,7 +2436,6 @@ var queryMarket = async (query, indexer = false) => {
|
|
|
2560
2436
|
liquidationDiscount: parsedMarketCollateralData.liquidationDiscount,
|
|
2561
2437
|
liquidationPanelty: parsedMarketCollateralData.liquidationPanelty,
|
|
2562
2438
|
liquidationReserveFactor: parsedMarketCollateralData.liquidationReserveFactor,
|
|
2563
|
-
isIsolated: await isIsolatedAsset(query.utils, collateralCoinName),
|
|
2564
2439
|
...calculatedMarketCollateralData
|
|
2565
2440
|
};
|
|
2566
2441
|
}
|
|
@@ -2608,73 +2483,79 @@ var getMarketPools = async (query, poolCoinNames = [...SUPPORT_POOLS], indexer =
|
|
|
2608
2483
|
return marketPools;
|
|
2609
2484
|
};
|
|
2610
2485
|
var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, coinPrice) => {
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2486
|
+
let marketPool;
|
|
2487
|
+
let balanceSheet;
|
|
2488
|
+
let borrowIndex;
|
|
2489
|
+
let interestModel;
|
|
2490
|
+
let borrowFeeRate;
|
|
2491
|
+
coinPrice = coinPrice || (await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName];
|
|
2492
|
+
if (indexer) {
|
|
2493
|
+
const marketPoolIndexer = await query.indexer.getMarketPool(poolCoinName);
|
|
2494
|
+
marketPoolIndexer.coinPrice = coinPrice || marketPoolIndexer.coinPrice;
|
|
2495
|
+
marketPoolIndexer.coinWrappedType = query.utils.getCoinWrappedType(
|
|
2496
|
+
marketPoolIndexer.coinName
|
|
2497
|
+
);
|
|
2498
|
+
return marketPoolIndexer;
|
|
2499
|
+
}
|
|
2500
|
+
const marketId = query.address.get("core.market");
|
|
2501
|
+
marketObject = marketObject || (await query.cache.queryGetObject(marketId, {
|
|
2502
|
+
showContent: true
|
|
2503
|
+
}))?.data;
|
|
2504
|
+
if (marketObject) {
|
|
2505
|
+
if (marketObject.content && "fields" in marketObject.content) {
|
|
2506
|
+
const fields = marketObject.content.fields;
|
|
2507
|
+
const coinType = query.utils.parseCoinType(poolCoinName);
|
|
2508
|
+
const balanceSheetParentId = fields.vault.fields.balance_sheets.fields.table.fields.id.id;
|
|
2509
|
+
const balanceSheetDynamicFieldObjectResponse = await query.cache.queryGetDynamicFieldObject({
|
|
2510
|
+
parentId: balanceSheetParentId,
|
|
2511
|
+
name: {
|
|
2512
|
+
type: "0x1::type_name::TypeName",
|
|
2513
|
+
value: {
|
|
2514
|
+
name: coinType.substring(2)
|
|
2515
|
+
}
|
|
2636
2516
|
}
|
|
2517
|
+
});
|
|
2518
|
+
if (!balanceSheetDynamicFieldObjectResponse)
|
|
2519
|
+
return void 0;
|
|
2520
|
+
const balanceSheetDynamicFieldObject = balanceSheetDynamicFieldObjectResponse.data;
|
|
2521
|
+
if (balanceSheetDynamicFieldObject && balanceSheetDynamicFieldObject.content && "fields" in balanceSheetDynamicFieldObject.content) {
|
|
2522
|
+
const dynamicFields = balanceSheetDynamicFieldObject.content.fields;
|
|
2523
|
+
balanceSheet = dynamicFields.value.fields;
|
|
2637
2524
|
}
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
const borrowIndexDynamicFieldObjectResponse = await query.cache.queryGetDynamicFieldObject({
|
|
2647
|
-
parentId: borrowIndexParentId,
|
|
2648
|
-
name: {
|
|
2649
|
-
type: "0x1::type_name::TypeName",
|
|
2650
|
-
value: {
|
|
2651
|
-
name: coinType.substring(2)
|
|
2525
|
+
const borrowIndexParentId = fields.borrow_dynamics.fields.table.fields.id.id;
|
|
2526
|
+
const borrowIndexDynamicFieldObjectResponse = await query.cache.queryGetDynamicFieldObject({
|
|
2527
|
+
parentId: borrowIndexParentId,
|
|
2528
|
+
name: {
|
|
2529
|
+
type: "0x1::type_name::TypeName",
|
|
2530
|
+
value: {
|
|
2531
|
+
name: coinType.substring(2)
|
|
2532
|
+
}
|
|
2652
2533
|
}
|
|
2534
|
+
});
|
|
2535
|
+
if (!borrowIndexDynamicFieldObjectResponse)
|
|
2536
|
+
return void 0;
|
|
2537
|
+
const borrowIndexDynamicFieldObject = borrowIndexDynamicFieldObjectResponse.data;
|
|
2538
|
+
if (borrowIndexDynamicFieldObject && borrowIndexDynamicFieldObject.content && "fields" in borrowIndexDynamicFieldObject.content) {
|
|
2539
|
+
const dynamicFields = borrowIndexDynamicFieldObject.content.fields;
|
|
2540
|
+
borrowIndex = dynamicFields.value.fields;
|
|
2653
2541
|
}
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
const interestModelDynamicFieldObjectResponse = await query.cache.queryGetDynamicFieldObject({
|
|
2663
|
-
parentId: interestModelParentId,
|
|
2664
|
-
name: {
|
|
2665
|
-
type: "0x1::type_name::TypeName",
|
|
2666
|
-
value: {
|
|
2667
|
-
name: coinType.substring(2)
|
|
2542
|
+
const interestModelParentId = fields.interest_models.fields.table.fields.id.id;
|
|
2543
|
+
const interestModelDynamicFieldObjectResponse = await query.cache.queryGetDynamicFieldObject({
|
|
2544
|
+
parentId: interestModelParentId,
|
|
2545
|
+
name: {
|
|
2546
|
+
type: "0x1::type_name::TypeName",
|
|
2547
|
+
value: {
|
|
2548
|
+
name: coinType.substring(2)
|
|
2549
|
+
}
|
|
2668
2550
|
}
|
|
2551
|
+
});
|
|
2552
|
+
if (!interestModelDynamicFieldObjectResponse)
|
|
2553
|
+
return void 0;
|
|
2554
|
+
const interestModelDynamicFieldObject = interestModelDynamicFieldObjectResponse.data;
|
|
2555
|
+
if (interestModelDynamicFieldObject && interestModelDynamicFieldObject.content && "fields" in interestModelDynamicFieldObject.content) {
|
|
2556
|
+
const dynamicFields = interestModelDynamicFieldObject.content.fields;
|
|
2557
|
+
interestModel = dynamicFields.value.fields;
|
|
2669
2558
|
}
|
|
2670
|
-
});
|
|
2671
|
-
const interestModelDynamicFieldObject = interestModelDynamicFieldObjectResponse?.data;
|
|
2672
|
-
if (!(interestModelDynamicFieldObject && interestModelDynamicFieldObject.content && "fields" in interestModelDynamicFieldObject.content))
|
|
2673
|
-
throw new Error(
|
|
2674
|
-
`Failed to fetch interestModelDynamicFieldObject for ${poolCoinName}: ${interestModelDynamicFieldObject}`
|
|
2675
|
-
);
|
|
2676
|
-
const interestModel = interestModelDynamicFieldObject.content.fields.value.fields;
|
|
2677
|
-
const getBorrowFee = async () => {
|
|
2678
2559
|
const borrowFeeDynamicFieldObjectResponse = await query.cache.queryGetDynamicFieldObject({
|
|
2679
2560
|
parentId: marketId,
|
|
2680
2561
|
name: {
|
|
@@ -2686,11 +2567,16 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
|
|
|
2686
2567
|
}
|
|
2687
2568
|
}
|
|
2688
2569
|
});
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2570
|
+
if (!borrowFeeDynamicFieldObjectResponse)
|
|
2571
|
+
return void 0;
|
|
2572
|
+
const borrowFeeDynamicFieldObject = borrowFeeDynamicFieldObjectResponse.data;
|
|
2573
|
+
if (borrowFeeDynamicFieldObject && borrowFeeDynamicFieldObject.content && "fields" in borrowFeeDynamicFieldObject.content) {
|
|
2574
|
+
const dynamicFields = borrowFeeDynamicFieldObject.content.fields;
|
|
2575
|
+
borrowFeeRate = dynamicFields.value.fields;
|
|
2576
|
+
}
|
|
2577
|
+
}
|
|
2578
|
+
}
|
|
2579
|
+
if (balanceSheet && borrowIndex && interestModel && (USE_TEST_ADDRESS || borrowFeeRate)) {
|
|
2694
2580
|
const parsedMarketPoolData = parseOriginMarketPoolData({
|
|
2695
2581
|
type: interestModel.type.fields,
|
|
2696
2582
|
maxBorrowRate: interestModel.max_borrow_rate.fields,
|
|
@@ -2704,7 +2590,7 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
|
|
|
2704
2590
|
reserve: balanceSheet.revenue,
|
|
2705
2591
|
reserveFactor: interestModel.revenue_factor.fields,
|
|
2706
2592
|
borrowWeight: interestModel.borrow_weight.fields,
|
|
2707
|
-
borrowFeeRate:
|
|
2593
|
+
borrowFeeRate: borrowFeeRate || { value: "0" },
|
|
2708
2594
|
baseBorrowRatePerSec: interestModel.base_borrow_rate_per_sec.fields,
|
|
2709
2595
|
borrowRateOnHighKink: interestModel.borrow_rate_on_high_kink.fields,
|
|
2710
2596
|
borrowRateOnMidKink: interestModel.borrow_rate_on_mid_kink.fields,
|
|
@@ -2720,7 +2606,7 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
|
|
|
2720
2606
|
const maxSupplyCoin = BigNumber2(
|
|
2721
2607
|
await getSupplyLimit(query.utils, poolCoinName) ?? "0"
|
|
2722
2608
|
).shiftedBy(-coinDecimal).toNumber();
|
|
2723
|
-
|
|
2609
|
+
marketPool = {
|
|
2724
2610
|
coinName: poolCoinName,
|
|
2725
2611
|
symbol: query.utils.parseSymbol(poolCoinName),
|
|
2726
2612
|
coinType: query.utils.parseCoinType(poolCoinName),
|
|
@@ -2739,13 +2625,12 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
|
|
|
2739
2625
|
marketCoinSupplyAmount: parsedMarketPoolData.marketCoinSupplyAmount,
|
|
2740
2626
|
minBorrowAmount: parsedMarketPoolData.minBorrowAmount,
|
|
2741
2627
|
maxSupplyCoin,
|
|
2742
|
-
isIsolated: await isIsolatedAsset(query.utils, poolCoinName),
|
|
2743
|
-
|
|
2628
|
+
// isIsolated: await isIsolatedAsset(query.utils, poolCoinName),
|
|
2629
|
+
isIsolated: false,
|
|
2744
2630
|
...calculatedMarketPoolData
|
|
2745
2631
|
};
|
|
2746
|
-
} catch (e) {
|
|
2747
|
-
console.error(e);
|
|
2748
2632
|
}
|
|
2633
|
+
return marketPool;
|
|
2749
2634
|
};
|
|
2750
2635
|
var getMarketCollaterals = async (query, collateralCoinNames = [...SUPPORT_COLLATERALS], indexer = false) => {
|
|
2751
2636
|
const marketId = query.address.get("core.market");
|
|
@@ -2794,76 +2679,85 @@ var getMarketCollateral = async (query, collateralCoinName, indexer = false, mar
|
|
|
2794
2679
|
);
|
|
2795
2680
|
return marketCollateralIndexer;
|
|
2796
2681
|
}
|
|
2682
|
+
let marketCollateral;
|
|
2683
|
+
let riskModel;
|
|
2684
|
+
let collateralStat;
|
|
2797
2685
|
const marketId = query.address.get("core.market");
|
|
2798
2686
|
marketObject = marketObject || (await query.cache.queryGetObject(marketId, {
|
|
2799
2687
|
showContent: true
|
|
2800
2688
|
}))?.data;
|
|
2801
|
-
if (
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2689
|
+
if (marketObject) {
|
|
2690
|
+
if (marketObject.content && "fields" in marketObject.content) {
|
|
2691
|
+
const fields = marketObject.content.fields;
|
|
2692
|
+
const coinType = query.utils.parseCoinType(collateralCoinName);
|
|
2693
|
+
const riskModelParentId = fields.risk_models.fields.table.fields.id.id;
|
|
2694
|
+
const riskModelDynamicFieldObjectResponse = await query.cache.queryGetDynamicFieldObject({
|
|
2695
|
+
parentId: riskModelParentId,
|
|
2696
|
+
name: {
|
|
2697
|
+
type: "0x1::type_name::TypeName",
|
|
2698
|
+
value: {
|
|
2699
|
+
name: coinType.substring(2)
|
|
2700
|
+
}
|
|
2701
|
+
}
|
|
2702
|
+
});
|
|
2703
|
+
if (!riskModelDynamicFieldObjectResponse)
|
|
2704
|
+
return void 0;
|
|
2705
|
+
const riskModelDynamicFieldObject = riskModelDynamicFieldObjectResponse.data;
|
|
2706
|
+
if (riskModelDynamicFieldObject && riskModelDynamicFieldObject.content && "fields" in riskModelDynamicFieldObject.content) {
|
|
2707
|
+
const dynamicFields = riskModelDynamicFieldObject.content.fields;
|
|
2708
|
+
riskModel = dynamicFields.value.fields;
|
|
2812
2709
|
}
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2710
|
+
const collateralStatParentId = fields.collateral_stats.fields.table.fields.id.id;
|
|
2711
|
+
const collateralStatDynamicFieldObjectResponse = await query.cache.queryGetDynamicFieldObject({
|
|
2712
|
+
parentId: collateralStatParentId,
|
|
2713
|
+
name: {
|
|
2714
|
+
type: "0x1::type_name::TypeName",
|
|
2715
|
+
value: {
|
|
2716
|
+
name: coinType.substring(2)
|
|
2717
|
+
}
|
|
2718
|
+
}
|
|
2719
|
+
});
|
|
2720
|
+
if (!collateralStatDynamicFieldObjectResponse)
|
|
2721
|
+
return void 0;
|
|
2722
|
+
const collateralStatDynamicFieldObject = collateralStatDynamicFieldObjectResponse.data;
|
|
2723
|
+
if (collateralStatDynamicFieldObject && collateralStatDynamicFieldObject.content && "fields" in collateralStatDynamicFieldObject.content) {
|
|
2724
|
+
const dynamicFields = collateralStatDynamicFieldObject.content.fields;
|
|
2725
|
+
collateralStat = dynamicFields.value.fields;
|
|
2828
2726
|
}
|
|
2829
2727
|
}
|
|
2830
|
-
}
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2728
|
+
}
|
|
2729
|
+
if (riskModel && collateralStat) {
|
|
2730
|
+
const parsedMarketCollateralData = parseOriginMarketCollateralData({
|
|
2731
|
+
type: riskModel.type.fields,
|
|
2732
|
+
collateralFactor: riskModel.collateral_factor.fields,
|
|
2733
|
+
liquidationFactor: riskModel.liquidation_factor.fields,
|
|
2734
|
+
liquidationDiscount: riskModel.liquidation_discount.fields,
|
|
2735
|
+
liquidationPanelty: riskModel.liquidation_penalty.fields,
|
|
2736
|
+
liquidationReserveFactor: riskModel.liquidation_revenue_factor.fields,
|
|
2737
|
+
maxCollateralAmount: riskModel.max_collateral_amount,
|
|
2738
|
+
totalCollateralAmount: collateralStat.amount
|
|
2739
|
+
});
|
|
2740
|
+
const calculatedMarketCollateralData = calculateMarketCollateralData(
|
|
2741
|
+
query.utils,
|
|
2742
|
+
parsedMarketCollateralData
|
|
2835
2743
|
);
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
symbol: query.utils.parseSymbol(collateralCoinName),
|
|
2854
|
-
coinType: query.utils.parseCoinType(collateralCoinName),
|
|
2855
|
-
marketCoinType: query.utils.parseMarketCoinType(collateralCoinName),
|
|
2856
|
-
coinWrappedType: query.utils.getCoinWrappedType(collateralCoinName),
|
|
2857
|
-
coinDecimal: query.utils.getCoinDecimal(collateralCoinName),
|
|
2858
|
-
coinPrice: coinPrice ?? 0,
|
|
2859
|
-
collateralFactor: parsedMarketCollateralData.collateralFactor,
|
|
2860
|
-
liquidationFactor: parsedMarketCollateralData.liquidationFactor,
|
|
2861
|
-
liquidationDiscount: parsedMarketCollateralData.liquidationDiscount,
|
|
2862
|
-
liquidationPanelty: parsedMarketCollateralData.liquidationPanelty,
|
|
2863
|
-
liquidationReserveFactor: parsedMarketCollateralData.liquidationReserveFactor,
|
|
2864
|
-
isIsolated: await isIsolatedAsset(query.utils, collateralCoinName),
|
|
2865
|
-
...calculatedMarketCollateralData
|
|
2866
|
-
};
|
|
2744
|
+
marketCollateral = {
|
|
2745
|
+
coinName: collateralCoinName,
|
|
2746
|
+
symbol: query.utils.parseSymbol(collateralCoinName),
|
|
2747
|
+
coinType: query.utils.parseCoinType(collateralCoinName),
|
|
2748
|
+
marketCoinType: query.utils.parseMarketCoinType(collateralCoinName),
|
|
2749
|
+
coinWrappedType: query.utils.getCoinWrappedType(collateralCoinName),
|
|
2750
|
+
coinDecimal: query.utils.getCoinDecimal(collateralCoinName),
|
|
2751
|
+
coinPrice: coinPrice ?? 0,
|
|
2752
|
+
collateralFactor: parsedMarketCollateralData.collateralFactor,
|
|
2753
|
+
liquidationFactor: parsedMarketCollateralData.liquidationFactor,
|
|
2754
|
+
liquidationDiscount: parsedMarketCollateralData.liquidationDiscount,
|
|
2755
|
+
liquidationPanelty: parsedMarketCollateralData.liquidationPanelty,
|
|
2756
|
+
liquidationReserveFactor: parsedMarketCollateralData.liquidationReserveFactor,
|
|
2757
|
+
...calculatedMarketCollateralData
|
|
2758
|
+
};
|
|
2759
|
+
}
|
|
2760
|
+
return marketCollateral;
|
|
2867
2761
|
};
|
|
2868
2762
|
var getObligations = async ({
|
|
2869
2763
|
address
|
|
@@ -2879,6 +2773,9 @@ var getObligations = async ({
|
|
|
2879
2773
|
filter: {
|
|
2880
2774
|
StructType: `${protocolObjectId}::obligation::ObligationKey`
|
|
2881
2775
|
},
|
|
2776
|
+
options: {
|
|
2777
|
+
showContent: true
|
|
2778
|
+
},
|
|
2882
2779
|
cursor: nextCursor,
|
|
2883
2780
|
limit: 10
|
|
2884
2781
|
});
|
|
@@ -2892,14 +2789,14 @@ var getObligations = async ({
|
|
|
2892
2789
|
hasNextPage = false;
|
|
2893
2790
|
}
|
|
2894
2791
|
} while (hasNextPage);
|
|
2895
|
-
const
|
|
2896
|
-
const keyObjects = await address.cache.queryGetObjects(keyObjectIds);
|
|
2792
|
+
const keyObjects = keyObjectsResponse.filter((ref) => !!ref.data);
|
|
2897
2793
|
const obligations = [];
|
|
2898
2794
|
await Promise.allSettled(
|
|
2899
|
-
keyObjects.map(async (
|
|
2900
|
-
const keyId =
|
|
2901
|
-
|
|
2902
|
-
|
|
2795
|
+
keyObjects.map(async ({ data }) => {
|
|
2796
|
+
const keyId = data?.objectId;
|
|
2797
|
+
const content = data?.content;
|
|
2798
|
+
if (keyId && content && "fields" in content) {
|
|
2799
|
+
const fields = content.fields;
|
|
2903
2800
|
const obligationId = String(fields.ownership.fields.of);
|
|
2904
2801
|
const locked = await getObligationLocked(address.cache, obligationId);
|
|
2905
2802
|
obligations.push({ id: obligationId, keyId, locked });
|
|
@@ -3092,7 +2989,7 @@ var getSpool = async (query, marketCoinName, indexer = false, marketPool, coinPr
|
|
|
3092
2989
|
const coinName = query.utils.parseCoinName(marketCoinName);
|
|
3093
2990
|
marketPool = marketPool || await query.getMarketPool(coinName, indexer);
|
|
3094
2991
|
if (!marketPool) {
|
|
3095
|
-
throw new Error(
|
|
2992
|
+
throw new Error("Fail to fetch marketPool");
|
|
3096
2993
|
}
|
|
3097
2994
|
const poolId = query.address.get(`spool.pools.${marketCoinName}.id`);
|
|
3098
2995
|
const rewardPoolId = query.address.get(
|
|
@@ -3167,6 +3064,7 @@ var getSpool = async (query, marketCoinName, indexer = false, marketPool, coinPr
|
|
|
3167
3064
|
coinType: query.utils.parseCoinType(coinName),
|
|
3168
3065
|
marketCoinType: query.utils.parseMarketCoinType(coinName),
|
|
3169
3066
|
rewardCoinType: isMarketCoin(rewardCoinName) ? query.utils.parseMarketCoinType(rewardCoinName) : query.utils.parseCoinType(rewardCoinName),
|
|
3067
|
+
sCoinType: marketPool.sCoinType,
|
|
3170
3068
|
coinDecimal: query.utils.getCoinDecimal(coinName),
|
|
3171
3069
|
rewardCoinDecimal: query.utils.getCoinDecimal(rewardCoinName),
|
|
3172
3070
|
coinPrice: coinPrices?.[coinName] ?? 0,
|
|
@@ -3763,6 +3661,7 @@ var getLending = async (query, poolCoinName, ownerAddress, indexer = false, mark
|
|
|
3763
3661
|
symbol: query.utils.parseSymbol(poolCoinName),
|
|
3764
3662
|
coinType: query.utils.parseCoinType(poolCoinName),
|
|
3765
3663
|
marketCoinType: query.utils.parseMarketCoinType(poolCoinName),
|
|
3664
|
+
sCoinType: marketPool?.sCoinType ?? "",
|
|
3766
3665
|
coinDecimal,
|
|
3767
3666
|
coinPrice: coinPrice ?? 0,
|
|
3768
3667
|
conversionRate: marketPool?.conversionRate ?? 1,
|
|
@@ -3820,8 +3719,12 @@ var getObligationAccounts = async (query, ownerAddress, indexer = false) => {
|
|
|
3820
3719
|
};
|
|
3821
3720
|
var getObligationAccount = async (query, obligationId, ownerAddress, indexer = false, market, coinPrices, coinAmounts) => {
|
|
3822
3721
|
market = market || await query.queryMarket(indexer);
|
|
3823
|
-
const
|
|
3824
|
-
.../* @__PURE__ */ new Set([
|
|
3722
|
+
const collateralAssetCoinNames = [
|
|
3723
|
+
.../* @__PURE__ */ new Set([
|
|
3724
|
+
...Object.values(market.collaterals).map(
|
|
3725
|
+
(collateral) => collateral.coinName
|
|
3726
|
+
)
|
|
3727
|
+
])
|
|
3825
3728
|
];
|
|
3826
3729
|
const obligationQuery = await query.queryObligation(obligationId);
|
|
3827
3730
|
const borrowIncentivePools = await query.getBorrowIncentivePools(
|
|
@@ -3829,9 +3732,8 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3829
3732
|
indexer
|
|
3830
3733
|
);
|
|
3831
3734
|
const borrowIncentiveAccounts = await query.getBorrowIncentiveAccounts(obligationId);
|
|
3832
|
-
coinPrices = coinPrices || await query.utils.getCoinPrices(
|
|
3833
|
-
coinAmounts = coinAmounts || await query.getCoinAmounts(
|
|
3834
|
-
console.log(coinPrices);
|
|
3735
|
+
coinPrices = coinPrices || await query.utils.getCoinPrices(collateralAssetCoinNames);
|
|
3736
|
+
coinAmounts = coinAmounts || await query.getCoinAmounts(collateralAssetCoinNames, ownerAddress);
|
|
3835
3737
|
const collaterals = {};
|
|
3836
3738
|
const debts = {};
|
|
3837
3739
|
const borrowIncentives = {};
|
|
@@ -3843,7 +3745,7 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3843
3745
|
let totalRewardedPools = 0;
|
|
3844
3746
|
let totalBorrowedValue = BigNumber4(0);
|
|
3845
3747
|
let totalBorrowedValueWithWeight = BigNumber4(0);
|
|
3846
|
-
for (const assetCoinName of
|
|
3748
|
+
for (const assetCoinName of collateralAssetCoinNames) {
|
|
3847
3749
|
const collateral = obligationQuery?.collaterals.find((collateral2) => {
|
|
3848
3750
|
const collateralCoinName = query.utils.parseCoinNameFromType(
|
|
3849
3751
|
collateral2.type.name
|
|
@@ -4148,7 +4050,7 @@ var getTotalValueLocked = async (query, indexer = false) => {
|
|
|
4148
4050
|
import BigNumber5 from "bignumber.js";
|
|
4149
4051
|
import { SUI_CLOCK_OBJECT_ID, SuiTxBlock as SuiTxBlock2 } from "@scallop-io/sui-kit";
|
|
4150
4052
|
import { bcs } from "@mysten/sui/bcs";
|
|
4151
|
-
import { z as
|
|
4053
|
+
import { z as zod2 } from "zod";
|
|
4152
4054
|
import assert from "assert";
|
|
4153
4055
|
var getVescaKeys = async (utils, ownerAddress) => {
|
|
4154
4056
|
const owner = ownerAddress || utils.suiKit.currentAddress();
|
|
@@ -4197,14 +4099,13 @@ var getVeScas = async ({
|
|
|
4197
4099
|
}
|
|
4198
4100
|
return result;
|
|
4199
4101
|
};
|
|
4200
|
-
var SuiObjectRefZod =
|
|
4201
|
-
objectId:
|
|
4202
|
-
digest:
|
|
4203
|
-
version:
|
|
4102
|
+
var SuiObjectRefZod = zod2.object({
|
|
4103
|
+
objectId: zod2.string(),
|
|
4104
|
+
digest: zod2.string(),
|
|
4105
|
+
version: zod2.string()
|
|
4204
4106
|
});
|
|
4205
|
-
var getVeSca = async (utils, veScaKey
|
|
4107
|
+
var getVeSca = async (utils, veScaKey) => {
|
|
4206
4108
|
const tableId = utils.address.get(`vesca.tableId`);
|
|
4207
|
-
veScaKey = veScaKey || (await getVescaKeys(utils, ownerAddress))[0];
|
|
4208
4109
|
if (!veScaKey)
|
|
4209
4110
|
return void 0;
|
|
4210
4111
|
if (typeof veScaKey === "object") {
|
|
@@ -4334,16 +4235,16 @@ var queryVeScaKeyIdFromReferralBindings = async (address, refereeAddress) => {
|
|
|
4334
4235
|
|
|
4335
4236
|
// src/queries/loyaltyProgramQuery.ts
|
|
4336
4237
|
import BigNumber6 from "bignumber.js";
|
|
4337
|
-
import { z as
|
|
4338
|
-
var rewardPoolFieldsZod =
|
|
4339
|
-
balance:
|
|
4340
|
-
enable_claim:
|
|
4238
|
+
import { z as zod3 } from "zod";
|
|
4239
|
+
var rewardPoolFieldsZod = zod3.object({
|
|
4240
|
+
balance: zod3.string(),
|
|
4241
|
+
enable_claim: zod3.boolean()
|
|
4341
4242
|
}).transform((value) => ({
|
|
4342
4243
|
totalPoolReward: BigNumber6(value.balance).shiftedBy(-9).toNumber(),
|
|
4343
4244
|
isClaimEnabled: value.enable_claim
|
|
4344
4245
|
}));
|
|
4345
|
-
var userRewardFieldsZod =
|
|
4346
|
-
value:
|
|
4246
|
+
var userRewardFieldsZod = zod3.object({
|
|
4247
|
+
value: zod3.string()
|
|
4347
4248
|
}).transform((value) => BigNumber6(value.value).shiftedBy(-9).toNumber());
|
|
4348
4249
|
var getLoyaltyProgramInformations = async (query, veScaKey) => {
|
|
4349
4250
|
const rewardPool = query.address.get("loyaltyProgram.rewardPool");
|
|
@@ -4454,10 +4355,10 @@ var ScallopUtils = class {
|
|
|
4454
4355
|
* @param address - ScallopAddress instance.
|
|
4455
4356
|
*/
|
|
4456
4357
|
async init(force = false, address) {
|
|
4457
|
-
if (
|
|
4458
|
-
this.address = address;
|
|
4459
|
-
if (force || !this.address.getAddresses()) {
|
|
4358
|
+
if (force || !this.address.getAddresses() || !address?.getAddresses()) {
|
|
4460
4359
|
await this.address.read();
|
|
4360
|
+
} else {
|
|
4361
|
+
this.address = address;
|
|
4461
4362
|
}
|
|
4462
4363
|
}
|
|
4463
4364
|
/**
|
|
@@ -4757,38 +4658,30 @@ var ScallopUtils = class {
|
|
|
4757
4658
|
const priceId = this.address.get(
|
|
4758
4659
|
`core.coins.${coinName}.oracle.pyth.feed`
|
|
4759
4660
|
);
|
|
4760
|
-
|
|
4761
|
-
acc[coinName] = priceId;
|
|
4762
|
-
}
|
|
4661
|
+
acc[coinName] = priceId;
|
|
4763
4662
|
return acc;
|
|
4764
4663
|
},
|
|
4765
4664
|
{}
|
|
4766
4665
|
);
|
|
4767
4666
|
await Promise.allSettled(
|
|
4768
|
-
Object.entries(priceIds).
|
|
4667
|
+
Object.entries(priceIds).map(async ([coinName, priceId]) => {
|
|
4769
4668
|
const pythConnection = new SuiPriceServiceConnection(endpoint);
|
|
4770
4669
|
try {
|
|
4771
4670
|
const feed = await this.cache.queryClient.fetchQuery({
|
|
4772
|
-
queryKey: queryKeys.oracle.getPythLatestPriceFeed(
|
|
4773
|
-
priceId,
|
|
4774
|
-
endpoint
|
|
4775
|
-
),
|
|
4671
|
+
queryKey: queryKeys.oracle.getPythLatestPriceFeed(priceId),
|
|
4776
4672
|
queryFn: async () => {
|
|
4777
4673
|
return await pythConnection.getLatestPriceFeeds([priceId]) ?? [];
|
|
4778
4674
|
}
|
|
4779
4675
|
});
|
|
4780
4676
|
if (feed[0]) {
|
|
4781
|
-
const data = parseDataFromPythPriceFeed(
|
|
4782
|
-
feed[0],
|
|
4783
|
-
this.address
|
|
4784
|
-
);
|
|
4677
|
+
const data = parseDataFromPythPriceFeed(feed[0], this.address);
|
|
4785
4678
|
this._priceMap.set(coinName, {
|
|
4786
4679
|
price: data.price,
|
|
4787
4680
|
publishTime: data.publishTime
|
|
4788
4681
|
});
|
|
4789
4682
|
coinPrices[coinName] = data.price;
|
|
4790
|
-
failedRequests.delete(coinName);
|
|
4791
4683
|
}
|
|
4684
|
+
failedRequests.delete(coinName);
|
|
4792
4685
|
} catch (e) {
|
|
4793
4686
|
console.warn(
|
|
4794
4687
|
`Failed to get price ${coinName} feeds with endpoint ${endpoint}: ${e}`
|
|
@@ -5800,13 +5693,14 @@ var generateBorrowIncentiveQuickMethod = ({ builder, txBlock }) => {
|
|
|
5800
5693
|
);
|
|
5801
5694
|
if (!obligationLocked || unstakeObligationBeforeStake) {
|
|
5802
5695
|
const bindedVeScaKey = await builder.query.getBindedVeScaKey(obligationArg);
|
|
5803
|
-
|
|
5696
|
+
const _veScaKey = bindedVeScaKey ?? veScaKey;
|
|
5697
|
+
if (!_veScaKey) {
|
|
5804
5698
|
txBlock.stakeObligation(obligationArg, obligationKeyArg);
|
|
5805
5699
|
} else {
|
|
5806
5700
|
txBlock.stakeObligationWithVesca(
|
|
5807
5701
|
obligationArg,
|
|
5808
5702
|
obligationKeyArg,
|
|
5809
|
-
|
|
5703
|
+
_veScaKey
|
|
5810
5704
|
);
|
|
5811
5705
|
}
|
|
5812
5706
|
}
|
|
@@ -6648,6 +6542,14 @@ var ScallopIndexer = class {
|
|
|
6648
6542
|
throw Error("Failed to getTotalValueLocked.");
|
|
6649
6543
|
}
|
|
6650
6544
|
}
|
|
6545
|
+
/**
|
|
6546
|
+
* Get coin price index data.
|
|
6547
|
+
*
|
|
6548
|
+
* @return price data.
|
|
6549
|
+
*/
|
|
6550
|
+
async getCoinPrice(poolCoinName) {
|
|
6551
|
+
return (await this.getMarketPool(poolCoinName))?.coinPrice ?? 0;
|
|
6552
|
+
}
|
|
6651
6553
|
};
|
|
6652
6554
|
|
|
6653
6555
|
// src/queries/sCoinQuery.ts
|
|
@@ -6745,6 +6647,88 @@ var getSCoinSwapRate = async (query, fromSCoin, toSCoin, underlyingCoinPrice) =>
|
|
|
6745
6647
|
|
|
6746
6648
|
// src/models/scallopQuery.ts
|
|
6747
6649
|
import { normalizeSuiAddress } from "@mysten/sui/utils";
|
|
6650
|
+
|
|
6651
|
+
// src/queries/isolatedAsset.ts
|
|
6652
|
+
import { z as zod4 } from "zod";
|
|
6653
|
+
var isolatedAssetZod = zod4.object({
|
|
6654
|
+
dataType: zod4.string(),
|
|
6655
|
+
type: zod4.string(),
|
|
6656
|
+
hasPublicTransfer: zod4.boolean(),
|
|
6657
|
+
fields: zod4.object({
|
|
6658
|
+
id: zod4.object({
|
|
6659
|
+
id: zod4.string()
|
|
6660
|
+
}),
|
|
6661
|
+
name: zod4.object({
|
|
6662
|
+
type: zod4.string()
|
|
6663
|
+
}),
|
|
6664
|
+
value: zod4.boolean()
|
|
6665
|
+
})
|
|
6666
|
+
});
|
|
6667
|
+
var ISOLATED_ASSET_KEY = "0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e::market_dynamic_keys::IsolatedAssetKey";
|
|
6668
|
+
var getIsolatedAssets = async (address) => {
|
|
6669
|
+
try {
|
|
6670
|
+
const marketObject = address.get("core.market");
|
|
6671
|
+
const isolatedAssets = [];
|
|
6672
|
+
if (!marketObject)
|
|
6673
|
+
return isolatedAssets;
|
|
6674
|
+
let hasNextPage = false;
|
|
6675
|
+
let nextCursor = null;
|
|
6676
|
+
const isIsolatedDynamicField = (dynamicField) => {
|
|
6677
|
+
return dynamicField.name.type === ISOLATED_ASSET_KEY;
|
|
6678
|
+
};
|
|
6679
|
+
do {
|
|
6680
|
+
const response = await address.cache.queryGetDynamicFields({
|
|
6681
|
+
parentId: marketObject,
|
|
6682
|
+
cursor: nextCursor,
|
|
6683
|
+
limit: 10
|
|
6684
|
+
});
|
|
6685
|
+
if (!response)
|
|
6686
|
+
break;
|
|
6687
|
+
const isolatedAssetCoinTypes = response.data.filter(isIsolatedDynamicField).map(({ name }) => `0x${name.value.type.name}`);
|
|
6688
|
+
isolatedAssets.push(...isolatedAssetCoinTypes);
|
|
6689
|
+
if (response && response.hasNextPage && response.nextCursor) {
|
|
6690
|
+
hasNextPage = true;
|
|
6691
|
+
nextCursor = response.nextCursor;
|
|
6692
|
+
} else {
|
|
6693
|
+
hasNextPage = false;
|
|
6694
|
+
}
|
|
6695
|
+
} while (hasNextPage);
|
|
6696
|
+
return isolatedAssets;
|
|
6697
|
+
} catch (e) {
|
|
6698
|
+
console.error(e);
|
|
6699
|
+
return [];
|
|
6700
|
+
}
|
|
6701
|
+
};
|
|
6702
|
+
var isIsolatedAsset = async (utils, coinName) => {
|
|
6703
|
+
try {
|
|
6704
|
+
const marketObject = utils.address.get("core.market");
|
|
6705
|
+
const cachedData = utils.address.cache.queryClient.getQueryData([
|
|
6706
|
+
"getDynamicFields",
|
|
6707
|
+
marketObject
|
|
6708
|
+
]);
|
|
6709
|
+
if (cachedData) {
|
|
6710
|
+
const coinType2 = utils.parseCoinType(coinName);
|
|
6711
|
+
return cachedData.includes(coinType2);
|
|
6712
|
+
}
|
|
6713
|
+
const coinType = utils.parseCoinType(coinName).slice(2);
|
|
6714
|
+
const object = await utils.cache.queryGetDynamicFieldObject({
|
|
6715
|
+
parentId: marketObject,
|
|
6716
|
+
name: {
|
|
6717
|
+
type: ISOLATED_ASSET_KEY,
|
|
6718
|
+
value: coinType
|
|
6719
|
+
}
|
|
6720
|
+
});
|
|
6721
|
+
const parsedData = isolatedAssetZod.safeParse(object?.data?.content);
|
|
6722
|
+
if (!parsedData.success)
|
|
6723
|
+
return false;
|
|
6724
|
+
return parsedData.data.fields.value;
|
|
6725
|
+
} catch (e) {
|
|
6726
|
+
console.error(e);
|
|
6727
|
+
return false;
|
|
6728
|
+
}
|
|
6729
|
+
};
|
|
6730
|
+
|
|
6731
|
+
// src/models/scallopQuery.ts
|
|
6748
6732
|
var ScallopQuery = class {
|
|
6749
6733
|
constructor(params, instance) {
|
|
6750
6734
|
this.params = params;
|
|
@@ -6814,11 +6798,10 @@ var ScallopQuery = class {
|
|
|
6814
6798
|
* @param address - ScallopAddress instance.
|
|
6815
6799
|
*/
|
|
6816
6800
|
async init(force = false, address) {
|
|
6817
|
-
if (
|
|
6818
|
-
this.address = address;
|
|
6819
|
-
}
|
|
6820
|
-
if (force || !this.address.getAddresses()) {
|
|
6801
|
+
if (force || !this.address.getAddresses() || !address?.getAddresses()) {
|
|
6821
6802
|
await this.address.read();
|
|
6803
|
+
} else {
|
|
6804
|
+
this.address = address;
|
|
6822
6805
|
}
|
|
6823
6806
|
await this.utils.init(force, this.address);
|
|
6824
6807
|
}
|
|
@@ -7275,6 +7258,14 @@ var ScallopQuery = class {
|
|
|
7275
7258
|
async isIsolatedAsset(assetCoinName) {
|
|
7276
7259
|
return isIsolatedAsset(this.utils, assetCoinName);
|
|
7277
7260
|
}
|
|
7261
|
+
/**
|
|
7262
|
+
* Get pool coin price from indexer
|
|
7263
|
+
* @param coinName
|
|
7264
|
+
* @returns price data
|
|
7265
|
+
*/
|
|
7266
|
+
async getCoinPriceByIndexer(poolName) {
|
|
7267
|
+
return this.indexer.getCoinPrice(poolName);
|
|
7268
|
+
}
|
|
7278
7269
|
};
|
|
7279
7270
|
|
|
7280
7271
|
// src/models/scallopBuilder.ts
|
|
@@ -7327,10 +7318,10 @@ var ScallopBuilder = class {
|
|
|
7327
7318
|
* @param address - ScallopAddress instance.
|
|
7328
7319
|
*/
|
|
7329
7320
|
async init(force = false, address) {
|
|
7330
|
-
if (
|
|
7331
|
-
this.address = address;
|
|
7332
|
-
if (force || !this.address.getAddresses()) {
|
|
7321
|
+
if (force || !this.address.getAddresses() || !address?.getAddresses()) {
|
|
7333
7322
|
await this.address.read();
|
|
7323
|
+
} else {
|
|
7324
|
+
this.address = address;
|
|
7334
7325
|
}
|
|
7335
7326
|
await this.query.init(force, this.address);
|
|
7336
7327
|
await this.utils.init(force, this.address);
|
|
@@ -7715,7 +7706,7 @@ var ScallopClient = class {
|
|
|
7715
7706
|
);
|
|
7716
7707
|
txBlock.transferObjects([coin], sender);
|
|
7717
7708
|
if (sign && availableStake) {
|
|
7718
|
-
await txBlock.
|
|
7709
|
+
await txBlock.stakeObligationWithVeScaQuick(obligationId, obligationKey);
|
|
7719
7710
|
}
|
|
7720
7711
|
if (sign) {
|
|
7721
7712
|
return await this.suiKit.signAndSendTxn(
|
|
@@ -7745,7 +7736,7 @@ var ScallopClient = class {
|
|
|
7745
7736
|
}
|
|
7746
7737
|
await txBlock.repayQuick(amount, poolCoinName, obligationId);
|
|
7747
7738
|
if (sign && availableStake) {
|
|
7748
|
-
await txBlock.
|
|
7739
|
+
await txBlock.stakeObligationWithVeScaQuick(obligationId, obligationKey);
|
|
7749
7740
|
}
|
|
7750
7741
|
if (sign) {
|
|
7751
7742
|
return await this.suiKit.signAndSendTxn(
|
|
@@ -7892,7 +7883,7 @@ var ScallopClient = class {
|
|
|
7892
7883
|
const txBlock = this.builder.createTxBlock();
|
|
7893
7884
|
const sender = walletAddress || this.walletAddress;
|
|
7894
7885
|
txBlock.setSender(sender);
|
|
7895
|
-
await txBlock.
|
|
7886
|
+
await txBlock.stakeObligationWithVeScaQuick(obligationId, obligationKeyId);
|
|
7896
7887
|
if (sign) {
|
|
7897
7888
|
return await this.suiKit.signAndSendTxn(
|
|
7898
7889
|
txBlock
|
|
@@ -8244,7 +8235,6 @@ export {
|
|
|
8244
8235
|
ScallopIndexer,
|
|
8245
8236
|
ScallopQuery,
|
|
8246
8237
|
ScallopUtils,
|
|
8247
|
-
TEST_ADDRESSES,
|
|
8248
8238
|
UNLOCK_ROUND_DURATION,
|
|
8249
8239
|
USE_TEST_ADDRESS,
|
|
8250
8240
|
assetCoins,
|