@scallop-io/sui-scallop-sdk 0.46.36 → 0.46.37
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 +567 -71
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +557 -61
- 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 +16 -5
- package/src/models/scallopUtils.ts +3 -3
- package/src/queries/index.ts +1 -0
- package/src/queries/loyaltyProgramQuery.ts +77 -0
- 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/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"));
|
|
@@ -3275,6 +3594,7 @@ var getTotalValueLocked = async (query, indexer = false) => {
|
|
|
3275
3594
|
var import_bignumber5 = __toESM(require("bignumber.js"));
|
|
3276
3595
|
var import_sui_kit2 = require("@scallop-io/sui-kit");
|
|
3277
3596
|
var import_bcs = require("@mysten/sui.js/bcs");
|
|
3597
|
+
var import_zod = require("zod");
|
|
3278
3598
|
var getVescaKeys = async (query, ownerAddress) => {
|
|
3279
3599
|
const owner = ownerAddress || query.suiKit.currentAddress();
|
|
3280
3600
|
const veScaObjId = query.address.get("vesca.object");
|
|
@@ -3303,10 +3623,9 @@ var getVescaKeys = async (query, ownerAddress) => {
|
|
|
3303
3623
|
};
|
|
3304
3624
|
var getVeScas = async (query, ownerAddress) => {
|
|
3305
3625
|
const keyObjectDatas = await getVescaKeys(query, ownerAddress);
|
|
3306
|
-
const
|
|
3307
|
-
const
|
|
3308
|
-
|
|
3309
|
-
const veSca = await getVeSca(query, keyId);
|
|
3626
|
+
const veScas = Array(keyObjectDatas.length).fill(null);
|
|
3627
|
+
const tasks = keyObjectDatas.map(async (veScaKey, idx) => {
|
|
3628
|
+
const veSca = await getVeSca(query, veScaKey);
|
|
3310
3629
|
if (veSca) {
|
|
3311
3630
|
veScas[idx] = veSca;
|
|
3312
3631
|
}
|
|
@@ -3314,15 +3633,25 @@ var getVeScas = async (query, ownerAddress) => {
|
|
|
3314
3633
|
await Promise.allSettled(tasks);
|
|
3315
3634
|
return veScas.filter(Boolean).sort((a, b) => b.currentVeScaBalance - a.currentVeScaBalance);
|
|
3316
3635
|
};
|
|
3317
|
-
var
|
|
3636
|
+
var SuiObjectRefZod = import_zod.z.object({
|
|
3637
|
+
objectId: import_zod.z.string(),
|
|
3638
|
+
digest: import_zod.z.string(),
|
|
3639
|
+
version: import_zod.z.string()
|
|
3640
|
+
});
|
|
3641
|
+
var getVeSca = async (query, veScaKey, ownerAddress) => {
|
|
3318
3642
|
const tableId = query.address.get(`vesca.tableId`);
|
|
3319
|
-
|
|
3643
|
+
veScaKey = veScaKey || (await getVescaKeys(query, ownerAddress))[0];
|
|
3644
|
+
if (!veScaKey)
|
|
3645
|
+
return void 0;
|
|
3646
|
+
if (typeof veScaKey === "object") {
|
|
3647
|
+
veScaKey = SuiObjectRefZod.parse(veScaKey);
|
|
3648
|
+
}
|
|
3320
3649
|
let vesca = void 0;
|
|
3321
3650
|
const veScaDynamicFieldObjectResponse = await query.cache.queryGetDynamicFieldObject({
|
|
3322
3651
|
parentId: tableId,
|
|
3323
3652
|
name: {
|
|
3324
3653
|
type: "0x2::object::ID",
|
|
3325
|
-
value:
|
|
3654
|
+
value: typeof veScaKey === "string" ? veScaKey : veScaKey.objectId
|
|
3326
3655
|
}
|
|
3327
3656
|
});
|
|
3328
3657
|
const veScaDynamicFieldObject = veScaDynamicFieldObjectResponse.data;
|
|
@@ -3337,7 +3666,9 @@ var getVeSca = async (query, veScaKeyId, ownerAddress) => {
|
|
|
3337
3666
|
const currentVeScaBalance = lockedScaCoin * (Math.floor(remainingLockPeriodInMilliseconds / 1e3) / MAX_LOCK_DURATION);
|
|
3338
3667
|
vesca = {
|
|
3339
3668
|
id: veScaDynamicFieldObject.objectId,
|
|
3340
|
-
keyId:
|
|
3669
|
+
keyId: typeof veScaKey === "string" ? veScaKey : veScaKey.objectId,
|
|
3670
|
+
keyObject: typeof veScaKey === "string" ? void 0 : veScaKey,
|
|
3671
|
+
object: SuiObjectRefZod.parse(veScaDynamicFieldObjectResponse.data),
|
|
3341
3672
|
lockedScaAmount,
|
|
3342
3673
|
lockedScaCoin,
|
|
3343
3674
|
currentVeScaBalance,
|
|
@@ -3346,10 +3677,10 @@ var getVeSca = async (query, veScaKeyId, ownerAddress) => {
|
|
|
3346
3677
|
}
|
|
3347
3678
|
return vesca;
|
|
3348
3679
|
};
|
|
3349
|
-
var getTotalVeScaTreasuryAmount = async (query) => {
|
|
3680
|
+
var getTotalVeScaTreasuryAmount = async (query, veScaTreasury) => {
|
|
3350
3681
|
const veScaPkgId = query.address.get("vesca.id");
|
|
3351
3682
|
const veScaConfig = query.address.get("vesca.config");
|
|
3352
|
-
|
|
3683
|
+
veScaTreasury = veScaTreasury ?? query.address.get("vesca.treasury");
|
|
3353
3684
|
const refreshQueryTarget = `${veScaPkgId}::treasury::refresh`;
|
|
3354
3685
|
const refreshArgs = [veScaConfig, veScaTreasury, import_sui_kit2.SUI_CLOCK_OBJECT_ID];
|
|
3355
3686
|
const veScaAmountQueryTarget = `${veScaPkgId}::treasury::total_ve_sca_amount`;
|
|
@@ -3385,8 +3716,7 @@ var getTotalVeScaTreasuryAmount = async (query) => {
|
|
|
3385
3716
|
],
|
|
3386
3717
|
queryFn: async () => {
|
|
3387
3718
|
return await query.suiKit.inspectTxn(txBytes);
|
|
3388
|
-
}
|
|
3389
|
-
staleTime: 8e3
|
|
3719
|
+
}
|
|
3390
3720
|
});
|
|
3391
3721
|
const results = res.results;
|
|
3392
3722
|
if (results && results[1].returnValues) {
|
|
@@ -3396,6 +3726,30 @@ var getTotalVeScaTreasuryAmount = async (query) => {
|
|
|
3396
3726
|
}
|
|
3397
3727
|
return "0";
|
|
3398
3728
|
};
|
|
3729
|
+
var getVeScaTreasuryInfo = async (query) => {
|
|
3730
|
+
const veScaTreasuryId = query.address.get("vesca.treasury");
|
|
3731
|
+
const veScaTreasury = await query.cache.queryGetObject(veScaTreasuryId, {
|
|
3732
|
+
showContent: true
|
|
3733
|
+
});
|
|
3734
|
+
if (!veScaTreasury || veScaTreasury.data?.content?.dataType !== "moveObject")
|
|
3735
|
+
return null;
|
|
3736
|
+
const treasuryFields = veScaTreasury.data.content.fields;
|
|
3737
|
+
console.log(treasuryFields);
|
|
3738
|
+
const totalLockedSca = (0, import_bignumber5.default)(
|
|
3739
|
+
treasuryFields.unlock_schedule.fields.locked_sca_amount
|
|
3740
|
+
).shiftedBy(-9).toNumber();
|
|
3741
|
+
const totalVeSca = (0, import_bignumber5.default)(
|
|
3742
|
+
await getTotalVeScaTreasuryAmount(query, veScaTreasury.data) ?? 0
|
|
3743
|
+
).shiftedBy(-9).toNumber();
|
|
3744
|
+
const averageLockingPeriod = totalLockedSca > 0 ? totalVeSca / totalLockedSca * 4 : 0;
|
|
3745
|
+
const averageLockingPeriodUnit = "year";
|
|
3746
|
+
return {
|
|
3747
|
+
totalLockedSca,
|
|
3748
|
+
totalVeSca,
|
|
3749
|
+
averageLockingPeriod,
|
|
3750
|
+
averageLockingPeriodUnit
|
|
3751
|
+
};
|
|
3752
|
+
};
|
|
3399
3753
|
|
|
3400
3754
|
// src/queries/referralQuery.ts
|
|
3401
3755
|
var queryVeScaKeyIdFromReferralBindings = async (query, refereeAddress) => {
|
|
@@ -3413,6 +3767,57 @@ var queryVeScaKeyIdFromReferralBindings = async (query, refereeAddress) => {
|
|
|
3413
3767
|
return fields.value;
|
|
3414
3768
|
};
|
|
3415
3769
|
|
|
3770
|
+
// src/queries/loyaltyProgramQuery.ts
|
|
3771
|
+
var import_bignumber6 = __toESM(require("bignumber.js"));
|
|
3772
|
+
var import_zod2 = require("zod");
|
|
3773
|
+
var rewardPoolFieldsZod = import_zod2.z.object({
|
|
3774
|
+
balance: import_zod2.z.string(),
|
|
3775
|
+
enable_claim: import_zod2.z.boolean()
|
|
3776
|
+
}).transform((value) => ({
|
|
3777
|
+
totalPoolReward: (0, import_bignumber6.default)(value.balance).shiftedBy(-9).toNumber(),
|
|
3778
|
+
isClaimEnabled: value.enable_claim
|
|
3779
|
+
}));
|
|
3780
|
+
var userRewardFieldsZod = import_zod2.z.object({
|
|
3781
|
+
value: import_zod2.z.string()
|
|
3782
|
+
}).transform((value) => (0, import_bignumber6.default)(value.value).shiftedBy(-9).toNumber());
|
|
3783
|
+
var getLoyaltyProgramInformations = async (query, veScaKey) => {
|
|
3784
|
+
const rewardPool = query.address.get("loyaltyProgram.rewardPool");
|
|
3785
|
+
const rewardPoolObject = await query.cache.queryGetObject(rewardPool, {
|
|
3786
|
+
showContent: true
|
|
3787
|
+
});
|
|
3788
|
+
if (rewardPoolObject.data?.content?.dataType !== "moveObject")
|
|
3789
|
+
return null;
|
|
3790
|
+
const rewardPoolFields = rewardPoolObject.data.content.fields;
|
|
3791
|
+
const { isClaimEnabled, totalPoolReward } = rewardPoolFieldsZod.parse(
|
|
3792
|
+
rewardPoolFields
|
|
3793
|
+
);
|
|
3794
|
+
const result = {
|
|
3795
|
+
pendingReward: 0,
|
|
3796
|
+
totalPoolReward,
|
|
3797
|
+
isClaimEnabled
|
|
3798
|
+
};
|
|
3799
|
+
veScaKey = veScaKey || (await query.getVeScas())[0]?.keyObject;
|
|
3800
|
+
if (!veScaKey)
|
|
3801
|
+
return result;
|
|
3802
|
+
const userRewardTableId = query.address.get(
|
|
3803
|
+
"loyaltyProgram.userRewardTableId"
|
|
3804
|
+
);
|
|
3805
|
+
const userRewardObject = await query.cache.queryGetDynamicFieldObject({
|
|
3806
|
+
parentId: userRewardTableId,
|
|
3807
|
+
name: {
|
|
3808
|
+
type: "0x2::object::ID",
|
|
3809
|
+
value: typeof veScaKey === "string" ? veScaKey : veScaKey.objectId
|
|
3810
|
+
}
|
|
3811
|
+
});
|
|
3812
|
+
if (userRewardObject.data?.content?.dataType !== "moveObject")
|
|
3813
|
+
return result;
|
|
3814
|
+
const userRewardFields = userRewardObject.data.content.fields;
|
|
3815
|
+
result.pendingReward = userRewardFieldsZod.parse(
|
|
3816
|
+
userRewardFields
|
|
3817
|
+
);
|
|
3818
|
+
return result;
|
|
3819
|
+
};
|
|
3820
|
+
|
|
3416
3821
|
// src/models/scallopIndexer.ts
|
|
3417
3822
|
var import_axios2 = __toESM(require("axios"));
|
|
3418
3823
|
var ScallopIndexer = class {
|
|
@@ -3959,11 +4364,11 @@ var ScallopQuery = class {
|
|
|
3959
4364
|
* Get total vesca treasury with movecall
|
|
3960
4365
|
* @returns Promise<string | undefined>
|
|
3961
4366
|
*/
|
|
3962
|
-
async
|
|
3963
|
-
return await
|
|
4367
|
+
async getVeScaTreasuryInfo() {
|
|
4368
|
+
return await getVeScaTreasuryInfo(this);
|
|
3964
4369
|
}
|
|
3965
4370
|
/**
|
|
3966
|
-
* Return binded veScaKeyId of walletAddress if exist
|
|
4371
|
+
* Return binded referrer veScaKeyId of referee walletAddress if exist
|
|
3967
4372
|
* @param walletAddress
|
|
3968
4373
|
* @returns veScaKeyId
|
|
3969
4374
|
*/
|
|
@@ -3986,6 +4391,14 @@ var ScallopQuery = class {
|
|
|
3986
4391
|
async getBindedVeScaKey(obligationId) {
|
|
3987
4392
|
return await getBindedVeScaKey(this, obligationId);
|
|
3988
4393
|
}
|
|
4394
|
+
/**
|
|
4395
|
+
* Get user's veSCA loyalty program informations
|
|
4396
|
+
* @param walletAddress
|
|
4397
|
+
* @returns Loyalty program information
|
|
4398
|
+
*/
|
|
4399
|
+
async getLoyaltyProgramInfos(veScaKey) {
|
|
4400
|
+
return await getLoyaltyProgramInformations(this, veScaKey);
|
|
4401
|
+
}
|
|
3989
4402
|
};
|
|
3990
4403
|
|
|
3991
4404
|
// src/constants/pyth.ts
|
|
@@ -4337,9 +4750,9 @@ var ScallopUtils = class {
|
|
|
4337
4750
|
* @param unlockAtInSecondTimestamp The unlock timestamp from veSca object.
|
|
4338
4751
|
* @return New unlock at in seconds timestamp.
|
|
4339
4752
|
*/
|
|
4340
|
-
getUnlockAt(extendLockPeriodInDay,
|
|
4753
|
+
getUnlockAt(extendLockPeriodInDay, unlockAtInMillisTimestamp) {
|
|
4341
4754
|
const now = Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3);
|
|
4342
|
-
const remainingLockPeriod =
|
|
4755
|
+
const remainingLockPeriod = unlockAtInMillisTimestamp ? Math.max(Math.floor(unlockAtInMillisTimestamp / 1e3) - now, 0) : 0;
|
|
4343
4756
|
let newUnlockAtInSecondTimestamp = 0;
|
|
4344
4757
|
if (remainingLockPeriod === 0) {
|
|
4345
4758
|
const lockPeriod = (extendLockPeriodInDay ?? 1) * UNLOCK_ROUND_DURATION;
|
|
@@ -4359,8 +4772,8 @@ var ScallopUtils = class {
|
|
|
4359
4772
|
};
|
|
4360
4773
|
|
|
4361
4774
|
// src/models/scallopBuilder.ts
|
|
4362
|
-
var
|
|
4363
|
-
var
|
|
4775
|
+
var import_utils21 = require("@mysten/sui.js/utils");
|
|
4776
|
+
var import_sui_kit11 = require("@scallop-io/sui-kit");
|
|
4364
4777
|
|
|
4365
4778
|
// src/builders/coreBuilder.ts
|
|
4366
4779
|
var import_transactions = require("@mysten/sui.js/transactions");
|
|
@@ -5232,7 +5645,10 @@ var generateQuickVeScaMethod = ({
|
|
|
5232
5645
|
},
|
|
5233
5646
|
extendLockPeriodQuick: async (lockPeriodInDays, veScaKey, autoCheck = true) => {
|
|
5234
5647
|
const veSca = await requireVeSca(builder, txBlock, veScaKey);
|
|
5235
|
-
const newUnlockAt = builder.utils.getUnlockAt(
|
|
5648
|
+
const newUnlockAt = builder.utils.getUnlockAt(
|
|
5649
|
+
lockPeriodInDays,
|
|
5650
|
+
veSca?.unlockAt
|
|
5651
|
+
);
|
|
5236
5652
|
if (autoCheck)
|
|
5237
5653
|
checkExtendLockPeriod(lockPeriodInDays, newUnlockAt, veSca?.unlockAt);
|
|
5238
5654
|
if (veSca) {
|
|
@@ -5698,12 +6114,90 @@ var newReferralTxBlock = (builder, initTxBlock) => {
|
|
|
5698
6114
|
});
|
|
5699
6115
|
};
|
|
5700
6116
|
|
|
6117
|
+
// src/builders/loyaltyProgramBuilder.ts
|
|
6118
|
+
var import_transactions4 = require("@mysten/sui.js/transactions");
|
|
6119
|
+
var import_sui_kit10 = require("@scallop-io/sui-kit");
|
|
6120
|
+
var generateLoyaltyProgramNormalMethod = ({ builder, txBlock }) => {
|
|
6121
|
+
const loyaltyProgramIds = {
|
|
6122
|
+
loyaltyProgramPkgId: builder.address.get("loyaltyProgram.id"),
|
|
6123
|
+
rewardPool: builder.address.get("loyaltyProgram.rewardPool"),
|
|
6124
|
+
userRewardTableId: builder.address.get(
|
|
6125
|
+
"loyaltyProgram.userRewardTableId"
|
|
6126
|
+
)
|
|
6127
|
+
};
|
|
6128
|
+
return {
|
|
6129
|
+
claimLoyaltyRevenue: (veScaKey) => {
|
|
6130
|
+
return txBlock.moveCall(
|
|
6131
|
+
`${loyaltyProgramIds.loyaltyProgramPkgId}::reward_pool::redeem_reward`,
|
|
6132
|
+
[loyaltyProgramIds.rewardPool, veScaKey]
|
|
6133
|
+
);
|
|
6134
|
+
}
|
|
6135
|
+
};
|
|
6136
|
+
};
|
|
6137
|
+
var generateLoyaltyProgramQuickMethod = ({
|
|
6138
|
+
builder,
|
|
6139
|
+
txBlock
|
|
6140
|
+
}) => {
|
|
6141
|
+
return {
|
|
6142
|
+
claimLoyaltyRevenueQuick: async (veScaKey) => {
|
|
6143
|
+
veScaKey = veScaKey || (await builder.query.getVeScas())[0]?.keyObject;
|
|
6144
|
+
const sender = requireSender(txBlock);
|
|
6145
|
+
if (!veScaKey)
|
|
6146
|
+
throw new Error(`No veScaKey found for user ${sender}`);
|
|
6147
|
+
const toTransferObject = [];
|
|
6148
|
+
const rewardCoin = txBlock.claimLoyaltyRevenue(veScaKey);
|
|
6149
|
+
try {
|
|
6150
|
+
const existingScaCoin = await builder.suiKit.suiInteractor.selectCoins(
|
|
6151
|
+
sender,
|
|
6152
|
+
Infinity,
|
|
6153
|
+
coinIds.sca
|
|
6154
|
+
);
|
|
6155
|
+
txBlock.mergeCoins(rewardCoin, existingScaCoin);
|
|
6156
|
+
} catch (e) {
|
|
6157
|
+
} finally {
|
|
6158
|
+
toTransferObject.push(rewardCoin);
|
|
6159
|
+
}
|
|
6160
|
+
if (toTransferObject.length > 0) {
|
|
6161
|
+
txBlock.transferObjects(toTransferObject, sender);
|
|
6162
|
+
}
|
|
6163
|
+
}
|
|
6164
|
+
};
|
|
6165
|
+
};
|
|
6166
|
+
var newLoyaltyProgramTxBlock = (builder, initTxBlock) => {
|
|
6167
|
+
const txBlock = initTxBlock instanceof import_transactions4.TransactionBlock ? new import_sui_kit10.SuiTxBlock(initTxBlock) : initTxBlock ? initTxBlock : new import_sui_kit10.SuiTxBlock();
|
|
6168
|
+
const normalMethod = generateLoyaltyProgramNormalMethod({
|
|
6169
|
+
builder,
|
|
6170
|
+
txBlock
|
|
6171
|
+
});
|
|
6172
|
+
const normalTxBlock = new Proxy(txBlock, {
|
|
6173
|
+
get: (target, prop) => {
|
|
6174
|
+
if (prop in normalMethod) {
|
|
6175
|
+
return Reflect.get(normalMethod, prop);
|
|
6176
|
+
}
|
|
6177
|
+
return Reflect.get(target, prop);
|
|
6178
|
+
}
|
|
6179
|
+
});
|
|
6180
|
+
const quickMethod = generateLoyaltyProgramQuickMethod({
|
|
6181
|
+
builder,
|
|
6182
|
+
txBlock: normalTxBlock
|
|
6183
|
+
});
|
|
6184
|
+
return new Proxy(normalTxBlock, {
|
|
6185
|
+
get: (target, prop) => {
|
|
6186
|
+
if (prop in quickMethod) {
|
|
6187
|
+
return Reflect.get(quickMethod, prop);
|
|
6188
|
+
}
|
|
6189
|
+
return Reflect.get(target, prop);
|
|
6190
|
+
}
|
|
6191
|
+
});
|
|
6192
|
+
};
|
|
6193
|
+
|
|
5701
6194
|
// src/builders/index.ts
|
|
5702
6195
|
var newScallopTxBlock = (builder, initTxBlock) => {
|
|
5703
6196
|
const vescaTxBlock = newVeScaTxBlock(builder, initTxBlock);
|
|
6197
|
+
const loyaltyTxBlock = newLoyaltyProgramTxBlock(builder, vescaTxBlock);
|
|
5704
6198
|
const borrowIncentiveTxBlock = newBorrowIncentiveTxBlock(
|
|
5705
6199
|
builder,
|
|
5706
|
-
|
|
6200
|
+
loyaltyTxBlock
|
|
5707
6201
|
);
|
|
5708
6202
|
const referralTxBlock = newReferralTxBlock(builder, borrowIncentiveTxBlock);
|
|
5709
6203
|
const spoolTxBlock = newSpoolTxBlock(builder, referralTxBlock);
|
|
@@ -5718,6 +6212,8 @@ var newScallopTxBlock = (builder, initTxBlock) => {
|
|
|
5718
6212
|
return Reflect.get(referralTxBlock, prop);
|
|
5719
6213
|
} else if (prop in spoolTxBlock) {
|
|
5720
6214
|
return Reflect.get(spoolTxBlock, prop);
|
|
6215
|
+
} else if (prop in loyaltyTxBlock) {
|
|
6216
|
+
return Reflect.get(loyaltyTxBlock, prop);
|
|
5721
6217
|
}
|
|
5722
6218
|
return Reflect.get(target, prop);
|
|
5723
6219
|
}
|
|
@@ -5728,7 +6224,7 @@ var newScallopTxBlock = (builder, initTxBlock) => {
|
|
|
5728
6224
|
var ScallopBuilder = class {
|
|
5729
6225
|
constructor(params, instance) {
|
|
5730
6226
|
this.params = params;
|
|
5731
|
-
this.suiKit = instance?.suiKit ?? new
|
|
6227
|
+
this.suiKit = instance?.suiKit ?? new import_sui_kit11.SuiKit(params);
|
|
5732
6228
|
this.cache = instance?.cache ?? new ScallopCache(DEFAULT_CACHE_OPTIONS, this.suiKit);
|
|
5733
6229
|
this.address = instance?.address ?? new ScallopAddress(
|
|
5734
6230
|
{
|
|
@@ -5748,7 +6244,7 @@ var ScallopBuilder = class {
|
|
|
5748
6244
|
query: this.query,
|
|
5749
6245
|
cache: this.cache
|
|
5750
6246
|
});
|
|
5751
|
-
this.walletAddress = (0,
|
|
6247
|
+
this.walletAddress = (0, import_utils21.normalizeSuiAddress)(
|
|
5752
6248
|
params?.walletAddress || this.suiKit.currentAddress()
|
|
5753
6249
|
);
|
|
5754
6250
|
this.isTestnet = params.networkType ? params.networkType === "testnet" : false;
|
|
@@ -5827,7 +6323,7 @@ var ScallopBuilder = class {
|
|
|
5827
6323
|
var ScallopClient = class {
|
|
5828
6324
|
constructor(params, instance) {
|
|
5829
6325
|
this.params = params;
|
|
5830
|
-
this.suiKit = instance?.suiKit ?? new
|
|
6326
|
+
this.suiKit = instance?.suiKit ?? new import_sui_kit12.SuiKit(params);
|
|
5831
6327
|
this.cache = instance?.cache ?? new ScallopCache(DEFAULT_CACHE_OPTIONS, this.suiKit);
|
|
5832
6328
|
this.address = instance?.address ?? new ScallopAddress(
|
|
5833
6329
|
{
|
|
@@ -5854,7 +6350,7 @@ var ScallopClient = class {
|
|
|
5854
6350
|
utils: this.utils,
|
|
5855
6351
|
cache: this.cache
|
|
5856
6352
|
});
|
|
5857
|
-
this.walletAddress = (0,
|
|
6353
|
+
this.walletAddress = (0, import_utils22.normalizeSuiAddress)(
|
|
5858
6354
|
params?.walletAddress || this.suiKit.currentAddress()
|
|
5859
6355
|
);
|
|
5860
6356
|
}
|
|
@@ -6360,7 +6856,7 @@ var ScallopClient = class {
|
|
|
6360
6856
|
var Scallop = class {
|
|
6361
6857
|
constructor(params, cacheOptions) {
|
|
6362
6858
|
this.params = params;
|
|
6363
|
-
this.suiKit = new
|
|
6859
|
+
this.suiKit = new import_sui_kit13.SuiKit(params);
|
|
6364
6860
|
this.cache = new ScallopCache(
|
|
6365
6861
|
cacheOptions ?? DEFAULT_CACHE_OPTIONS,
|
|
6366
6862
|
this.suiKit
|