@scallop-io/sui-scallop-sdk 0.46.36 → 0.46.38
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/builders/loyaltyProgramBuilder.d.ts +12 -0
- package/dist/builders/referralBuilder.d.ts +1 -1
- package/dist/constants/testAddress.d.ts +2 -0
- package/dist/index.js +684 -172
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +674 -162
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopQuery.d.ts +10 -3
- package/dist/models/scallopUtils.d.ts +1 -1
- package/dist/queries/index.d.ts +1 -0
- package/dist/queries/loyaltyProgramQuery.d.ts +10 -0
- package/dist/queries/vescaQuery.d.ts +8 -6
- package/dist/types/address.d.ts +6 -0
- package/dist/types/builder/index.d.ts +3 -1
- package/dist/types/builder/loyaltyProgram.d.ts +23 -0
- package/dist/types/builder/vesca.d.ts +16 -0
- package/dist/types/query/index.d.ts +1 -0
- package/dist/types/query/loyaltyProgram.d.ts +5 -0
- package/dist/types/query/vesca.d.ts +18 -0
- package/dist/utils/builder.d.ts +6 -5
- package/package.json +7 -6
- package/src/builders/index.ts +6 -1
- package/src/builders/loyaltyProgramBuilder.ts +115 -0
- package/src/builders/referralBuilder.ts +1 -1
- package/src/builders/vescaBuilder.ts +5 -1
- package/src/constants/testAddress.ts +383 -0
- package/src/models/scallopAddress.ts +12 -2
- package/src/models/scallopCache.ts +0 -1
- package/src/models/scallopQuery.ts +28 -16
- package/src/models/scallopUtils.ts +3 -3
- package/src/queries/borrowIncentiveQuery.ts +9 -8
- package/src/queries/coreQuery.ts +70 -66
- package/src/queries/index.ts +1 -0
- package/src/queries/loyaltyProgramQuery.ts +77 -0
- package/src/queries/portfolioQuery.ts +36 -28
- package/src/queries/vescaQuery.ts +70 -15
- package/src/types/address.ts +6 -0
- package/src/types/builder/index.ts +3 -0
- package/src/types/builder/loyaltyProgram.ts +35 -0
- package/src/types/builder/vesca.ts +16 -0
- package/src/types/query/index.ts +1 -0
- package/src/types/query/loyaltyProgram.ts +5 -0
- package/src/types/query/vesca.ts +21 -0
- package/src/utils/builder.ts +69 -53
- package/src/utils/query.ts +6 -5
package/dist/index.js
CHANGED
|
@@ -268,7 +268,7 @@ var MIN_INITIAL_LOCK_AMOUNT = 1e10;
|
|
|
268
268
|
var MIN_TOP_UP_AMOUNT = 1e9;
|
|
269
269
|
|
|
270
270
|
// src/models/scallop.ts
|
|
271
|
-
var
|
|
271
|
+
var import_sui_kit13 = require("@scallop-io/sui-kit");
|
|
272
272
|
|
|
273
273
|
// src/models/scallopCache.ts
|
|
274
274
|
var import_query_core = require("@tanstack/query-core");
|
|
@@ -357,9 +357,7 @@ var ScallopCache = class {
|
|
|
357
357
|
],
|
|
358
358
|
queryFn: async () => {
|
|
359
359
|
return await this.suiKit.inspectTxn(txBytes);
|
|
360
|
-
}
|
|
361
|
-
staleTime: 8e3
|
|
362
|
-
// make stale time longer for inspectTxn results
|
|
360
|
+
}
|
|
363
361
|
});
|
|
364
362
|
return query;
|
|
365
363
|
}
|
|
@@ -493,6 +491,310 @@ var ScallopCache = class {
|
|
|
493
491
|
|
|
494
492
|
// src/models/scallopAddress.ts
|
|
495
493
|
var import_axios = __toESM(require("axios"));
|
|
494
|
+
|
|
495
|
+
// src/constants/testAddress.ts
|
|
496
|
+
var TEST_ADDRESSES = {
|
|
497
|
+
core: {
|
|
498
|
+
version: "0x07871c4b3c847a0f674510d4978d5cf6f960452795e8ff6f189fd2088a3f6ac7",
|
|
499
|
+
versionCap: "0x590a4011cb649b3878f3ea14b3a78674642a9548d79b7e091ef679574b158a07",
|
|
500
|
+
object: "0xefe8b36d5b2e43728cc323298626b83177803521d195cfb11e15b910e892fddf",
|
|
501
|
+
market: "0xa757975255146dc9686aa823b7838b507f315d704f428cbadad2f4ea061939d9",
|
|
502
|
+
adminCap: "0x09689d018e71c337d9db6d67cbca06b74ed92196103624028ccc3ecea411777c",
|
|
503
|
+
coinDecimalsRegistry: "0x200abe9bf19751cc566ae35aa58e2b7e4ff688fc1130f8d8909ea09bc137d668",
|
|
504
|
+
obligationAccessStore: "0x733e30b7c94d619d78cb8f5bc4bfbb759ced9a531239028caabb2474e5be59c9",
|
|
505
|
+
coins: {
|
|
506
|
+
cetus: {
|
|
507
|
+
id: "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b",
|
|
508
|
+
metaData: "0x4c0dce55eff2db5419bbd2d239d1aa22b4a400c01bbb648b058a9883989025da",
|
|
509
|
+
treasury: "",
|
|
510
|
+
oracle: {
|
|
511
|
+
supra: "",
|
|
512
|
+
switchboard: "",
|
|
513
|
+
pyth: {
|
|
514
|
+
feed: "e5b274b2611143df055d6e7cd8d93fe1961716bcd4dca1cad87a83bc1e78c1ef",
|
|
515
|
+
feedObject: "0x24c0247fb22457a719efac7f670cdc79be321b521460bd6bd2ccfa9f80713b14"
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
},
|
|
519
|
+
apt: {
|
|
520
|
+
id: "0x3a5143bb1196e3bcdfab6203d1683ae29edd26294fc8bfeafe4aaa9d2704df37",
|
|
521
|
+
metaData: "0xc969c5251f372c0f34c32759f1d315cf1ea0ee5e4454b52aea08778eacfdd0a8",
|
|
522
|
+
treasury: "",
|
|
523
|
+
oracle: {
|
|
524
|
+
supra: "",
|
|
525
|
+
switchboard: "",
|
|
526
|
+
pyth: {
|
|
527
|
+
feed: "03ae4db29ed4ae33d323568895aa00337e658e348b37509f5372ae51f0af00d5",
|
|
528
|
+
feedObject: "0x7c5b7837c44a69b469325463ac0673ac1aa8435ff44ddb4191c9ae380463647f"
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
},
|
|
532
|
+
sol: {
|
|
533
|
+
id: "0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8",
|
|
534
|
+
metaData: "0x4d2c39082b4477e3e79dc4562d939147ab90c42fc5f3e4acf03b94383cd69b6e",
|
|
535
|
+
treasury: "",
|
|
536
|
+
oracle: {
|
|
537
|
+
supra: "",
|
|
538
|
+
switchboard: "",
|
|
539
|
+
pyth: {
|
|
540
|
+
feed: "ef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d",
|
|
541
|
+
feedObject: "0x9d0d275efbd37d8a8855f6f2c761fa5983293dd8ce202ee5196626de8fcd4469"
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
},
|
|
545
|
+
btc: {
|
|
546
|
+
id: "0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881",
|
|
547
|
+
metaData: "0x5d3c6e60eeff8a05b693b481539e7847dfe33013e7070cdcb387f5c0cac05dfd",
|
|
548
|
+
treasury: "",
|
|
549
|
+
oracle: {
|
|
550
|
+
supra: "",
|
|
551
|
+
switchboard: "",
|
|
552
|
+
pyth: {
|
|
553
|
+
feed: "e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43",
|
|
554
|
+
feedObject: "0x9a62b4863bdeaabdc9500fce769cf7e72d5585eeb28a6d26e4cafadc13f76ab2"
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
},
|
|
558
|
+
eth: {
|
|
559
|
+
id: "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5",
|
|
560
|
+
metaData: "0x8900e4ceede3363bef086d6b50ca89d816d0e90bf6bc46efefe1f8455e08f50f",
|
|
561
|
+
treasury: "",
|
|
562
|
+
oracle: {
|
|
563
|
+
supra: "",
|
|
564
|
+
switchboard: "",
|
|
565
|
+
pyth: {
|
|
566
|
+
feed: "ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace",
|
|
567
|
+
feedObject: "0x9193fd47f9a0ab99b6e365a464c8a9ae30e6150fc37ed2a89c1586631f6fc4ab"
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
},
|
|
571
|
+
usdc: {
|
|
572
|
+
id: "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf",
|
|
573
|
+
metaData: "0x4fbf84f3029bd0c0b77164b587963be957f853eccf834a67bb9ecba6ec80f189",
|
|
574
|
+
treasury: "",
|
|
575
|
+
oracle: {
|
|
576
|
+
supra: "",
|
|
577
|
+
switchboard: "",
|
|
578
|
+
pyth: {
|
|
579
|
+
feed: "eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a",
|
|
580
|
+
feedObject: "0x5dec622733a204ca27f5a90d8c2fad453cc6665186fd5dff13a83d0b6c9027ab"
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
},
|
|
584
|
+
usdt: {
|
|
585
|
+
id: "0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c",
|
|
586
|
+
metaData: "0xfb0e3eb97dd158a5ae979dddfa24348063843c5b20eb8381dd5fa7c93699e45c",
|
|
587
|
+
treasury: "",
|
|
588
|
+
oracle: {
|
|
589
|
+
supra: "",
|
|
590
|
+
switchboard: "",
|
|
591
|
+
pyth: {
|
|
592
|
+
feed: "2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b",
|
|
593
|
+
feedObject: "0x985e3db9f93f76ee8bace7c3dd5cc676a096accd5d9e09e9ae0fb6e492b14572"
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
},
|
|
597
|
+
sui: {
|
|
598
|
+
id: "0x0000000000000000000000000000000000000000000000000000000000000002",
|
|
599
|
+
metaData: "0x9258181f5ceac8dbffb7030890243caed69a9599d2886d957a9cb7656af3bdb3",
|
|
600
|
+
treasury: "",
|
|
601
|
+
oracle: {
|
|
602
|
+
supra: "",
|
|
603
|
+
switchboard: "0xbca474133638352ba83ccf7b5c931d50f764b09550e16612c9f70f1e21f3f594",
|
|
604
|
+
pyth: {
|
|
605
|
+
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
606
|
+
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
},
|
|
610
|
+
afsui: {
|
|
611
|
+
id: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc",
|
|
612
|
+
metaData: "0x2f9217f533e51334873a39b8026a4aa6919497b47f49d0986a4f1aec66f8a34d",
|
|
613
|
+
treasury: "",
|
|
614
|
+
oracle: {
|
|
615
|
+
supra: "",
|
|
616
|
+
switchboard: "",
|
|
617
|
+
pyth: {
|
|
618
|
+
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
619
|
+
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
},
|
|
623
|
+
hasui: {
|
|
624
|
+
id: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d",
|
|
625
|
+
metaData: "0x2c5f33af93f6511df699aaaa5822d823aac6ed99d4a0de2a4a50b3afa0172e24",
|
|
626
|
+
treasury: "",
|
|
627
|
+
oracle: {
|
|
628
|
+
supra: "",
|
|
629
|
+
switchboard: "",
|
|
630
|
+
pyth: {
|
|
631
|
+
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
632
|
+
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
},
|
|
636
|
+
vsui: {
|
|
637
|
+
id: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55",
|
|
638
|
+
metaData: "0xabd84a23467b33854ab25cf862006fd97479f8f6f53e50fe732c43a274d939bd",
|
|
639
|
+
treasury: "",
|
|
640
|
+
oracle: {
|
|
641
|
+
supra: "",
|
|
642
|
+
switchboard: "",
|
|
643
|
+
pyth: {
|
|
644
|
+
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
645
|
+
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
},
|
|
649
|
+
sca: {
|
|
650
|
+
id: "0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6",
|
|
651
|
+
metaData: "0x5d26a1e9a55c88147ac870bfa31b729d7f49f8804b8b3adfdf3582d301cca844",
|
|
652
|
+
treasury: "",
|
|
653
|
+
oracle: {
|
|
654
|
+
supra: "",
|
|
655
|
+
switchboard: "",
|
|
656
|
+
pyth: {
|
|
657
|
+
feed: "7e17f0ac105abe9214deb9944c30264f5986bf292869c6bd8e8da3ccd92d79bc",
|
|
658
|
+
feedObject: "0xf6de1d3279a269a597d813cbaca59aa906543ab9a8c64e84a4722f1a20863985"
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
},
|
|
663
|
+
oracles: {
|
|
664
|
+
xOracle: "0x93d5bf0936b71eb27255941e532fac33b5a5c7759e377b4923af0a1359ad494f",
|
|
665
|
+
xOracleCap: "0x1edeae568fde99e090dbdec4bcdbd33a15f53a1ce1f87aeef1a560dedf4b4a90",
|
|
666
|
+
supra: { registry: "", registryCap: "", holder: "" },
|
|
667
|
+
switchboard: { registry: "", registryCap: "" },
|
|
668
|
+
pyth: {
|
|
669
|
+
registry: "0xedc293f9413a5a7a5d53bdba1fd889d0a4030894469228f0acdae4aa3c55a213",
|
|
670
|
+
registryCap: "0xbcb07141eb1f7e01fbda4130ecf5f5adaeabb77f5d9c32158b7532bcd2197acd",
|
|
671
|
+
state: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8",
|
|
672
|
+
wormhole: "0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a",
|
|
673
|
+
wormholeState: "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c"
|
|
674
|
+
}
|
|
675
|
+
},
|
|
676
|
+
packages: {
|
|
677
|
+
coinDecimalsRegistry: {
|
|
678
|
+
id: "0xca5a5a62f01c79a104bf4d31669e29daa387f325c241de4edbe30986a9bc8b0d",
|
|
679
|
+
upgradeCap: "0x34e76a945d29f195bc53ca704fa70877d1cf3a5d7bbfdda1b13e633fff13c0f6"
|
|
680
|
+
},
|
|
681
|
+
math: {
|
|
682
|
+
id: "0xad013d5fde39e15eabda32b3dbdafd67dac32b798ce63237c27a8f73339b9b6f",
|
|
683
|
+
upgradeCap: "0x3a329598231de02e6135c62284b66005b41cad1d9ab7ca2dc79c08293aba2ec6"
|
|
684
|
+
},
|
|
685
|
+
whitelist: {
|
|
686
|
+
id: "0x1318fdc90319ec9c24df1456d960a447521b0a658316155895014a6e39b5482f",
|
|
687
|
+
upgradeCap: "0xf5a22aea23db664f7b69855b6a546747f17c1ec4230319cfc17225e462b05761"
|
|
688
|
+
},
|
|
689
|
+
x: {
|
|
690
|
+
id: "0x779b5c547976899f5474f3a5bc0db36ddf4697ad7e5a901db0415c2281d28162",
|
|
691
|
+
upgradeCap: "0x3f203f6fff6a69d151e4f1cd931f22b68c489ef2759765662fc7baf673943c9e"
|
|
692
|
+
},
|
|
693
|
+
protocol: {
|
|
694
|
+
id: "0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e",
|
|
695
|
+
upgradeCap: "0x38527d154618d1fd5a644b90717fe07cf0e9f26b46b63e9568e611a3f86d5c1a"
|
|
696
|
+
},
|
|
697
|
+
protocolWhitelist: {
|
|
698
|
+
id: "0x4c262d9343dac53ecb28f482a2a3f62c73d0ebac5b5f03d57383d56ff219acdf",
|
|
699
|
+
upgradeCap: "0x4a5e88a75039b00988f633f811f58117f31b8627a46bf822aa114d9010049449"
|
|
700
|
+
},
|
|
701
|
+
query: {
|
|
702
|
+
id: "0xb8d603a39114a5efef3dd0bf84df0bed1be1fbd39b78b7dd6e8a61ccc5e6006f",
|
|
703
|
+
upgradeCap: "0x0d535c35f608b9b01b7ccce11acf43b1dd80c1b72bf8b541744a6e28e8d2745f"
|
|
704
|
+
},
|
|
705
|
+
supra: { id: "", upgradeCap: "" },
|
|
706
|
+
pyth: {
|
|
707
|
+
id: "0x910f30cbc7f601f75a5141a01265cd47c62d468707c5e1aecb32a18f448cb25a",
|
|
708
|
+
upgradeCap: "0xdf0ffbae1ea5bb25fbca5efba433dcf00c7cced65679af2f04728901275c6157"
|
|
709
|
+
},
|
|
710
|
+
switchboard: { id: "", upgradeCap: "" },
|
|
711
|
+
xOracle: {
|
|
712
|
+
id: "0x1478a432123e4b3d61878b629f2c692969fdb375644f1251cd278a4b1e7d7cd6",
|
|
713
|
+
upgradeCap: "0x0f928a6b2e26b73330fecaf9b44acfc9800a4a9794d6415c2a3153bc70e3c1f0"
|
|
714
|
+
},
|
|
715
|
+
testCoin: { id: "", upgradeCap: "" }
|
|
716
|
+
}
|
|
717
|
+
},
|
|
718
|
+
spool: {
|
|
719
|
+
id: "0x7c4fdabe81c31b19a45d1e572a52a539997a90903fbb5bfab71480abe0fa62c3",
|
|
720
|
+
adminCap: "0xdd8a047cbbf802bfcde5288b8ef1910965d789cc614da11d39af05fca0bd020a",
|
|
721
|
+
object: "0xe87f1b2d498106a2c61421cec75b7b5c5e348512b0dc263949a0e7a3c256571a",
|
|
722
|
+
pools: {
|
|
723
|
+
seth: {
|
|
724
|
+
id: "0xeec40beccb07c575bebd842eeaabb835f77cd3dab73add433477e57f583a6787",
|
|
725
|
+
rewardPoolId: "0x957de68a18d87817de8309b30c1ec269a4d87ae513abbeed86b5619cb9ce1077"
|
|
726
|
+
},
|
|
727
|
+
ssui: {
|
|
728
|
+
id: "0x4f0ba970d3c11db05c8f40c64a15b6a33322db3702d634ced6536960ab6f3ee4",
|
|
729
|
+
rewardPoolId: "0x162250ef72393a4ad3d46294c4e1bdfcb03f04c869d390e7efbfc995353a7ee9"
|
|
730
|
+
},
|
|
731
|
+
susdc: {
|
|
732
|
+
id: "0x4ace6648ddc64e646ba47a957c562c32c9599b3bba8f5ac1aadb2ae23a2f8ca0",
|
|
733
|
+
rewardPoolId: "0xf4268cc9b9413b9bfe09e8966b8de650494c9e5784bf0930759cfef4904daff8"
|
|
734
|
+
},
|
|
735
|
+
susdt: {
|
|
736
|
+
id: "0xcb328f7ffa7f9342ed85af3fdb2f22919e1a06dfb2f713c04c73543870d7548f",
|
|
737
|
+
rewardPoolId: "0x2c9f934d67a5baa586ceec2cc24163a2f049a6af3d5ba36b84d8ac40f25c4080"
|
|
738
|
+
},
|
|
739
|
+
scetus: {
|
|
740
|
+
id: "0xac1bb13bf4472a637c18c2415fb0e3c1227ea2bcf35242e50563c98215bd298e",
|
|
741
|
+
rewardPoolId: "0x6835c1224126a45086fc6406adc249e3f30df18d779ca4f4e570e38716a17f3f"
|
|
742
|
+
},
|
|
743
|
+
safsui: {
|
|
744
|
+
id: "0xeedf438abcaa6ce4d9625ffca110920592d5867e4c5637d84ad9f466c4feb800",
|
|
745
|
+
rewardPoolId: "0x89255a2f86ed7fbfef35ab8b7be48cc7667015975be2685dd9a55a9a64baf76e"
|
|
746
|
+
},
|
|
747
|
+
shasui: {
|
|
748
|
+
id: "0xa6148bc1b623e936d39a952ceb5bea79e8b37228a8f595067bf1852efd3c34aa",
|
|
749
|
+
rewardPoolId: "0x6f3563644d3e2ef13176dbf9d865bd93479df60ccbe07b7e66db57f6309f5a66"
|
|
750
|
+
},
|
|
751
|
+
svsui: {
|
|
752
|
+
id: "0x69ce8e537e750a95381e6040794afa5ab1758353a1a2e1de7760391b01f91670",
|
|
753
|
+
rewardPoolId: "0xbca914adce058ad0902c7f3cfcd698392a475f00dcfdc3f76001d0370b98777a"
|
|
754
|
+
}
|
|
755
|
+
},
|
|
756
|
+
config: ""
|
|
757
|
+
},
|
|
758
|
+
borrowIncentive: {
|
|
759
|
+
id: "0x6152f696fc3a658f33c4b891764731a59153125ffedfa8bff7167c42823f58a9",
|
|
760
|
+
adminCap: "0xc486afa253646f4d381e81d7f1df8aa4723b845a6bb356f69bad635ffefffe2c",
|
|
761
|
+
object: "0x002875153e09f8145ab63527bc85c00f2bd102e12f9573c47f8cdf1a1cb62934",
|
|
762
|
+
query: "0x529edc54a3dce2207703ceebbccb0ac14133f7825c1f528775ba0d85a4063489",
|
|
763
|
+
incentivePools: "0x6547e143d406b5ccd5f46aae482497de279cc1a68c406f701df70a05f9212ab4",
|
|
764
|
+
incentiveAccounts: "0xc4701fdbc1c92f9a636d334d66012b3027659e9fb8aff27279a82edfb6b77d02",
|
|
765
|
+
config: "0xdf5d04b4691cc67e82fd4db8394d89ff44823a9de29716c924f74bb4f11cc1f7"
|
|
766
|
+
},
|
|
767
|
+
referral: {
|
|
768
|
+
id: "0xa3654ebb63eb06c0f4ff52f8aa6512df9f164f7772bdf15dac3709bd3798dda9",
|
|
769
|
+
object: "0x5658d4bf5ddcba27e4337b4262108b3ad1716643cac8c2054ac341538adc72ec",
|
|
770
|
+
adminCap: "0xc5dc06b9074291259f2cac460c940012c781c4430e42125c541cc43101c3bcbd",
|
|
771
|
+
referralBindings: "0xf63299d58789d99de94092b9011323466e55ca0c1ea1a7a3786a589af46e1c09",
|
|
772
|
+
bindingTableId: "0x1c8202b17267ec8d6cf97ca013615354181a04f179570e42601ff2dae19294b1",
|
|
773
|
+
referralRevenuePool: "0x6abd852caf90769c1b185cdf636d841673fa95528f0550f018b8a138bd283c07",
|
|
774
|
+
revenueTableId: "0x595baa3654c297bff84ab7786a2d250f019cefc66e8df8e89fd9d41e02bd30dd",
|
|
775
|
+
referralTiers: "0x962cb903d8d7346190c5204785ccbb91b61086aa764f674c8145df82335cf83e",
|
|
776
|
+
tiersTableId: "0xeac755a7a8b7798530905ac79e8c114f19d0f130f6eab012954f08faac29c75d",
|
|
777
|
+
authorizedWitnessList: "0xf21b0ed043c9bb70842c0129159f4943dbcc3c9ef2f2f808af65f8be25cfd20e",
|
|
778
|
+
version: "0x1bd4b7285f72e11c316b828c7c47b3f4da18dcec9f9b3dba6d8629cbb6f93e5e"
|
|
779
|
+
},
|
|
780
|
+
vesca: {
|
|
781
|
+
id: "0xb15b6e0cdd85afb5028bea851dd249405e734d800a259147bbc24980629723a4",
|
|
782
|
+
object: "0xb15b6e0cdd85afb5028bea851dd249405e734d800a259147bbc24980629723a4",
|
|
783
|
+
adminCap: "0x8ffa76135c5b85c5fbd73a6448a4a733d826cb63a267ab817656acb77c72d4a5",
|
|
784
|
+
tableId: "0xe3153b2bf124be0b86cb8bd468346a861efd0da52fc42197b54d2f616488a311",
|
|
785
|
+
table: "0x611cb8d9d4d90867467b5ebdf4cc447a0047ed5b01334a28a29fcfe733e3d609",
|
|
786
|
+
treasury: "0xe8c112c09b88158dc6c8e23d1fbae5b3c7136cdee54b7dafc08e65db28c4a5bc",
|
|
787
|
+
config: "0xe0a2ff281e73c1d53cfa85807080f87e833e4f1a7f93dcf8800b3865269a76b9"
|
|
788
|
+
},
|
|
789
|
+
loyaltyProgram: {
|
|
790
|
+
id: "0xd17bcf8b5a59652c36225d478564a8593ae0ed7d650bcacdda1d6fe179127907",
|
|
791
|
+
object: "0xd17bcf8b5a59652c36225d478564a8593ae0ed7d650bcacdda1d6fe179127907",
|
|
792
|
+
rewardPool: "0xf9c090492ef476bd542109d0913ffe871cbfa28578b7114eca2a8c0e5671786f",
|
|
793
|
+
userRewardTableId: "0x748a80395849ed37db1b0e14f2ab5d1d96458d2359ab3a84eb079d0f4ac7cf2e"
|
|
794
|
+
}
|
|
795
|
+
};
|
|
796
|
+
|
|
797
|
+
// src/models/scallopAddress.ts
|
|
496
798
|
var EMPTY_ADDRESSES = {
|
|
497
799
|
core: {
|
|
498
800
|
version: "",
|
|
@@ -785,6 +1087,12 @@ var EMPTY_ADDRESSES = {
|
|
|
785
1087
|
referralTiers: "",
|
|
786
1088
|
tiersTableId: "",
|
|
787
1089
|
authorizedWitnessList: ""
|
|
1090
|
+
},
|
|
1091
|
+
loyaltyProgram: {
|
|
1092
|
+
id: "",
|
|
1093
|
+
object: "",
|
|
1094
|
+
rewardPool: "",
|
|
1095
|
+
userRewardTableId: ""
|
|
788
1096
|
}
|
|
789
1097
|
};
|
|
790
1098
|
var ScallopAddress = class {
|
|
@@ -803,7 +1111,9 @@ var ScallopAddress = class {
|
|
|
803
1111
|
this._auth = auth;
|
|
804
1112
|
this._id = id;
|
|
805
1113
|
this._network = network || "mainnet";
|
|
806
|
-
this._addressesMap = /* @__PURE__ */ new Map();
|
|
1114
|
+
this._addressesMap = IS_VE_SCA_TEST ? /* @__PURE__ */ new Map([["mainnet", TEST_ADDRESSES]]) : /* @__PURE__ */ new Map();
|
|
1115
|
+
if (IS_VE_SCA_TEST)
|
|
1116
|
+
this._currentAddresses = TEST_ADDRESSES;
|
|
807
1117
|
}
|
|
808
1118
|
/**
|
|
809
1119
|
* Get addresses API id.
|
|
@@ -1091,8 +1401,8 @@ var ScallopAddress = class {
|
|
|
1091
1401
|
};
|
|
1092
1402
|
|
|
1093
1403
|
// src/models/scallopClient.ts
|
|
1094
|
-
var
|
|
1095
|
-
var
|
|
1404
|
+
var import_utils22 = require("@mysten/sui.js/utils");
|
|
1405
|
+
var import_sui_kit12 = require("@scallop-io/sui-kit");
|
|
1096
1406
|
|
|
1097
1407
|
// src/models/scallopUtils.ts
|
|
1098
1408
|
var import_utils9 = require("@mysten/sui.js/utils");
|
|
@@ -1113,7 +1423,37 @@ var requireSender = (txBlock) => {
|
|
|
1113
1423
|
}
|
|
1114
1424
|
return sender;
|
|
1115
1425
|
};
|
|
1116
|
-
var
|
|
1426
|
+
var checkVesca = (prevUnlockAtInMillisTimestamp) => {
|
|
1427
|
+
if (prevUnlockAtInMillisTimestamp === void 0) {
|
|
1428
|
+
throw new Error("veSca not found");
|
|
1429
|
+
}
|
|
1430
|
+
};
|
|
1431
|
+
var checkVescaExpired = (prevUnlockAtInMillisTimestamp) => {
|
|
1432
|
+
if (prevUnlockAtInMillisTimestamp <= (/* @__PURE__ */ new Date()).getTime()) {
|
|
1433
|
+
throw new Error("veSca is expired, use renewExpiredVeScaQuick instead");
|
|
1434
|
+
}
|
|
1435
|
+
};
|
|
1436
|
+
var checkExtendLockPeriod = (lockPeriodInDays, newUnlockAtInSecondTimestamp, prevUnlockAtInMillisTimestamp) => {
|
|
1437
|
+
checkVesca(prevUnlockAtInMillisTimestamp);
|
|
1438
|
+
checkVescaExpired(prevUnlockAtInMillisTimestamp);
|
|
1439
|
+
const prevUnlockAtInSecondTimestamp = Math.floor(
|
|
1440
|
+
prevUnlockAtInMillisTimestamp / 1e3
|
|
1441
|
+
);
|
|
1442
|
+
if (lockPeriodInDays < 1) {
|
|
1443
|
+
throw new Error("Minimum lock period is 1 day");
|
|
1444
|
+
}
|
|
1445
|
+
const availableLockPeriodInDays = Math.floor(
|
|
1446
|
+
(newUnlockAtInSecondTimestamp - prevUnlockAtInSecondTimestamp) / UNLOCK_ROUND_DURATION
|
|
1447
|
+
);
|
|
1448
|
+
console.log("availableLockPeriodInDays", availableLockPeriodInDays);
|
|
1449
|
+
if (lockPeriodInDays > availableLockPeriodInDays) {
|
|
1450
|
+
throw new Error(
|
|
1451
|
+
`Cannot extend lock period by ${lockPeriodInDays} days, maximum lock period is ~4 years (${MAX_LOCK_ROUNDS} days), remaining lock period is ${MAX_LOCK_ROUNDS - availableLockPeriodInDays}`
|
|
1452
|
+
);
|
|
1453
|
+
}
|
|
1454
|
+
};
|
|
1455
|
+
var checkLockSca = (scaAmountOrCoin, lockPeriodInDays, newUnlockAtInSecondTimestamp, prevUnlockAtInMillisTimestamp) => {
|
|
1456
|
+
const prevUnlockAtInSecondTimestamp = prevUnlockAtInMillisTimestamp ? Math.floor(prevUnlockAtInMillisTimestamp / 1e3) : void 0;
|
|
1117
1457
|
const isInitialLock = !prevUnlockAtInSecondTimestamp;
|
|
1118
1458
|
const isLockExpired = !isInitialLock && prevUnlockAtInSecondTimestamp * 1e3 <= (/* @__PURE__ */ new Date()).getTime();
|
|
1119
1459
|
if (isInitialLock || isLockExpired) {
|
|
@@ -1138,52 +1478,36 @@ var checkLockSca = (scaAmountOrCoin, lockPeriodInDays, newUnlockAtInSecondTimest
|
|
|
1138
1478
|
);
|
|
1139
1479
|
}
|
|
1140
1480
|
} else {
|
|
1141
|
-
checkVesca(
|
|
1481
|
+
checkVesca(prevUnlockAtInMillisTimestamp);
|
|
1482
|
+
checkVescaExpired(prevUnlockAtInMillisTimestamp);
|
|
1142
1483
|
if (typeof scaAmountOrCoin === "number" && scaAmountOrCoin < MIN_TOP_UP_AMOUNT) {
|
|
1143
1484
|
throw new Error("Minimum top up amount is 1 SCA");
|
|
1144
1485
|
}
|
|
1145
|
-
if (
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
);
|
|
1151
|
-
}
|
|
1152
|
-
}
|
|
1153
|
-
}
|
|
1154
|
-
};
|
|
1155
|
-
var checkExtendLockPeriod = (lockPeriodInDays, newUnlockAtInSecondTimestamp, prevUnlockAtInSecondTimestamp) => {
|
|
1156
|
-
checkVesca(prevUnlockAtInSecondTimestamp);
|
|
1157
|
-
if (lockPeriodInDays <= 0) {
|
|
1158
|
-
throw new Error("Lock period must be greater than 0");
|
|
1159
|
-
}
|
|
1160
|
-
const isInitialLock = !prevUnlockAtInSecondTimestamp;
|
|
1161
|
-
const isLockExpired = !isInitialLock && prevUnlockAtInSecondTimestamp * 1e3 <= (/* @__PURE__ */ new Date()).getTime();
|
|
1162
|
-
if (isLockExpired) {
|
|
1163
|
-
throw new Error("veSca is expired, use renewExpiredVeScaQuick instead");
|
|
1164
|
-
}
|
|
1165
|
-
if (prevUnlockAtInSecondTimestamp) {
|
|
1166
|
-
const totalLockDuration = newUnlockAtInSecondTimestamp - prevUnlockAtInSecondTimestamp;
|
|
1167
|
-
if (totalLockDuration > MAX_LOCK_DURATION - UNLOCK_ROUND_DURATION) {
|
|
1168
|
-
throw new Error(
|
|
1169
|
-
`Maximum lock period is ~4 years (${MAX_LOCK_ROUNDS - 1} days)`
|
|
1486
|
+
if (newUnlockAtInSecondTimestamp && lockPeriodInDays) {
|
|
1487
|
+
checkExtendLockPeriod(
|
|
1488
|
+
lockPeriodInDays,
|
|
1489
|
+
newUnlockAtInSecondTimestamp,
|
|
1490
|
+
prevUnlockAtInMillisTimestamp
|
|
1170
1491
|
);
|
|
1171
1492
|
}
|
|
1172
1493
|
}
|
|
1173
1494
|
};
|
|
1174
|
-
var checkExtendLockAmount = (scaAmount,
|
|
1175
|
-
checkVesca(
|
|
1495
|
+
var checkExtendLockAmount = (scaAmount, prevUnlockAtInMillisTimestamp) => {
|
|
1496
|
+
checkVesca(prevUnlockAtInMillisTimestamp);
|
|
1497
|
+
checkVescaExpired(prevUnlockAtInMillisTimestamp);
|
|
1176
1498
|
if (scaAmount < MIN_TOP_UP_AMOUNT) {
|
|
1177
1499
|
throw new Error("Minimum top up amount is 1 SCA");
|
|
1178
1500
|
}
|
|
1179
|
-
const isInitialLock = !
|
|
1180
|
-
const isLockExpired = !isInitialLock &&
|
|
1501
|
+
const isInitialLock = !prevUnlockAtInMillisTimestamp;
|
|
1502
|
+
const isLockExpired = !isInitialLock && prevUnlockAtInMillisTimestamp <= (/* @__PURE__ */ new Date()).getTime();
|
|
1181
1503
|
if (isLockExpired) {
|
|
1182
1504
|
throw new Error("veSca is expired, use renewExpiredVeScaQuick instead");
|
|
1183
1505
|
}
|
|
1184
1506
|
};
|
|
1185
|
-
var checkRenewExpiredVeSca = (scaAmount, lockPeriodInDays,
|
|
1186
|
-
|
|
1507
|
+
var checkRenewExpiredVeSca = (scaAmount, lockPeriodInDays, prevUnlockAtInMillisTimestamp) => {
|
|
1508
|
+
if (!prevUnlockAtInMillisTimestamp || prevUnlockAtInMillisTimestamp > (/* @__PURE__ */ new Date()).getTime()) {
|
|
1509
|
+
throw new Error("Renew method can only be used for expired veSca");
|
|
1510
|
+
}
|
|
1187
1511
|
if (scaAmount < MIN_INITIAL_LOCK_AMOUNT) {
|
|
1188
1512
|
throw new Error("Minimum lock amount for renewing expired vesca 10 SCA");
|
|
1189
1513
|
}
|
|
@@ -1194,11 +1518,6 @@ var checkRenewExpiredVeSca = (scaAmount, lockPeriodInDays, prevUnlockAtInSecondT
|
|
|
1194
1518
|
);
|
|
1195
1519
|
}
|
|
1196
1520
|
};
|
|
1197
|
-
var checkVesca = (prevUnlockAtInSecondTimestamp) => {
|
|
1198
|
-
if (prevUnlockAtInSecondTimestamp === void 0) {
|
|
1199
|
-
throw new Error("veSca not found");
|
|
1200
|
-
}
|
|
1201
|
-
};
|
|
1202
1521
|
|
|
1203
1522
|
// src/utils/query.ts
|
|
1204
1523
|
var import_bignumber = __toESM(require("bignumber.js"));
|
|
@@ -1299,13 +1618,14 @@ var calculateMarketPoolData = (utils, parsedMarketPoolData) => {
|
|
|
1299
1618
|
};
|
|
1300
1619
|
};
|
|
1301
1620
|
var parseOriginMarketCollateralData = (originMarketCollateralData) => {
|
|
1621
|
+
const divisor = 2 ** 32;
|
|
1302
1622
|
return {
|
|
1303
1623
|
coinType: (0, import_utils.normalizeStructTag)(originMarketCollateralData.type.name),
|
|
1304
|
-
collateralFactor: Number(originMarketCollateralData.collateralFactor.value) /
|
|
1305
|
-
liquidationFactor: Number(originMarketCollateralData.liquidationFactor.value) /
|
|
1306
|
-
liquidationDiscount: Number(originMarketCollateralData.liquidationDiscount.value) /
|
|
1307
|
-
liquidationPanelty: Number(originMarketCollateralData.liquidationPanelty.value) /
|
|
1308
|
-
liquidationReserveFactor: Number(originMarketCollateralData.liquidationReserveFactor.value) /
|
|
1624
|
+
collateralFactor: Number(originMarketCollateralData.collateralFactor.value) / divisor,
|
|
1625
|
+
liquidationFactor: Number(originMarketCollateralData.liquidationFactor.value) / divisor,
|
|
1626
|
+
liquidationDiscount: Number(originMarketCollateralData.liquidationDiscount.value) / divisor,
|
|
1627
|
+
liquidationPanelty: Number(originMarketCollateralData.liquidationPanelty.value) / divisor,
|
|
1628
|
+
liquidationReserveFactor: Number(originMarketCollateralData.liquidationReserveFactor.value) / divisor,
|
|
1309
1629
|
maxCollateralAmount: Number(originMarketCollateralData.maxCollateralAmount),
|
|
1310
1630
|
totalCollateralAmount: Number(
|
|
1311
1631
|
originMarketCollateralData.totalCollateralAmount
|
|
@@ -1647,15 +1967,6 @@ var findClosestUnlockRound = (unlockAtInSecondTimestamp) => {
|
|
|
1647
1967
|
// src/queries/coreQuery.ts
|
|
1648
1968
|
var import_bignumber2 = __toESM(require("bignumber.js"));
|
|
1649
1969
|
var queryMarket = async (query, indexer = false) => {
|
|
1650
|
-
const packageId = query.address.get("core.packages.query.id");
|
|
1651
|
-
const marketId = query.address.get("core.market");
|
|
1652
|
-
const queryTarget = `${packageId}::market_query::market_data`;
|
|
1653
|
-
const args = [marketId];
|
|
1654
|
-
const queryResult = await query.cache.queryInspectTxn(
|
|
1655
|
-
{ queryTarget, args }
|
|
1656
|
-
// txBlock
|
|
1657
|
-
);
|
|
1658
|
-
const marketData = queryResult.events[0].parsedJson;
|
|
1659
1970
|
const coinPrices = await query.utils.getCoinPrices();
|
|
1660
1971
|
const pools = {};
|
|
1661
1972
|
const collaterals = {};
|
|
@@ -1676,6 +1987,12 @@ var queryMarket = async (query, indexer = false) => {
|
|
|
1676
1987
|
collaterals: marketIndexer.collaterals
|
|
1677
1988
|
};
|
|
1678
1989
|
}
|
|
1990
|
+
const packageId = query.address.get("core.packages.query.id");
|
|
1991
|
+
const marketId = query.address.get("core.market");
|
|
1992
|
+
const queryTarget = `${packageId}::market_query::market_data`;
|
|
1993
|
+
const args = [marketId];
|
|
1994
|
+
const queryResult = await query.cache.queryInspectTxn({ queryTarget, args });
|
|
1995
|
+
const marketData = queryResult.events[0].parsedJson;
|
|
1679
1996
|
for (const pool of marketData.pools) {
|
|
1680
1997
|
const coinType = (0, import_utils2.normalizeStructTag)(pool.type.name);
|
|
1681
1998
|
const poolCoinName = query.utils.parseCoinNameFromType(coinType);
|
|
@@ -1790,18 +2107,20 @@ var getMarketPools = async (query, poolCoinNames, indexer = false) => {
|
|
|
1790
2107
|
}
|
|
1791
2108
|
return marketPools;
|
|
1792
2109
|
}
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
2110
|
+
Promise.allSettled(
|
|
2111
|
+
poolCoinNames.map(async (poolCoinName) => {
|
|
2112
|
+
const marketPool = await getMarketPool(
|
|
2113
|
+
query,
|
|
2114
|
+
poolCoinName,
|
|
2115
|
+
indexer,
|
|
2116
|
+
marketObjectResponse.data,
|
|
2117
|
+
coinPrices?.[poolCoinName]
|
|
2118
|
+
);
|
|
2119
|
+
if (marketPool) {
|
|
2120
|
+
marketPools[poolCoinName] = marketPool;
|
|
2121
|
+
}
|
|
2122
|
+
})
|
|
2123
|
+
);
|
|
1805
2124
|
return marketPools;
|
|
1806
2125
|
};
|
|
1807
2126
|
var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, coinPrice) => {
|
|
@@ -1939,10 +2258,12 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
|
|
|
1939
2258
|
var getMarketCollaterals = async (query, collateralCoinNames, indexer = false) => {
|
|
1940
2259
|
collateralCoinNames = collateralCoinNames || [...SUPPORT_COLLATERALS];
|
|
1941
2260
|
const marketId = query.address.get("core.market");
|
|
1942
|
-
const marketObjectResponse = await
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
2261
|
+
const [marketObjectResponse, coinPrices] = await Promise.all([
|
|
2262
|
+
query.cache.queryGetObject(marketId, {
|
|
2263
|
+
showContent: true
|
|
2264
|
+
}),
|
|
2265
|
+
query.utils.getCoinPrices(collateralCoinNames ?? [])
|
|
2266
|
+
]);
|
|
1946
2267
|
const marketCollaterals = {};
|
|
1947
2268
|
if (indexer) {
|
|
1948
2269
|
const marketCollateralsIndexer = await query.indexer.getMarketCollaterals();
|
|
@@ -1957,29 +2278,23 @@ var getMarketCollaterals = async (query, collateralCoinNames, indexer = false) =
|
|
|
1957
2278
|
}
|
|
1958
2279
|
return marketCollaterals;
|
|
1959
2280
|
}
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
2281
|
+
await Promise.allSettled(
|
|
2282
|
+
collateralCoinNames.map(async (collateralCoinName) => {
|
|
2283
|
+
const marketCollateral = await getMarketCollateral(
|
|
2284
|
+
query,
|
|
2285
|
+
collateralCoinName,
|
|
2286
|
+
indexer,
|
|
2287
|
+
marketObjectResponse.data,
|
|
2288
|
+
coinPrices?.[collateralCoinName]
|
|
2289
|
+
);
|
|
2290
|
+
if (marketCollateral) {
|
|
2291
|
+
marketCollaterals[collateralCoinName] = marketCollateral;
|
|
2292
|
+
}
|
|
2293
|
+
})
|
|
2294
|
+
);
|
|
1972
2295
|
return marketCollaterals;
|
|
1973
2296
|
};
|
|
1974
2297
|
var getMarketCollateral = async (query, collateralCoinName, indexer = false, marketObject, coinPrice) => {
|
|
1975
|
-
const marketId = query.address.get("core.market");
|
|
1976
|
-
marketObject = marketObject || (await query.cache.queryGetObject(marketId, {
|
|
1977
|
-
showContent: true
|
|
1978
|
-
})).data;
|
|
1979
|
-
coinPrice = coinPrice || (await query.utils.getCoinPrices([collateralCoinName]))?.[collateralCoinName];
|
|
1980
|
-
let marketCollateral;
|
|
1981
|
-
let riskModel;
|
|
1982
|
-
let collateralStat;
|
|
1983
2298
|
if (indexer) {
|
|
1984
2299
|
const marketCollateralIndexer = await query.indexer.getMarketCollateral(collateralCoinName);
|
|
1985
2300
|
marketCollateralIndexer.coinPrice = coinPrice || marketCollateralIndexer.coinPrice;
|
|
@@ -1988,6 +2303,14 @@ var getMarketCollateral = async (query, collateralCoinName, indexer = false, mar
|
|
|
1988
2303
|
);
|
|
1989
2304
|
return marketCollateralIndexer;
|
|
1990
2305
|
}
|
|
2306
|
+
let marketCollateral;
|
|
2307
|
+
let riskModel;
|
|
2308
|
+
let collateralStat;
|
|
2309
|
+
const marketId = query.address.get("core.market");
|
|
2310
|
+
marketObject = marketObject || (await query.cache.queryGetObject(marketId, {
|
|
2311
|
+
showContent: true
|
|
2312
|
+
})).data;
|
|
2313
|
+
coinPrice = coinPrice || (await query.utils.getCoinPrices([collateralCoinName]))?.[collateralCoinName];
|
|
1991
2314
|
if (marketObject) {
|
|
1992
2315
|
if (marketObject.content && "fields" in marketObject.content) {
|
|
1993
2316
|
const fields = marketObject.content.fields;
|
|
@@ -2082,15 +2405,17 @@ var getObligations = async (query, ownerAddress) => {
|
|
|
2082
2405
|
const keyObjectIds = keyObjectsResponse.map((ref) => ref?.data?.objectId).filter((id) => id !== void 0);
|
|
2083
2406
|
const keyObjects = await query.cache.queryGetObjects(keyObjectIds);
|
|
2084
2407
|
const obligations = [];
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2408
|
+
await Promise.allSettled(
|
|
2409
|
+
keyObjects.map(async (keyObject) => {
|
|
2410
|
+
const keyId = keyObject.objectId;
|
|
2411
|
+
if (keyObject.content && "fields" in keyObject.content) {
|
|
2412
|
+
const fields = keyObject.content.fields;
|
|
2413
|
+
const obligationId = String(fields.ownership.fields.of);
|
|
2414
|
+
const locked = await getObligationLocked(query, obligationId);
|
|
2415
|
+
obligations.push({ id: obligationId, keyId, locked });
|
|
2416
|
+
}
|
|
2417
|
+
})
|
|
2418
|
+
);
|
|
2094
2419
|
return obligations;
|
|
2095
2420
|
};
|
|
2096
2421
|
var getObligationLocked = async (query, obligationId) => {
|
|
@@ -2544,12 +2869,6 @@ var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames, indexer
|
|
|
2544
2869
|
borrowIncentiveCoinNames = borrowIncentiveCoinNames || [
|
|
2545
2870
|
...SUPPORT_BORROW_INCENTIVE_POOLS
|
|
2546
2871
|
];
|
|
2547
|
-
const queryPkgId = query.address.get("borrowIncentive.query");
|
|
2548
|
-
const incentivePoolsId = query.address.get("borrowIncentive.incentivePools");
|
|
2549
|
-
const queryTarget = `${queryPkgId}::incentive_pools_query::incentive_pools_data`;
|
|
2550
|
-
const args = [incentivePoolsId];
|
|
2551
|
-
const queryResult = await query.cache.queryInspectTxn({ queryTarget, args });
|
|
2552
|
-
const borrowIncentivePoolsQueryData = queryResult.events[0].parsedJson;
|
|
2553
2872
|
const borrowIncentivePools = {};
|
|
2554
2873
|
const coinPrices = await query.utils.getCoinPrices(
|
|
2555
2874
|
[
|
|
@@ -2571,6 +2890,12 @@ var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames, indexer
|
|
|
2571
2890
|
}
|
|
2572
2891
|
return borrowIncentivePools;
|
|
2573
2892
|
}
|
|
2893
|
+
const queryPkgId = query.address.get("borrowIncentive.query");
|
|
2894
|
+
const incentivePoolsId = query.address.get("borrowIncentive.incentivePools");
|
|
2895
|
+
const queryTarget = `${queryPkgId}::incentive_pools_query::incentive_pools_data`;
|
|
2896
|
+
const args = [incentivePoolsId];
|
|
2897
|
+
const queryResult = await query.cache.queryInspectTxn({ queryTarget, args });
|
|
2898
|
+
const borrowIncentivePoolsQueryData = queryResult.events[0].parsedJson;
|
|
2574
2899
|
for (const pool of borrowIncentivePoolsQueryData.incentive_pools) {
|
|
2575
2900
|
const borrowIncentivePoolPoints = {};
|
|
2576
2901
|
const parsedBorrowIncentivePoolData = parseOriginBorrowIncentivePoolData(pool);
|
|
@@ -2780,34 +3105,42 @@ var getLendings = async (query, poolCoinNames, ownerAddress, indexer = false) =>
|
|
|
2780
3105
|
const stakeMarketCoinNames = marketCoinNames.filter(
|
|
2781
3106
|
(marketCoinName) => SUPPORT_SPOOLS.includes(marketCoinName)
|
|
2782
3107
|
);
|
|
2783
|
-
const
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
3108
|
+
const [
|
|
3109
|
+
marketPools,
|
|
3110
|
+
spools,
|
|
3111
|
+
coinAmounts,
|
|
3112
|
+
marketCoinAmounts,
|
|
3113
|
+
allStakeAccounts,
|
|
3114
|
+
coinPrices
|
|
3115
|
+
] = await Promise.all([
|
|
3116
|
+
query.getMarketPools(poolCoinNames, indexer),
|
|
3117
|
+
query.getSpools(stakeMarketCoinNames, indexer),
|
|
3118
|
+
query.getCoinAmounts(poolCoinNames, ownerAddress),
|
|
3119
|
+
query.getMarketCoinAmounts(marketCoinNames, ownerAddress),
|
|
3120
|
+
query.getAllStakeAccounts(ownerAddress),
|
|
3121
|
+
query.utils.getCoinPrices(poolCoinNames)
|
|
3122
|
+
]);
|
|
2792
3123
|
const lendings = {};
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
3124
|
+
await Promise.allSettled(
|
|
3125
|
+
poolCoinNames.map(async (poolCoinName) => {
|
|
3126
|
+
const stakeMarketCoinName = stakeMarketCoinNames.find(
|
|
3127
|
+
(marketCoinName2) => marketCoinName2 === query.utils.parseMarketCoinName(poolCoinName)
|
|
3128
|
+
);
|
|
3129
|
+
const marketCoinName = query.utils.parseMarketCoinName(poolCoinName);
|
|
3130
|
+
lendings[poolCoinName] = await getLending(
|
|
3131
|
+
query,
|
|
3132
|
+
poolCoinName,
|
|
3133
|
+
ownerAddress,
|
|
3134
|
+
indexer,
|
|
3135
|
+
marketPools?.[poolCoinName],
|
|
3136
|
+
stakeMarketCoinName ? spools[stakeMarketCoinName] : void 0,
|
|
3137
|
+
stakeMarketCoinName ? allStakeAccounts[stakeMarketCoinName] : void 0,
|
|
3138
|
+
coinAmounts?.[poolCoinName],
|
|
3139
|
+
marketCoinAmounts?.[marketCoinName],
|
|
3140
|
+
coinPrices?.[poolCoinName] ?? 0
|
|
3141
|
+
);
|
|
3142
|
+
})
|
|
3143
|
+
);
|
|
2811
3144
|
return lendings;
|
|
2812
3145
|
};
|
|
2813
3146
|
var getLending = async (query, poolCoinName, ownerAddress, indexer = false, marketPool, spool, stakeAccounts, coinAmount, marketCoinAmount, coinPrice) => {
|
|
@@ -3275,6 +3608,7 @@ var getTotalValueLocked = async (query, indexer = false) => {
|
|
|
3275
3608
|
var import_bignumber5 = __toESM(require("bignumber.js"));
|
|
3276
3609
|
var import_sui_kit2 = require("@scallop-io/sui-kit");
|
|
3277
3610
|
var import_bcs = require("@mysten/sui.js/bcs");
|
|
3611
|
+
var import_zod = require("zod");
|
|
3278
3612
|
var getVescaKeys = async (query, ownerAddress) => {
|
|
3279
3613
|
const owner = ownerAddress || query.suiKit.currentAddress();
|
|
3280
3614
|
const veScaObjId = query.address.get("vesca.object");
|
|
@@ -3303,10 +3637,9 @@ var getVescaKeys = async (query, ownerAddress) => {
|
|
|
3303
3637
|
};
|
|
3304
3638
|
var getVeScas = async (query, ownerAddress) => {
|
|
3305
3639
|
const keyObjectDatas = await getVescaKeys(query, ownerAddress);
|
|
3306
|
-
const
|
|
3307
|
-
const
|
|
3308
|
-
|
|
3309
|
-
const veSca = await getVeSca(query, keyId);
|
|
3640
|
+
const veScas = Array(keyObjectDatas.length).fill(null);
|
|
3641
|
+
const tasks = keyObjectDatas.map(async (veScaKey, idx) => {
|
|
3642
|
+
const veSca = await getVeSca(query, veScaKey);
|
|
3310
3643
|
if (veSca) {
|
|
3311
3644
|
veScas[idx] = veSca;
|
|
3312
3645
|
}
|
|
@@ -3314,15 +3647,25 @@ var getVeScas = async (query, ownerAddress) => {
|
|
|
3314
3647
|
await Promise.allSettled(tasks);
|
|
3315
3648
|
return veScas.filter(Boolean).sort((a, b) => b.currentVeScaBalance - a.currentVeScaBalance);
|
|
3316
3649
|
};
|
|
3317
|
-
var
|
|
3650
|
+
var SuiObjectRefZod = import_zod.z.object({
|
|
3651
|
+
objectId: import_zod.z.string(),
|
|
3652
|
+
digest: import_zod.z.string(),
|
|
3653
|
+
version: import_zod.z.string()
|
|
3654
|
+
});
|
|
3655
|
+
var getVeSca = async (query, veScaKey, ownerAddress) => {
|
|
3318
3656
|
const tableId = query.address.get(`vesca.tableId`);
|
|
3319
|
-
|
|
3657
|
+
veScaKey = veScaKey || (await getVescaKeys(query, ownerAddress))[0];
|
|
3658
|
+
if (!veScaKey)
|
|
3659
|
+
return void 0;
|
|
3660
|
+
if (typeof veScaKey === "object") {
|
|
3661
|
+
veScaKey = SuiObjectRefZod.parse(veScaKey);
|
|
3662
|
+
}
|
|
3320
3663
|
let vesca = void 0;
|
|
3321
3664
|
const veScaDynamicFieldObjectResponse = await query.cache.queryGetDynamicFieldObject({
|
|
3322
3665
|
parentId: tableId,
|
|
3323
3666
|
name: {
|
|
3324
3667
|
type: "0x2::object::ID",
|
|
3325
|
-
value:
|
|
3668
|
+
value: typeof veScaKey === "string" ? veScaKey : veScaKey.objectId
|
|
3326
3669
|
}
|
|
3327
3670
|
});
|
|
3328
3671
|
const veScaDynamicFieldObject = veScaDynamicFieldObjectResponse.data;
|
|
@@ -3337,7 +3680,9 @@ var getVeSca = async (query, veScaKeyId, ownerAddress) => {
|
|
|
3337
3680
|
const currentVeScaBalance = lockedScaCoin * (Math.floor(remainingLockPeriodInMilliseconds / 1e3) / MAX_LOCK_DURATION);
|
|
3338
3681
|
vesca = {
|
|
3339
3682
|
id: veScaDynamicFieldObject.objectId,
|
|
3340
|
-
keyId:
|
|
3683
|
+
keyId: typeof veScaKey === "string" ? veScaKey : veScaKey.objectId,
|
|
3684
|
+
keyObject: typeof veScaKey === "string" ? void 0 : veScaKey,
|
|
3685
|
+
object: SuiObjectRefZod.parse(veScaDynamicFieldObjectResponse.data),
|
|
3341
3686
|
lockedScaAmount,
|
|
3342
3687
|
lockedScaCoin,
|
|
3343
3688
|
currentVeScaBalance,
|
|
@@ -3346,10 +3691,10 @@ var getVeSca = async (query, veScaKeyId, ownerAddress) => {
|
|
|
3346
3691
|
}
|
|
3347
3692
|
return vesca;
|
|
3348
3693
|
};
|
|
3349
|
-
var getTotalVeScaTreasuryAmount = async (query) => {
|
|
3694
|
+
var getTotalVeScaTreasuryAmount = async (query, veScaTreasury) => {
|
|
3350
3695
|
const veScaPkgId = query.address.get("vesca.id");
|
|
3351
3696
|
const veScaConfig = query.address.get("vesca.config");
|
|
3352
|
-
|
|
3697
|
+
veScaTreasury = veScaTreasury ?? query.address.get("vesca.treasury");
|
|
3353
3698
|
const refreshQueryTarget = `${veScaPkgId}::treasury::refresh`;
|
|
3354
3699
|
const refreshArgs = [veScaConfig, veScaTreasury, import_sui_kit2.SUI_CLOCK_OBJECT_ID];
|
|
3355
3700
|
const veScaAmountQueryTarget = `${veScaPkgId}::treasury::total_ve_sca_amount`;
|
|
@@ -3385,8 +3730,7 @@ var getTotalVeScaTreasuryAmount = async (query) => {
|
|
|
3385
3730
|
],
|
|
3386
3731
|
queryFn: async () => {
|
|
3387
3732
|
return await query.suiKit.inspectTxn(txBytes);
|
|
3388
|
-
}
|
|
3389
|
-
staleTime: 8e3
|
|
3733
|
+
}
|
|
3390
3734
|
});
|
|
3391
3735
|
const results = res.results;
|
|
3392
3736
|
if (results && results[1].returnValues) {
|
|
@@ -3396,6 +3740,30 @@ var getTotalVeScaTreasuryAmount = async (query) => {
|
|
|
3396
3740
|
}
|
|
3397
3741
|
return "0";
|
|
3398
3742
|
};
|
|
3743
|
+
var getVeScaTreasuryInfo = async (query) => {
|
|
3744
|
+
const veScaTreasuryId = query.address.get("vesca.treasury");
|
|
3745
|
+
const veScaTreasury = await query.cache.queryGetObject(veScaTreasuryId, {
|
|
3746
|
+
showContent: true
|
|
3747
|
+
});
|
|
3748
|
+
if (!veScaTreasury || veScaTreasury.data?.content?.dataType !== "moveObject")
|
|
3749
|
+
return null;
|
|
3750
|
+
const treasuryFields = veScaTreasury.data.content.fields;
|
|
3751
|
+
console.log(treasuryFields);
|
|
3752
|
+
const totalLockedSca = (0, import_bignumber5.default)(
|
|
3753
|
+
treasuryFields.unlock_schedule.fields.locked_sca_amount
|
|
3754
|
+
).shiftedBy(-9).toNumber();
|
|
3755
|
+
const totalVeSca = (0, import_bignumber5.default)(
|
|
3756
|
+
await getTotalVeScaTreasuryAmount(query, veScaTreasury.data) ?? 0
|
|
3757
|
+
).shiftedBy(-9).toNumber();
|
|
3758
|
+
const averageLockingPeriod = totalLockedSca > 0 ? totalVeSca / totalLockedSca * 4 : 0;
|
|
3759
|
+
const averageLockingPeriodUnit = "year";
|
|
3760
|
+
return {
|
|
3761
|
+
totalLockedSca,
|
|
3762
|
+
totalVeSca,
|
|
3763
|
+
averageLockingPeriod,
|
|
3764
|
+
averageLockingPeriodUnit
|
|
3765
|
+
};
|
|
3766
|
+
};
|
|
3399
3767
|
|
|
3400
3768
|
// src/queries/referralQuery.ts
|
|
3401
3769
|
var queryVeScaKeyIdFromReferralBindings = async (query, refereeAddress) => {
|
|
@@ -3413,6 +3781,57 @@ var queryVeScaKeyIdFromReferralBindings = async (query, refereeAddress) => {
|
|
|
3413
3781
|
return fields.value;
|
|
3414
3782
|
};
|
|
3415
3783
|
|
|
3784
|
+
// src/queries/loyaltyProgramQuery.ts
|
|
3785
|
+
var import_bignumber6 = __toESM(require("bignumber.js"));
|
|
3786
|
+
var import_zod2 = require("zod");
|
|
3787
|
+
var rewardPoolFieldsZod = import_zod2.z.object({
|
|
3788
|
+
balance: import_zod2.z.string(),
|
|
3789
|
+
enable_claim: import_zod2.z.boolean()
|
|
3790
|
+
}).transform((value) => ({
|
|
3791
|
+
totalPoolReward: (0, import_bignumber6.default)(value.balance).shiftedBy(-9).toNumber(),
|
|
3792
|
+
isClaimEnabled: value.enable_claim
|
|
3793
|
+
}));
|
|
3794
|
+
var userRewardFieldsZod = import_zod2.z.object({
|
|
3795
|
+
value: import_zod2.z.string()
|
|
3796
|
+
}).transform((value) => (0, import_bignumber6.default)(value.value).shiftedBy(-9).toNumber());
|
|
3797
|
+
var getLoyaltyProgramInformations = async (query, veScaKey) => {
|
|
3798
|
+
const rewardPool = query.address.get("loyaltyProgram.rewardPool");
|
|
3799
|
+
const rewardPoolObject = await query.cache.queryGetObject(rewardPool, {
|
|
3800
|
+
showContent: true
|
|
3801
|
+
});
|
|
3802
|
+
if (rewardPoolObject.data?.content?.dataType !== "moveObject")
|
|
3803
|
+
return null;
|
|
3804
|
+
const rewardPoolFields = rewardPoolObject.data.content.fields;
|
|
3805
|
+
const { isClaimEnabled, totalPoolReward } = rewardPoolFieldsZod.parse(
|
|
3806
|
+
rewardPoolFields
|
|
3807
|
+
);
|
|
3808
|
+
const result = {
|
|
3809
|
+
pendingReward: 0,
|
|
3810
|
+
totalPoolReward,
|
|
3811
|
+
isClaimEnabled
|
|
3812
|
+
};
|
|
3813
|
+
veScaKey = veScaKey || (await query.getVeScas())[0]?.keyObject;
|
|
3814
|
+
if (!veScaKey)
|
|
3815
|
+
return result;
|
|
3816
|
+
const userRewardTableId = query.address.get(
|
|
3817
|
+
"loyaltyProgram.userRewardTableId"
|
|
3818
|
+
);
|
|
3819
|
+
const userRewardObject = await query.cache.queryGetDynamicFieldObject({
|
|
3820
|
+
parentId: userRewardTableId,
|
|
3821
|
+
name: {
|
|
3822
|
+
type: "0x2::object::ID",
|
|
3823
|
+
value: typeof veScaKey === "string" ? veScaKey : veScaKey.objectId
|
|
3824
|
+
}
|
|
3825
|
+
});
|
|
3826
|
+
if (userRewardObject.data?.content?.dataType !== "moveObject")
|
|
3827
|
+
return result;
|
|
3828
|
+
const userRewardFields = userRewardObject.data.content.fields;
|
|
3829
|
+
result.pendingReward = userRewardFieldsZod.parse(
|
|
3830
|
+
userRewardFields
|
|
3831
|
+
);
|
|
3832
|
+
return result;
|
|
3833
|
+
};
|
|
3834
|
+
|
|
3416
3835
|
// src/models/scallopIndexer.ts
|
|
3417
3836
|
var import_axios2 = __toESM(require("axios"));
|
|
3418
3837
|
var ScallopIndexer = class {
|
|
@@ -3837,15 +4256,17 @@ var ScallopQuery = class {
|
|
|
3837
4256
|
async getStakeRewardPools(stakeMarketCoinNames) {
|
|
3838
4257
|
stakeMarketCoinNames = stakeMarketCoinNames ?? [...SUPPORT_SPOOLS];
|
|
3839
4258
|
const stakeRewardPools = {};
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
4259
|
+
await Promise.allSettled(
|
|
4260
|
+
stakeMarketCoinNames.map(async (stakeMarketCoinName) => {
|
|
4261
|
+
const stakeRewardPool = await getStakeRewardPool(
|
|
4262
|
+
this,
|
|
4263
|
+
stakeMarketCoinName
|
|
4264
|
+
);
|
|
4265
|
+
if (stakeRewardPool) {
|
|
4266
|
+
stakeRewardPools[stakeMarketCoinName] = stakeRewardPool;
|
|
4267
|
+
}
|
|
4268
|
+
})
|
|
4269
|
+
);
|
|
3849
4270
|
return stakeRewardPools;
|
|
3850
4271
|
}
|
|
3851
4272
|
/**
|
|
@@ -3959,11 +4380,11 @@ var ScallopQuery = class {
|
|
|
3959
4380
|
* Get total vesca treasury with movecall
|
|
3960
4381
|
* @returns Promise<string | undefined>
|
|
3961
4382
|
*/
|
|
3962
|
-
async
|
|
3963
|
-
return await
|
|
4383
|
+
async getVeScaTreasuryInfo() {
|
|
4384
|
+
return await getVeScaTreasuryInfo(this);
|
|
3964
4385
|
}
|
|
3965
4386
|
/**
|
|
3966
|
-
* Return binded veScaKeyId of walletAddress if exist
|
|
4387
|
+
* Return binded referrer veScaKeyId of referee walletAddress if exist
|
|
3967
4388
|
* @param walletAddress
|
|
3968
4389
|
* @returns veScaKeyId
|
|
3969
4390
|
*/
|
|
@@ -3986,6 +4407,14 @@ var ScallopQuery = class {
|
|
|
3986
4407
|
async getBindedVeScaKey(obligationId) {
|
|
3987
4408
|
return await getBindedVeScaKey(this, obligationId);
|
|
3988
4409
|
}
|
|
4410
|
+
/**
|
|
4411
|
+
* Get user's veSCA loyalty program informations
|
|
4412
|
+
* @param walletAddress
|
|
4413
|
+
* @returns Loyalty program information
|
|
4414
|
+
*/
|
|
4415
|
+
async getLoyaltyProgramInfos(veScaKey) {
|
|
4416
|
+
return await getLoyaltyProgramInformations(this, veScaKey);
|
|
4417
|
+
}
|
|
3989
4418
|
};
|
|
3990
4419
|
|
|
3991
4420
|
// src/constants/pyth.ts
|
|
@@ -4337,9 +4766,9 @@ var ScallopUtils = class {
|
|
|
4337
4766
|
* @param unlockAtInSecondTimestamp The unlock timestamp from veSca object.
|
|
4338
4767
|
* @return New unlock at in seconds timestamp.
|
|
4339
4768
|
*/
|
|
4340
|
-
getUnlockAt(extendLockPeriodInDay,
|
|
4769
|
+
getUnlockAt(extendLockPeriodInDay, unlockAtInMillisTimestamp) {
|
|
4341
4770
|
const now = Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3);
|
|
4342
|
-
const remainingLockPeriod =
|
|
4771
|
+
const remainingLockPeriod = unlockAtInMillisTimestamp ? Math.max(Math.floor(unlockAtInMillisTimestamp / 1e3) - now, 0) : 0;
|
|
4343
4772
|
let newUnlockAtInSecondTimestamp = 0;
|
|
4344
4773
|
if (remainingLockPeriod === 0) {
|
|
4345
4774
|
const lockPeriod = (extendLockPeriodInDay ?? 1) * UNLOCK_ROUND_DURATION;
|
|
@@ -4359,8 +4788,8 @@ var ScallopUtils = class {
|
|
|
4359
4788
|
};
|
|
4360
4789
|
|
|
4361
4790
|
// src/models/scallopBuilder.ts
|
|
4362
|
-
var
|
|
4363
|
-
var
|
|
4791
|
+
var import_utils21 = require("@mysten/sui.js/utils");
|
|
4792
|
+
var import_sui_kit11 = require("@scallop-io/sui-kit");
|
|
4364
4793
|
|
|
4365
4794
|
// src/builders/coreBuilder.ts
|
|
4366
4795
|
var import_transactions = require("@mysten/sui.js/transactions");
|
|
@@ -5232,7 +5661,10 @@ var generateQuickVeScaMethod = ({
|
|
|
5232
5661
|
},
|
|
5233
5662
|
extendLockPeriodQuick: async (lockPeriodInDays, veScaKey, autoCheck = true) => {
|
|
5234
5663
|
const veSca = await requireVeSca(builder, txBlock, veScaKey);
|
|
5235
|
-
const newUnlockAt = builder.utils.getUnlockAt(
|
|
5664
|
+
const newUnlockAt = builder.utils.getUnlockAt(
|
|
5665
|
+
lockPeriodInDays,
|
|
5666
|
+
veSca?.unlockAt
|
|
5667
|
+
);
|
|
5236
5668
|
if (autoCheck)
|
|
5237
5669
|
checkExtendLockPeriod(lockPeriodInDays, newUnlockAt, veSca?.unlockAt);
|
|
5238
5670
|
if (veSca) {
|
|
@@ -5698,12 +6130,90 @@ var newReferralTxBlock = (builder, initTxBlock) => {
|
|
|
5698
6130
|
});
|
|
5699
6131
|
};
|
|
5700
6132
|
|
|
6133
|
+
// src/builders/loyaltyProgramBuilder.ts
|
|
6134
|
+
var import_transactions4 = require("@mysten/sui.js/transactions");
|
|
6135
|
+
var import_sui_kit10 = require("@scallop-io/sui-kit");
|
|
6136
|
+
var generateLoyaltyProgramNormalMethod = ({ builder, txBlock }) => {
|
|
6137
|
+
const loyaltyProgramIds = {
|
|
6138
|
+
loyaltyProgramPkgId: builder.address.get("loyaltyProgram.id"),
|
|
6139
|
+
rewardPool: builder.address.get("loyaltyProgram.rewardPool"),
|
|
6140
|
+
userRewardTableId: builder.address.get(
|
|
6141
|
+
"loyaltyProgram.userRewardTableId"
|
|
6142
|
+
)
|
|
6143
|
+
};
|
|
6144
|
+
return {
|
|
6145
|
+
claimLoyaltyRevenue: (veScaKey) => {
|
|
6146
|
+
return txBlock.moveCall(
|
|
6147
|
+
`${loyaltyProgramIds.loyaltyProgramPkgId}::reward_pool::redeem_reward`,
|
|
6148
|
+
[loyaltyProgramIds.rewardPool, veScaKey]
|
|
6149
|
+
);
|
|
6150
|
+
}
|
|
6151
|
+
};
|
|
6152
|
+
};
|
|
6153
|
+
var generateLoyaltyProgramQuickMethod = ({
|
|
6154
|
+
builder,
|
|
6155
|
+
txBlock
|
|
6156
|
+
}) => {
|
|
6157
|
+
return {
|
|
6158
|
+
claimLoyaltyRevenueQuick: async (veScaKey) => {
|
|
6159
|
+
veScaKey = veScaKey || (await builder.query.getVeScas())[0]?.keyObject;
|
|
6160
|
+
const sender = requireSender(txBlock);
|
|
6161
|
+
if (!veScaKey)
|
|
6162
|
+
throw new Error(`No veScaKey found for user ${sender}`);
|
|
6163
|
+
const toTransferObject = [];
|
|
6164
|
+
const rewardCoin = txBlock.claimLoyaltyRevenue(veScaKey);
|
|
6165
|
+
try {
|
|
6166
|
+
const existingScaCoin = await builder.suiKit.suiInteractor.selectCoins(
|
|
6167
|
+
sender,
|
|
6168
|
+
Infinity,
|
|
6169
|
+
coinIds.sca
|
|
6170
|
+
);
|
|
6171
|
+
txBlock.mergeCoins(rewardCoin, existingScaCoin);
|
|
6172
|
+
} catch (e) {
|
|
6173
|
+
} finally {
|
|
6174
|
+
toTransferObject.push(rewardCoin);
|
|
6175
|
+
}
|
|
6176
|
+
if (toTransferObject.length > 0) {
|
|
6177
|
+
txBlock.transferObjects(toTransferObject, sender);
|
|
6178
|
+
}
|
|
6179
|
+
}
|
|
6180
|
+
};
|
|
6181
|
+
};
|
|
6182
|
+
var newLoyaltyProgramTxBlock = (builder, initTxBlock) => {
|
|
6183
|
+
const txBlock = initTxBlock instanceof import_transactions4.TransactionBlock ? new import_sui_kit10.SuiTxBlock(initTxBlock) : initTxBlock ? initTxBlock : new import_sui_kit10.SuiTxBlock();
|
|
6184
|
+
const normalMethod = generateLoyaltyProgramNormalMethod({
|
|
6185
|
+
builder,
|
|
6186
|
+
txBlock
|
|
6187
|
+
});
|
|
6188
|
+
const normalTxBlock = new Proxy(txBlock, {
|
|
6189
|
+
get: (target, prop) => {
|
|
6190
|
+
if (prop in normalMethod) {
|
|
6191
|
+
return Reflect.get(normalMethod, prop);
|
|
6192
|
+
}
|
|
6193
|
+
return Reflect.get(target, prop);
|
|
6194
|
+
}
|
|
6195
|
+
});
|
|
6196
|
+
const quickMethod = generateLoyaltyProgramQuickMethod({
|
|
6197
|
+
builder,
|
|
6198
|
+
txBlock: normalTxBlock
|
|
6199
|
+
});
|
|
6200
|
+
return new Proxy(normalTxBlock, {
|
|
6201
|
+
get: (target, prop) => {
|
|
6202
|
+
if (prop in quickMethod) {
|
|
6203
|
+
return Reflect.get(quickMethod, prop);
|
|
6204
|
+
}
|
|
6205
|
+
return Reflect.get(target, prop);
|
|
6206
|
+
}
|
|
6207
|
+
});
|
|
6208
|
+
};
|
|
6209
|
+
|
|
5701
6210
|
// src/builders/index.ts
|
|
5702
6211
|
var newScallopTxBlock = (builder, initTxBlock) => {
|
|
5703
6212
|
const vescaTxBlock = newVeScaTxBlock(builder, initTxBlock);
|
|
6213
|
+
const loyaltyTxBlock = newLoyaltyProgramTxBlock(builder, vescaTxBlock);
|
|
5704
6214
|
const borrowIncentiveTxBlock = newBorrowIncentiveTxBlock(
|
|
5705
6215
|
builder,
|
|
5706
|
-
|
|
6216
|
+
loyaltyTxBlock
|
|
5707
6217
|
);
|
|
5708
6218
|
const referralTxBlock = newReferralTxBlock(builder, borrowIncentiveTxBlock);
|
|
5709
6219
|
const spoolTxBlock = newSpoolTxBlock(builder, referralTxBlock);
|
|
@@ -5718,6 +6228,8 @@ var newScallopTxBlock = (builder, initTxBlock) => {
|
|
|
5718
6228
|
return Reflect.get(referralTxBlock, prop);
|
|
5719
6229
|
} else if (prop in spoolTxBlock) {
|
|
5720
6230
|
return Reflect.get(spoolTxBlock, prop);
|
|
6231
|
+
} else if (prop in loyaltyTxBlock) {
|
|
6232
|
+
return Reflect.get(loyaltyTxBlock, prop);
|
|
5721
6233
|
}
|
|
5722
6234
|
return Reflect.get(target, prop);
|
|
5723
6235
|
}
|
|
@@ -5728,7 +6240,7 @@ var newScallopTxBlock = (builder, initTxBlock) => {
|
|
|
5728
6240
|
var ScallopBuilder = class {
|
|
5729
6241
|
constructor(params, instance) {
|
|
5730
6242
|
this.params = params;
|
|
5731
|
-
this.suiKit = instance?.suiKit ?? new
|
|
6243
|
+
this.suiKit = instance?.suiKit ?? new import_sui_kit11.SuiKit(params);
|
|
5732
6244
|
this.cache = instance?.cache ?? new ScallopCache(DEFAULT_CACHE_OPTIONS, this.suiKit);
|
|
5733
6245
|
this.address = instance?.address ?? new ScallopAddress(
|
|
5734
6246
|
{
|
|
@@ -5748,7 +6260,7 @@ var ScallopBuilder = class {
|
|
|
5748
6260
|
query: this.query,
|
|
5749
6261
|
cache: this.cache
|
|
5750
6262
|
});
|
|
5751
|
-
this.walletAddress = (0,
|
|
6263
|
+
this.walletAddress = (0, import_utils21.normalizeSuiAddress)(
|
|
5752
6264
|
params?.walletAddress || this.suiKit.currentAddress()
|
|
5753
6265
|
);
|
|
5754
6266
|
this.isTestnet = params.networkType ? params.networkType === "testnet" : false;
|
|
@@ -5827,7 +6339,7 @@ var ScallopBuilder = class {
|
|
|
5827
6339
|
var ScallopClient = class {
|
|
5828
6340
|
constructor(params, instance) {
|
|
5829
6341
|
this.params = params;
|
|
5830
|
-
this.suiKit = instance?.suiKit ?? new
|
|
6342
|
+
this.suiKit = instance?.suiKit ?? new import_sui_kit12.SuiKit(params);
|
|
5831
6343
|
this.cache = instance?.cache ?? new ScallopCache(DEFAULT_CACHE_OPTIONS, this.suiKit);
|
|
5832
6344
|
this.address = instance?.address ?? new ScallopAddress(
|
|
5833
6345
|
{
|
|
@@ -5854,7 +6366,7 @@ var ScallopClient = class {
|
|
|
5854
6366
|
utils: this.utils,
|
|
5855
6367
|
cache: this.cache
|
|
5856
6368
|
});
|
|
5857
|
-
this.walletAddress = (0,
|
|
6369
|
+
this.walletAddress = (0, import_utils22.normalizeSuiAddress)(
|
|
5858
6370
|
params?.walletAddress || this.suiKit.currentAddress()
|
|
5859
6371
|
);
|
|
5860
6372
|
}
|
|
@@ -6360,7 +6872,7 @@ var ScallopClient = class {
|
|
|
6360
6872
|
var Scallop = class {
|
|
6361
6873
|
constructor(params, cacheOptions) {
|
|
6362
6874
|
this.params = params;
|
|
6363
|
-
this.suiKit = new
|
|
6875
|
+
this.suiKit = new import_sui_kit13.SuiKit(params);
|
|
6364
6876
|
this.cache = new ScallopCache(
|
|
6365
6877
|
cacheOptions ?? DEFAULT_CACHE_OPTIONS,
|
|
6366
6878
|
this.suiKit
|