@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.mjs
CHANGED
|
@@ -284,9 +284,7 @@ var ScallopCache = class {
|
|
|
284
284
|
],
|
|
285
285
|
queryFn: async () => {
|
|
286
286
|
return await this.suiKit.inspectTxn(txBytes);
|
|
287
|
-
}
|
|
288
|
-
staleTime: 8e3
|
|
289
|
-
// make stale time longer for inspectTxn results
|
|
287
|
+
}
|
|
290
288
|
});
|
|
291
289
|
return query;
|
|
292
290
|
}
|
|
@@ -420,6 +418,310 @@ var ScallopCache = class {
|
|
|
420
418
|
|
|
421
419
|
// src/models/scallopAddress.ts
|
|
422
420
|
import axios from "axios";
|
|
421
|
+
|
|
422
|
+
// src/constants/testAddress.ts
|
|
423
|
+
var TEST_ADDRESSES = {
|
|
424
|
+
core: {
|
|
425
|
+
version: "0x07871c4b3c847a0f674510d4978d5cf6f960452795e8ff6f189fd2088a3f6ac7",
|
|
426
|
+
versionCap: "0x590a4011cb649b3878f3ea14b3a78674642a9548d79b7e091ef679574b158a07",
|
|
427
|
+
object: "0xefe8b36d5b2e43728cc323298626b83177803521d195cfb11e15b910e892fddf",
|
|
428
|
+
market: "0xa757975255146dc9686aa823b7838b507f315d704f428cbadad2f4ea061939d9",
|
|
429
|
+
adminCap: "0x09689d018e71c337d9db6d67cbca06b74ed92196103624028ccc3ecea411777c",
|
|
430
|
+
coinDecimalsRegistry: "0x200abe9bf19751cc566ae35aa58e2b7e4ff688fc1130f8d8909ea09bc137d668",
|
|
431
|
+
obligationAccessStore: "0x733e30b7c94d619d78cb8f5bc4bfbb759ced9a531239028caabb2474e5be59c9",
|
|
432
|
+
coins: {
|
|
433
|
+
cetus: {
|
|
434
|
+
id: "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b",
|
|
435
|
+
metaData: "0x4c0dce55eff2db5419bbd2d239d1aa22b4a400c01bbb648b058a9883989025da",
|
|
436
|
+
treasury: "",
|
|
437
|
+
oracle: {
|
|
438
|
+
supra: "",
|
|
439
|
+
switchboard: "",
|
|
440
|
+
pyth: {
|
|
441
|
+
feed: "e5b274b2611143df055d6e7cd8d93fe1961716bcd4dca1cad87a83bc1e78c1ef",
|
|
442
|
+
feedObject: "0x24c0247fb22457a719efac7f670cdc79be321b521460bd6bd2ccfa9f80713b14"
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
},
|
|
446
|
+
apt: {
|
|
447
|
+
id: "0x3a5143bb1196e3bcdfab6203d1683ae29edd26294fc8bfeafe4aaa9d2704df37",
|
|
448
|
+
metaData: "0xc969c5251f372c0f34c32759f1d315cf1ea0ee5e4454b52aea08778eacfdd0a8",
|
|
449
|
+
treasury: "",
|
|
450
|
+
oracle: {
|
|
451
|
+
supra: "",
|
|
452
|
+
switchboard: "",
|
|
453
|
+
pyth: {
|
|
454
|
+
feed: "03ae4db29ed4ae33d323568895aa00337e658e348b37509f5372ae51f0af00d5",
|
|
455
|
+
feedObject: "0x7c5b7837c44a69b469325463ac0673ac1aa8435ff44ddb4191c9ae380463647f"
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
},
|
|
459
|
+
sol: {
|
|
460
|
+
id: "0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8",
|
|
461
|
+
metaData: "0x4d2c39082b4477e3e79dc4562d939147ab90c42fc5f3e4acf03b94383cd69b6e",
|
|
462
|
+
treasury: "",
|
|
463
|
+
oracle: {
|
|
464
|
+
supra: "",
|
|
465
|
+
switchboard: "",
|
|
466
|
+
pyth: {
|
|
467
|
+
feed: "ef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d",
|
|
468
|
+
feedObject: "0x9d0d275efbd37d8a8855f6f2c761fa5983293dd8ce202ee5196626de8fcd4469"
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
},
|
|
472
|
+
btc: {
|
|
473
|
+
id: "0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881",
|
|
474
|
+
metaData: "0x5d3c6e60eeff8a05b693b481539e7847dfe33013e7070cdcb387f5c0cac05dfd",
|
|
475
|
+
treasury: "",
|
|
476
|
+
oracle: {
|
|
477
|
+
supra: "",
|
|
478
|
+
switchboard: "",
|
|
479
|
+
pyth: {
|
|
480
|
+
feed: "e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43",
|
|
481
|
+
feedObject: "0x9a62b4863bdeaabdc9500fce769cf7e72d5585eeb28a6d26e4cafadc13f76ab2"
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
},
|
|
485
|
+
eth: {
|
|
486
|
+
id: "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5",
|
|
487
|
+
metaData: "0x8900e4ceede3363bef086d6b50ca89d816d0e90bf6bc46efefe1f8455e08f50f",
|
|
488
|
+
treasury: "",
|
|
489
|
+
oracle: {
|
|
490
|
+
supra: "",
|
|
491
|
+
switchboard: "",
|
|
492
|
+
pyth: {
|
|
493
|
+
feed: "ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace",
|
|
494
|
+
feedObject: "0x9193fd47f9a0ab99b6e365a464c8a9ae30e6150fc37ed2a89c1586631f6fc4ab"
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
},
|
|
498
|
+
usdc: {
|
|
499
|
+
id: "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf",
|
|
500
|
+
metaData: "0x4fbf84f3029bd0c0b77164b587963be957f853eccf834a67bb9ecba6ec80f189",
|
|
501
|
+
treasury: "",
|
|
502
|
+
oracle: {
|
|
503
|
+
supra: "",
|
|
504
|
+
switchboard: "",
|
|
505
|
+
pyth: {
|
|
506
|
+
feed: "eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a",
|
|
507
|
+
feedObject: "0x5dec622733a204ca27f5a90d8c2fad453cc6665186fd5dff13a83d0b6c9027ab"
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
},
|
|
511
|
+
usdt: {
|
|
512
|
+
id: "0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c",
|
|
513
|
+
metaData: "0xfb0e3eb97dd158a5ae979dddfa24348063843c5b20eb8381dd5fa7c93699e45c",
|
|
514
|
+
treasury: "",
|
|
515
|
+
oracle: {
|
|
516
|
+
supra: "",
|
|
517
|
+
switchboard: "",
|
|
518
|
+
pyth: {
|
|
519
|
+
feed: "2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b",
|
|
520
|
+
feedObject: "0x985e3db9f93f76ee8bace7c3dd5cc676a096accd5d9e09e9ae0fb6e492b14572"
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
},
|
|
524
|
+
sui: {
|
|
525
|
+
id: "0x0000000000000000000000000000000000000000000000000000000000000002",
|
|
526
|
+
metaData: "0x9258181f5ceac8dbffb7030890243caed69a9599d2886d957a9cb7656af3bdb3",
|
|
527
|
+
treasury: "",
|
|
528
|
+
oracle: {
|
|
529
|
+
supra: "",
|
|
530
|
+
switchboard: "0xbca474133638352ba83ccf7b5c931d50f764b09550e16612c9f70f1e21f3f594",
|
|
531
|
+
pyth: {
|
|
532
|
+
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
533
|
+
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
},
|
|
537
|
+
afsui: {
|
|
538
|
+
id: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc",
|
|
539
|
+
metaData: "0x2f9217f533e51334873a39b8026a4aa6919497b47f49d0986a4f1aec66f8a34d",
|
|
540
|
+
treasury: "",
|
|
541
|
+
oracle: {
|
|
542
|
+
supra: "",
|
|
543
|
+
switchboard: "",
|
|
544
|
+
pyth: {
|
|
545
|
+
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
546
|
+
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
},
|
|
550
|
+
hasui: {
|
|
551
|
+
id: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d",
|
|
552
|
+
metaData: "0x2c5f33af93f6511df699aaaa5822d823aac6ed99d4a0de2a4a50b3afa0172e24",
|
|
553
|
+
treasury: "",
|
|
554
|
+
oracle: {
|
|
555
|
+
supra: "",
|
|
556
|
+
switchboard: "",
|
|
557
|
+
pyth: {
|
|
558
|
+
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
559
|
+
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
},
|
|
563
|
+
vsui: {
|
|
564
|
+
id: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55",
|
|
565
|
+
metaData: "0xabd84a23467b33854ab25cf862006fd97479f8f6f53e50fe732c43a274d939bd",
|
|
566
|
+
treasury: "",
|
|
567
|
+
oracle: {
|
|
568
|
+
supra: "",
|
|
569
|
+
switchboard: "",
|
|
570
|
+
pyth: {
|
|
571
|
+
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
572
|
+
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
},
|
|
576
|
+
sca: {
|
|
577
|
+
id: "0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6",
|
|
578
|
+
metaData: "0x5d26a1e9a55c88147ac870bfa31b729d7f49f8804b8b3adfdf3582d301cca844",
|
|
579
|
+
treasury: "",
|
|
580
|
+
oracle: {
|
|
581
|
+
supra: "",
|
|
582
|
+
switchboard: "",
|
|
583
|
+
pyth: {
|
|
584
|
+
feed: "7e17f0ac105abe9214deb9944c30264f5986bf292869c6bd8e8da3ccd92d79bc",
|
|
585
|
+
feedObject: "0xf6de1d3279a269a597d813cbaca59aa906543ab9a8c64e84a4722f1a20863985"
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
},
|
|
590
|
+
oracles: {
|
|
591
|
+
xOracle: "0x93d5bf0936b71eb27255941e532fac33b5a5c7759e377b4923af0a1359ad494f",
|
|
592
|
+
xOracleCap: "0x1edeae568fde99e090dbdec4bcdbd33a15f53a1ce1f87aeef1a560dedf4b4a90",
|
|
593
|
+
supra: { registry: "", registryCap: "", holder: "" },
|
|
594
|
+
switchboard: { registry: "", registryCap: "" },
|
|
595
|
+
pyth: {
|
|
596
|
+
registry: "0xedc293f9413a5a7a5d53bdba1fd889d0a4030894469228f0acdae4aa3c55a213",
|
|
597
|
+
registryCap: "0xbcb07141eb1f7e01fbda4130ecf5f5adaeabb77f5d9c32158b7532bcd2197acd",
|
|
598
|
+
state: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8",
|
|
599
|
+
wormhole: "0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a",
|
|
600
|
+
wormholeState: "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c"
|
|
601
|
+
}
|
|
602
|
+
},
|
|
603
|
+
packages: {
|
|
604
|
+
coinDecimalsRegistry: {
|
|
605
|
+
id: "0xca5a5a62f01c79a104bf4d31669e29daa387f325c241de4edbe30986a9bc8b0d",
|
|
606
|
+
upgradeCap: "0x34e76a945d29f195bc53ca704fa70877d1cf3a5d7bbfdda1b13e633fff13c0f6"
|
|
607
|
+
},
|
|
608
|
+
math: {
|
|
609
|
+
id: "0xad013d5fde39e15eabda32b3dbdafd67dac32b798ce63237c27a8f73339b9b6f",
|
|
610
|
+
upgradeCap: "0x3a329598231de02e6135c62284b66005b41cad1d9ab7ca2dc79c08293aba2ec6"
|
|
611
|
+
},
|
|
612
|
+
whitelist: {
|
|
613
|
+
id: "0x1318fdc90319ec9c24df1456d960a447521b0a658316155895014a6e39b5482f",
|
|
614
|
+
upgradeCap: "0xf5a22aea23db664f7b69855b6a546747f17c1ec4230319cfc17225e462b05761"
|
|
615
|
+
},
|
|
616
|
+
x: {
|
|
617
|
+
id: "0x779b5c547976899f5474f3a5bc0db36ddf4697ad7e5a901db0415c2281d28162",
|
|
618
|
+
upgradeCap: "0x3f203f6fff6a69d151e4f1cd931f22b68c489ef2759765662fc7baf673943c9e"
|
|
619
|
+
},
|
|
620
|
+
protocol: {
|
|
621
|
+
id: "0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e",
|
|
622
|
+
upgradeCap: "0x38527d154618d1fd5a644b90717fe07cf0e9f26b46b63e9568e611a3f86d5c1a"
|
|
623
|
+
},
|
|
624
|
+
protocolWhitelist: {
|
|
625
|
+
id: "0x4c262d9343dac53ecb28f482a2a3f62c73d0ebac5b5f03d57383d56ff219acdf",
|
|
626
|
+
upgradeCap: "0x4a5e88a75039b00988f633f811f58117f31b8627a46bf822aa114d9010049449"
|
|
627
|
+
},
|
|
628
|
+
query: {
|
|
629
|
+
id: "0xb8d603a39114a5efef3dd0bf84df0bed1be1fbd39b78b7dd6e8a61ccc5e6006f",
|
|
630
|
+
upgradeCap: "0x0d535c35f608b9b01b7ccce11acf43b1dd80c1b72bf8b541744a6e28e8d2745f"
|
|
631
|
+
},
|
|
632
|
+
supra: { id: "", upgradeCap: "" },
|
|
633
|
+
pyth: {
|
|
634
|
+
id: "0x910f30cbc7f601f75a5141a01265cd47c62d468707c5e1aecb32a18f448cb25a",
|
|
635
|
+
upgradeCap: "0xdf0ffbae1ea5bb25fbca5efba433dcf00c7cced65679af2f04728901275c6157"
|
|
636
|
+
},
|
|
637
|
+
switchboard: { id: "", upgradeCap: "" },
|
|
638
|
+
xOracle: {
|
|
639
|
+
id: "0x1478a432123e4b3d61878b629f2c692969fdb375644f1251cd278a4b1e7d7cd6",
|
|
640
|
+
upgradeCap: "0x0f928a6b2e26b73330fecaf9b44acfc9800a4a9794d6415c2a3153bc70e3c1f0"
|
|
641
|
+
},
|
|
642
|
+
testCoin: { id: "", upgradeCap: "" }
|
|
643
|
+
}
|
|
644
|
+
},
|
|
645
|
+
spool: {
|
|
646
|
+
id: "0x7c4fdabe81c31b19a45d1e572a52a539997a90903fbb5bfab71480abe0fa62c3",
|
|
647
|
+
adminCap: "0xdd8a047cbbf802bfcde5288b8ef1910965d789cc614da11d39af05fca0bd020a",
|
|
648
|
+
object: "0xe87f1b2d498106a2c61421cec75b7b5c5e348512b0dc263949a0e7a3c256571a",
|
|
649
|
+
pools: {
|
|
650
|
+
seth: {
|
|
651
|
+
id: "0xeec40beccb07c575bebd842eeaabb835f77cd3dab73add433477e57f583a6787",
|
|
652
|
+
rewardPoolId: "0x957de68a18d87817de8309b30c1ec269a4d87ae513abbeed86b5619cb9ce1077"
|
|
653
|
+
},
|
|
654
|
+
ssui: {
|
|
655
|
+
id: "0x4f0ba970d3c11db05c8f40c64a15b6a33322db3702d634ced6536960ab6f3ee4",
|
|
656
|
+
rewardPoolId: "0x162250ef72393a4ad3d46294c4e1bdfcb03f04c869d390e7efbfc995353a7ee9"
|
|
657
|
+
},
|
|
658
|
+
susdc: {
|
|
659
|
+
id: "0x4ace6648ddc64e646ba47a957c562c32c9599b3bba8f5ac1aadb2ae23a2f8ca0",
|
|
660
|
+
rewardPoolId: "0xf4268cc9b9413b9bfe09e8966b8de650494c9e5784bf0930759cfef4904daff8"
|
|
661
|
+
},
|
|
662
|
+
susdt: {
|
|
663
|
+
id: "0xcb328f7ffa7f9342ed85af3fdb2f22919e1a06dfb2f713c04c73543870d7548f",
|
|
664
|
+
rewardPoolId: "0x2c9f934d67a5baa586ceec2cc24163a2f049a6af3d5ba36b84d8ac40f25c4080"
|
|
665
|
+
},
|
|
666
|
+
scetus: {
|
|
667
|
+
id: "0xac1bb13bf4472a637c18c2415fb0e3c1227ea2bcf35242e50563c98215bd298e",
|
|
668
|
+
rewardPoolId: "0x6835c1224126a45086fc6406adc249e3f30df18d779ca4f4e570e38716a17f3f"
|
|
669
|
+
},
|
|
670
|
+
safsui: {
|
|
671
|
+
id: "0xeedf438abcaa6ce4d9625ffca110920592d5867e4c5637d84ad9f466c4feb800",
|
|
672
|
+
rewardPoolId: "0x89255a2f86ed7fbfef35ab8b7be48cc7667015975be2685dd9a55a9a64baf76e"
|
|
673
|
+
},
|
|
674
|
+
shasui: {
|
|
675
|
+
id: "0xa6148bc1b623e936d39a952ceb5bea79e8b37228a8f595067bf1852efd3c34aa",
|
|
676
|
+
rewardPoolId: "0x6f3563644d3e2ef13176dbf9d865bd93479df60ccbe07b7e66db57f6309f5a66"
|
|
677
|
+
},
|
|
678
|
+
svsui: {
|
|
679
|
+
id: "0x69ce8e537e750a95381e6040794afa5ab1758353a1a2e1de7760391b01f91670",
|
|
680
|
+
rewardPoolId: "0xbca914adce058ad0902c7f3cfcd698392a475f00dcfdc3f76001d0370b98777a"
|
|
681
|
+
}
|
|
682
|
+
},
|
|
683
|
+
config: ""
|
|
684
|
+
},
|
|
685
|
+
borrowIncentive: {
|
|
686
|
+
id: "0x6152f696fc3a658f33c4b891764731a59153125ffedfa8bff7167c42823f58a9",
|
|
687
|
+
adminCap: "0xc486afa253646f4d381e81d7f1df8aa4723b845a6bb356f69bad635ffefffe2c",
|
|
688
|
+
object: "0x002875153e09f8145ab63527bc85c00f2bd102e12f9573c47f8cdf1a1cb62934",
|
|
689
|
+
query: "0x529edc54a3dce2207703ceebbccb0ac14133f7825c1f528775ba0d85a4063489",
|
|
690
|
+
incentivePools: "0x6547e143d406b5ccd5f46aae482497de279cc1a68c406f701df70a05f9212ab4",
|
|
691
|
+
incentiveAccounts: "0xc4701fdbc1c92f9a636d334d66012b3027659e9fb8aff27279a82edfb6b77d02",
|
|
692
|
+
config: "0xdf5d04b4691cc67e82fd4db8394d89ff44823a9de29716c924f74bb4f11cc1f7"
|
|
693
|
+
},
|
|
694
|
+
referral: {
|
|
695
|
+
id: "0xa3654ebb63eb06c0f4ff52f8aa6512df9f164f7772bdf15dac3709bd3798dda9",
|
|
696
|
+
object: "0x5658d4bf5ddcba27e4337b4262108b3ad1716643cac8c2054ac341538adc72ec",
|
|
697
|
+
adminCap: "0xc5dc06b9074291259f2cac460c940012c781c4430e42125c541cc43101c3bcbd",
|
|
698
|
+
referralBindings: "0xf63299d58789d99de94092b9011323466e55ca0c1ea1a7a3786a589af46e1c09",
|
|
699
|
+
bindingTableId: "0x1c8202b17267ec8d6cf97ca013615354181a04f179570e42601ff2dae19294b1",
|
|
700
|
+
referralRevenuePool: "0x6abd852caf90769c1b185cdf636d841673fa95528f0550f018b8a138bd283c07",
|
|
701
|
+
revenueTableId: "0x595baa3654c297bff84ab7786a2d250f019cefc66e8df8e89fd9d41e02bd30dd",
|
|
702
|
+
referralTiers: "0x962cb903d8d7346190c5204785ccbb91b61086aa764f674c8145df82335cf83e",
|
|
703
|
+
tiersTableId: "0xeac755a7a8b7798530905ac79e8c114f19d0f130f6eab012954f08faac29c75d",
|
|
704
|
+
authorizedWitnessList: "0xf21b0ed043c9bb70842c0129159f4943dbcc3c9ef2f2f808af65f8be25cfd20e",
|
|
705
|
+
version: "0x1bd4b7285f72e11c316b828c7c47b3f4da18dcec9f9b3dba6d8629cbb6f93e5e"
|
|
706
|
+
},
|
|
707
|
+
vesca: {
|
|
708
|
+
id: "0xb15b6e0cdd85afb5028bea851dd249405e734d800a259147bbc24980629723a4",
|
|
709
|
+
object: "0xb15b6e0cdd85afb5028bea851dd249405e734d800a259147bbc24980629723a4",
|
|
710
|
+
adminCap: "0x8ffa76135c5b85c5fbd73a6448a4a733d826cb63a267ab817656acb77c72d4a5",
|
|
711
|
+
tableId: "0xe3153b2bf124be0b86cb8bd468346a861efd0da52fc42197b54d2f616488a311",
|
|
712
|
+
table: "0x611cb8d9d4d90867467b5ebdf4cc447a0047ed5b01334a28a29fcfe733e3d609",
|
|
713
|
+
treasury: "0xe8c112c09b88158dc6c8e23d1fbae5b3c7136cdee54b7dafc08e65db28c4a5bc",
|
|
714
|
+
config: "0xe0a2ff281e73c1d53cfa85807080f87e833e4f1a7f93dcf8800b3865269a76b9"
|
|
715
|
+
},
|
|
716
|
+
loyaltyProgram: {
|
|
717
|
+
id: "0xd17bcf8b5a59652c36225d478564a8593ae0ed7d650bcacdda1d6fe179127907",
|
|
718
|
+
object: "0xd17bcf8b5a59652c36225d478564a8593ae0ed7d650bcacdda1d6fe179127907",
|
|
719
|
+
rewardPool: "0xf9c090492ef476bd542109d0913ffe871cbfa28578b7114eca2a8c0e5671786f",
|
|
720
|
+
userRewardTableId: "0x748a80395849ed37db1b0e14f2ab5d1d96458d2359ab3a84eb079d0f4ac7cf2e"
|
|
721
|
+
}
|
|
722
|
+
};
|
|
723
|
+
|
|
724
|
+
// src/models/scallopAddress.ts
|
|
423
725
|
var EMPTY_ADDRESSES = {
|
|
424
726
|
core: {
|
|
425
727
|
version: "",
|
|
@@ -712,6 +1014,12 @@ var EMPTY_ADDRESSES = {
|
|
|
712
1014
|
referralTiers: "",
|
|
713
1015
|
tiersTableId: "",
|
|
714
1016
|
authorizedWitnessList: ""
|
|
1017
|
+
},
|
|
1018
|
+
loyaltyProgram: {
|
|
1019
|
+
id: "",
|
|
1020
|
+
object: "",
|
|
1021
|
+
rewardPool: "",
|
|
1022
|
+
userRewardTableId: ""
|
|
715
1023
|
}
|
|
716
1024
|
};
|
|
717
1025
|
var ScallopAddress = class {
|
|
@@ -730,7 +1038,9 @@ var ScallopAddress = class {
|
|
|
730
1038
|
this._auth = auth;
|
|
731
1039
|
this._id = id;
|
|
732
1040
|
this._network = network || "mainnet";
|
|
733
|
-
this._addressesMap = /* @__PURE__ */ new Map();
|
|
1041
|
+
this._addressesMap = IS_VE_SCA_TEST ? /* @__PURE__ */ new Map([["mainnet", TEST_ADDRESSES]]) : /* @__PURE__ */ new Map();
|
|
1042
|
+
if (IS_VE_SCA_TEST)
|
|
1043
|
+
this._currentAddresses = TEST_ADDRESSES;
|
|
734
1044
|
}
|
|
735
1045
|
/**
|
|
736
1046
|
* Get addresses API id.
|
|
@@ -1040,7 +1350,37 @@ var requireSender = (txBlock) => {
|
|
|
1040
1350
|
}
|
|
1041
1351
|
return sender;
|
|
1042
1352
|
};
|
|
1043
|
-
var
|
|
1353
|
+
var checkVesca = (prevUnlockAtInMillisTimestamp) => {
|
|
1354
|
+
if (prevUnlockAtInMillisTimestamp === void 0) {
|
|
1355
|
+
throw new Error("veSca not found");
|
|
1356
|
+
}
|
|
1357
|
+
};
|
|
1358
|
+
var checkVescaExpired = (prevUnlockAtInMillisTimestamp) => {
|
|
1359
|
+
if (prevUnlockAtInMillisTimestamp <= (/* @__PURE__ */ new Date()).getTime()) {
|
|
1360
|
+
throw new Error("veSca is expired, use renewExpiredVeScaQuick instead");
|
|
1361
|
+
}
|
|
1362
|
+
};
|
|
1363
|
+
var checkExtendLockPeriod = (lockPeriodInDays, newUnlockAtInSecondTimestamp, prevUnlockAtInMillisTimestamp) => {
|
|
1364
|
+
checkVesca(prevUnlockAtInMillisTimestamp);
|
|
1365
|
+
checkVescaExpired(prevUnlockAtInMillisTimestamp);
|
|
1366
|
+
const prevUnlockAtInSecondTimestamp = Math.floor(
|
|
1367
|
+
prevUnlockAtInMillisTimestamp / 1e3
|
|
1368
|
+
);
|
|
1369
|
+
if (lockPeriodInDays < 1) {
|
|
1370
|
+
throw new Error("Minimum lock period is 1 day");
|
|
1371
|
+
}
|
|
1372
|
+
const availableLockPeriodInDays = Math.floor(
|
|
1373
|
+
(newUnlockAtInSecondTimestamp - prevUnlockAtInSecondTimestamp) / UNLOCK_ROUND_DURATION
|
|
1374
|
+
);
|
|
1375
|
+
console.log("availableLockPeriodInDays", availableLockPeriodInDays);
|
|
1376
|
+
if (lockPeriodInDays > availableLockPeriodInDays) {
|
|
1377
|
+
throw new Error(
|
|
1378
|
+
`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}`
|
|
1379
|
+
);
|
|
1380
|
+
}
|
|
1381
|
+
};
|
|
1382
|
+
var checkLockSca = (scaAmountOrCoin, lockPeriodInDays, newUnlockAtInSecondTimestamp, prevUnlockAtInMillisTimestamp) => {
|
|
1383
|
+
const prevUnlockAtInSecondTimestamp = prevUnlockAtInMillisTimestamp ? Math.floor(prevUnlockAtInMillisTimestamp / 1e3) : void 0;
|
|
1044
1384
|
const isInitialLock = !prevUnlockAtInSecondTimestamp;
|
|
1045
1385
|
const isLockExpired = !isInitialLock && prevUnlockAtInSecondTimestamp * 1e3 <= (/* @__PURE__ */ new Date()).getTime();
|
|
1046
1386
|
if (isInitialLock || isLockExpired) {
|
|
@@ -1065,52 +1405,36 @@ var checkLockSca = (scaAmountOrCoin, lockPeriodInDays, newUnlockAtInSecondTimest
|
|
|
1065
1405
|
);
|
|
1066
1406
|
}
|
|
1067
1407
|
} else {
|
|
1068
|
-
checkVesca(
|
|
1408
|
+
checkVesca(prevUnlockAtInMillisTimestamp);
|
|
1409
|
+
checkVescaExpired(prevUnlockAtInMillisTimestamp);
|
|
1069
1410
|
if (typeof scaAmountOrCoin === "number" && scaAmountOrCoin < MIN_TOP_UP_AMOUNT) {
|
|
1070
1411
|
throw new Error("Minimum top up amount is 1 SCA");
|
|
1071
1412
|
}
|
|
1072
|
-
if (
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
);
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
}
|
|
1081
|
-
};
|
|
1082
|
-
var checkExtendLockPeriod = (lockPeriodInDays, newUnlockAtInSecondTimestamp, prevUnlockAtInSecondTimestamp) => {
|
|
1083
|
-
checkVesca(prevUnlockAtInSecondTimestamp);
|
|
1084
|
-
if (lockPeriodInDays <= 0) {
|
|
1085
|
-
throw new Error("Lock period must be greater than 0");
|
|
1086
|
-
}
|
|
1087
|
-
const isInitialLock = !prevUnlockAtInSecondTimestamp;
|
|
1088
|
-
const isLockExpired = !isInitialLock && prevUnlockAtInSecondTimestamp * 1e3 <= (/* @__PURE__ */ new Date()).getTime();
|
|
1089
|
-
if (isLockExpired) {
|
|
1090
|
-
throw new Error("veSca is expired, use renewExpiredVeScaQuick instead");
|
|
1091
|
-
}
|
|
1092
|
-
if (prevUnlockAtInSecondTimestamp) {
|
|
1093
|
-
const totalLockDuration = newUnlockAtInSecondTimestamp - prevUnlockAtInSecondTimestamp;
|
|
1094
|
-
if (totalLockDuration > MAX_LOCK_DURATION - UNLOCK_ROUND_DURATION) {
|
|
1095
|
-
throw new Error(
|
|
1096
|
-
`Maximum lock period is ~4 years (${MAX_LOCK_ROUNDS - 1} days)`
|
|
1413
|
+
if (newUnlockAtInSecondTimestamp && lockPeriodInDays) {
|
|
1414
|
+
checkExtendLockPeriod(
|
|
1415
|
+
lockPeriodInDays,
|
|
1416
|
+
newUnlockAtInSecondTimestamp,
|
|
1417
|
+
prevUnlockAtInMillisTimestamp
|
|
1097
1418
|
);
|
|
1098
1419
|
}
|
|
1099
1420
|
}
|
|
1100
1421
|
};
|
|
1101
|
-
var checkExtendLockAmount = (scaAmount,
|
|
1102
|
-
checkVesca(
|
|
1422
|
+
var checkExtendLockAmount = (scaAmount, prevUnlockAtInMillisTimestamp) => {
|
|
1423
|
+
checkVesca(prevUnlockAtInMillisTimestamp);
|
|
1424
|
+
checkVescaExpired(prevUnlockAtInMillisTimestamp);
|
|
1103
1425
|
if (scaAmount < MIN_TOP_UP_AMOUNT) {
|
|
1104
1426
|
throw new Error("Minimum top up amount is 1 SCA");
|
|
1105
1427
|
}
|
|
1106
|
-
const isInitialLock = !
|
|
1107
|
-
const isLockExpired = !isInitialLock &&
|
|
1428
|
+
const isInitialLock = !prevUnlockAtInMillisTimestamp;
|
|
1429
|
+
const isLockExpired = !isInitialLock && prevUnlockAtInMillisTimestamp <= (/* @__PURE__ */ new Date()).getTime();
|
|
1108
1430
|
if (isLockExpired) {
|
|
1109
1431
|
throw new Error("veSca is expired, use renewExpiredVeScaQuick instead");
|
|
1110
1432
|
}
|
|
1111
1433
|
};
|
|
1112
|
-
var checkRenewExpiredVeSca = (scaAmount, lockPeriodInDays,
|
|
1113
|
-
|
|
1434
|
+
var checkRenewExpiredVeSca = (scaAmount, lockPeriodInDays, prevUnlockAtInMillisTimestamp) => {
|
|
1435
|
+
if (!prevUnlockAtInMillisTimestamp || prevUnlockAtInMillisTimestamp > (/* @__PURE__ */ new Date()).getTime()) {
|
|
1436
|
+
throw new Error("Renew method can only be used for expired veSca");
|
|
1437
|
+
}
|
|
1114
1438
|
if (scaAmount < MIN_INITIAL_LOCK_AMOUNT) {
|
|
1115
1439
|
throw new Error("Minimum lock amount for renewing expired vesca 10 SCA");
|
|
1116
1440
|
}
|
|
@@ -1121,11 +1445,6 @@ var checkRenewExpiredVeSca = (scaAmount, lockPeriodInDays, prevUnlockAtInSecondT
|
|
|
1121
1445
|
);
|
|
1122
1446
|
}
|
|
1123
1447
|
};
|
|
1124
|
-
var checkVesca = (prevUnlockAtInSecondTimestamp) => {
|
|
1125
|
-
if (prevUnlockAtInSecondTimestamp === void 0) {
|
|
1126
|
-
throw new Error("veSca not found");
|
|
1127
|
-
}
|
|
1128
|
-
};
|
|
1129
1448
|
|
|
1130
1449
|
// src/utils/query.ts
|
|
1131
1450
|
import BigNumber from "bignumber.js";
|
|
@@ -1226,13 +1545,14 @@ var calculateMarketPoolData = (utils, parsedMarketPoolData) => {
|
|
|
1226
1545
|
};
|
|
1227
1546
|
};
|
|
1228
1547
|
var parseOriginMarketCollateralData = (originMarketCollateralData) => {
|
|
1548
|
+
const divisor = 2 ** 32;
|
|
1229
1549
|
return {
|
|
1230
1550
|
coinType: normalizeStructTag2(originMarketCollateralData.type.name),
|
|
1231
|
-
collateralFactor: Number(originMarketCollateralData.collateralFactor.value) /
|
|
1232
|
-
liquidationFactor: Number(originMarketCollateralData.liquidationFactor.value) /
|
|
1233
|
-
liquidationDiscount: Number(originMarketCollateralData.liquidationDiscount.value) /
|
|
1234
|
-
liquidationPanelty: Number(originMarketCollateralData.liquidationPanelty.value) /
|
|
1235
|
-
liquidationReserveFactor: Number(originMarketCollateralData.liquidationReserveFactor.value) /
|
|
1551
|
+
collateralFactor: Number(originMarketCollateralData.collateralFactor.value) / divisor,
|
|
1552
|
+
liquidationFactor: Number(originMarketCollateralData.liquidationFactor.value) / divisor,
|
|
1553
|
+
liquidationDiscount: Number(originMarketCollateralData.liquidationDiscount.value) / divisor,
|
|
1554
|
+
liquidationPanelty: Number(originMarketCollateralData.liquidationPanelty.value) / divisor,
|
|
1555
|
+
liquidationReserveFactor: Number(originMarketCollateralData.liquidationReserveFactor.value) / divisor,
|
|
1236
1556
|
maxCollateralAmount: Number(originMarketCollateralData.maxCollateralAmount),
|
|
1237
1557
|
totalCollateralAmount: Number(
|
|
1238
1558
|
originMarketCollateralData.totalCollateralAmount
|
|
@@ -1574,15 +1894,6 @@ var findClosestUnlockRound = (unlockAtInSecondTimestamp) => {
|
|
|
1574
1894
|
// src/queries/coreQuery.ts
|
|
1575
1895
|
import BigNumber2 from "bignumber.js";
|
|
1576
1896
|
var queryMarket = async (query, indexer = false) => {
|
|
1577
|
-
const packageId = query.address.get("core.packages.query.id");
|
|
1578
|
-
const marketId = query.address.get("core.market");
|
|
1579
|
-
const queryTarget = `${packageId}::market_query::market_data`;
|
|
1580
|
-
const args = [marketId];
|
|
1581
|
-
const queryResult = await query.cache.queryInspectTxn(
|
|
1582
|
-
{ queryTarget, args }
|
|
1583
|
-
// txBlock
|
|
1584
|
-
);
|
|
1585
|
-
const marketData = queryResult.events[0].parsedJson;
|
|
1586
1897
|
const coinPrices = await query.utils.getCoinPrices();
|
|
1587
1898
|
const pools = {};
|
|
1588
1899
|
const collaterals = {};
|
|
@@ -1603,6 +1914,12 @@ var queryMarket = async (query, indexer = false) => {
|
|
|
1603
1914
|
collaterals: marketIndexer.collaterals
|
|
1604
1915
|
};
|
|
1605
1916
|
}
|
|
1917
|
+
const packageId = query.address.get("core.packages.query.id");
|
|
1918
|
+
const marketId = query.address.get("core.market");
|
|
1919
|
+
const queryTarget = `${packageId}::market_query::market_data`;
|
|
1920
|
+
const args = [marketId];
|
|
1921
|
+
const queryResult = await query.cache.queryInspectTxn({ queryTarget, args });
|
|
1922
|
+
const marketData = queryResult.events[0].parsedJson;
|
|
1606
1923
|
for (const pool of marketData.pools) {
|
|
1607
1924
|
const coinType = normalizeStructTag3(pool.type.name);
|
|
1608
1925
|
const poolCoinName = query.utils.parseCoinNameFromType(coinType);
|
|
@@ -1717,18 +2034,20 @@ var getMarketPools = async (query, poolCoinNames, indexer = false) => {
|
|
|
1717
2034
|
}
|
|
1718
2035
|
return marketPools;
|
|
1719
2036
|
}
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
2037
|
+
Promise.allSettled(
|
|
2038
|
+
poolCoinNames.map(async (poolCoinName) => {
|
|
2039
|
+
const marketPool = await getMarketPool(
|
|
2040
|
+
query,
|
|
2041
|
+
poolCoinName,
|
|
2042
|
+
indexer,
|
|
2043
|
+
marketObjectResponse.data,
|
|
2044
|
+
coinPrices?.[poolCoinName]
|
|
2045
|
+
);
|
|
2046
|
+
if (marketPool) {
|
|
2047
|
+
marketPools[poolCoinName] = marketPool;
|
|
2048
|
+
}
|
|
2049
|
+
})
|
|
2050
|
+
);
|
|
1732
2051
|
return marketPools;
|
|
1733
2052
|
};
|
|
1734
2053
|
var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, coinPrice) => {
|
|
@@ -1866,10 +2185,12 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
|
|
|
1866
2185
|
var getMarketCollaterals = async (query, collateralCoinNames, indexer = false) => {
|
|
1867
2186
|
collateralCoinNames = collateralCoinNames || [...SUPPORT_COLLATERALS];
|
|
1868
2187
|
const marketId = query.address.get("core.market");
|
|
1869
|
-
const marketObjectResponse = await
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
2188
|
+
const [marketObjectResponse, coinPrices] = await Promise.all([
|
|
2189
|
+
query.cache.queryGetObject(marketId, {
|
|
2190
|
+
showContent: true
|
|
2191
|
+
}),
|
|
2192
|
+
query.utils.getCoinPrices(collateralCoinNames ?? [])
|
|
2193
|
+
]);
|
|
1873
2194
|
const marketCollaterals = {};
|
|
1874
2195
|
if (indexer) {
|
|
1875
2196
|
const marketCollateralsIndexer = await query.indexer.getMarketCollaterals();
|
|
@@ -1884,29 +2205,23 @@ var getMarketCollaterals = async (query, collateralCoinNames, indexer = false) =
|
|
|
1884
2205
|
}
|
|
1885
2206
|
return marketCollaterals;
|
|
1886
2207
|
}
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
2208
|
+
await Promise.allSettled(
|
|
2209
|
+
collateralCoinNames.map(async (collateralCoinName) => {
|
|
2210
|
+
const marketCollateral = await getMarketCollateral(
|
|
2211
|
+
query,
|
|
2212
|
+
collateralCoinName,
|
|
2213
|
+
indexer,
|
|
2214
|
+
marketObjectResponse.data,
|
|
2215
|
+
coinPrices?.[collateralCoinName]
|
|
2216
|
+
);
|
|
2217
|
+
if (marketCollateral) {
|
|
2218
|
+
marketCollaterals[collateralCoinName] = marketCollateral;
|
|
2219
|
+
}
|
|
2220
|
+
})
|
|
2221
|
+
);
|
|
1899
2222
|
return marketCollaterals;
|
|
1900
2223
|
};
|
|
1901
2224
|
var getMarketCollateral = async (query, collateralCoinName, indexer = false, marketObject, coinPrice) => {
|
|
1902
|
-
const marketId = query.address.get("core.market");
|
|
1903
|
-
marketObject = marketObject || (await query.cache.queryGetObject(marketId, {
|
|
1904
|
-
showContent: true
|
|
1905
|
-
})).data;
|
|
1906
|
-
coinPrice = coinPrice || (await query.utils.getCoinPrices([collateralCoinName]))?.[collateralCoinName];
|
|
1907
|
-
let marketCollateral;
|
|
1908
|
-
let riskModel;
|
|
1909
|
-
let collateralStat;
|
|
1910
2225
|
if (indexer) {
|
|
1911
2226
|
const marketCollateralIndexer = await query.indexer.getMarketCollateral(collateralCoinName);
|
|
1912
2227
|
marketCollateralIndexer.coinPrice = coinPrice || marketCollateralIndexer.coinPrice;
|
|
@@ -1915,6 +2230,14 @@ var getMarketCollateral = async (query, collateralCoinName, indexer = false, mar
|
|
|
1915
2230
|
);
|
|
1916
2231
|
return marketCollateralIndexer;
|
|
1917
2232
|
}
|
|
2233
|
+
let marketCollateral;
|
|
2234
|
+
let riskModel;
|
|
2235
|
+
let collateralStat;
|
|
2236
|
+
const marketId = query.address.get("core.market");
|
|
2237
|
+
marketObject = marketObject || (await query.cache.queryGetObject(marketId, {
|
|
2238
|
+
showContent: true
|
|
2239
|
+
})).data;
|
|
2240
|
+
coinPrice = coinPrice || (await query.utils.getCoinPrices([collateralCoinName]))?.[collateralCoinName];
|
|
1918
2241
|
if (marketObject) {
|
|
1919
2242
|
if (marketObject.content && "fields" in marketObject.content) {
|
|
1920
2243
|
const fields = marketObject.content.fields;
|
|
@@ -2009,15 +2332,17 @@ var getObligations = async (query, ownerAddress) => {
|
|
|
2009
2332
|
const keyObjectIds = keyObjectsResponse.map((ref) => ref?.data?.objectId).filter((id) => id !== void 0);
|
|
2010
2333
|
const keyObjects = await query.cache.queryGetObjects(keyObjectIds);
|
|
2011
2334
|
const obligations = [];
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2335
|
+
await Promise.allSettled(
|
|
2336
|
+
keyObjects.map(async (keyObject) => {
|
|
2337
|
+
const keyId = keyObject.objectId;
|
|
2338
|
+
if (keyObject.content && "fields" in keyObject.content) {
|
|
2339
|
+
const fields = keyObject.content.fields;
|
|
2340
|
+
const obligationId = String(fields.ownership.fields.of);
|
|
2341
|
+
const locked = await getObligationLocked(query, obligationId);
|
|
2342
|
+
obligations.push({ id: obligationId, keyId, locked });
|
|
2343
|
+
}
|
|
2344
|
+
})
|
|
2345
|
+
);
|
|
2021
2346
|
return obligations;
|
|
2022
2347
|
};
|
|
2023
2348
|
var getObligationLocked = async (query, obligationId) => {
|
|
@@ -2471,12 +2796,6 @@ var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames, indexer
|
|
|
2471
2796
|
borrowIncentiveCoinNames = borrowIncentiveCoinNames || [
|
|
2472
2797
|
...SUPPORT_BORROW_INCENTIVE_POOLS
|
|
2473
2798
|
];
|
|
2474
|
-
const queryPkgId = query.address.get("borrowIncentive.query");
|
|
2475
|
-
const incentivePoolsId = query.address.get("borrowIncentive.incentivePools");
|
|
2476
|
-
const queryTarget = `${queryPkgId}::incentive_pools_query::incentive_pools_data`;
|
|
2477
|
-
const args = [incentivePoolsId];
|
|
2478
|
-
const queryResult = await query.cache.queryInspectTxn({ queryTarget, args });
|
|
2479
|
-
const borrowIncentivePoolsQueryData = queryResult.events[0].parsedJson;
|
|
2480
2799
|
const borrowIncentivePools = {};
|
|
2481
2800
|
const coinPrices = await query.utils.getCoinPrices(
|
|
2482
2801
|
[
|
|
@@ -2498,6 +2817,12 @@ var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames, indexer
|
|
|
2498
2817
|
}
|
|
2499
2818
|
return borrowIncentivePools;
|
|
2500
2819
|
}
|
|
2820
|
+
const queryPkgId = query.address.get("borrowIncentive.query");
|
|
2821
|
+
const incentivePoolsId = query.address.get("borrowIncentive.incentivePools");
|
|
2822
|
+
const queryTarget = `${queryPkgId}::incentive_pools_query::incentive_pools_data`;
|
|
2823
|
+
const args = [incentivePoolsId];
|
|
2824
|
+
const queryResult = await query.cache.queryInspectTxn({ queryTarget, args });
|
|
2825
|
+
const borrowIncentivePoolsQueryData = queryResult.events[0].parsedJson;
|
|
2501
2826
|
for (const pool of borrowIncentivePoolsQueryData.incentive_pools) {
|
|
2502
2827
|
const borrowIncentivePoolPoints = {};
|
|
2503
2828
|
const parsedBorrowIncentivePoolData = parseOriginBorrowIncentivePoolData(pool);
|
|
@@ -2707,34 +3032,42 @@ var getLendings = async (query, poolCoinNames, ownerAddress, indexer = false) =>
|
|
|
2707
3032
|
const stakeMarketCoinNames = marketCoinNames.filter(
|
|
2708
3033
|
(marketCoinName) => SUPPORT_SPOOLS.includes(marketCoinName)
|
|
2709
3034
|
);
|
|
2710
|
-
const
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
3035
|
+
const [
|
|
3036
|
+
marketPools,
|
|
3037
|
+
spools,
|
|
3038
|
+
coinAmounts,
|
|
3039
|
+
marketCoinAmounts,
|
|
3040
|
+
allStakeAccounts,
|
|
3041
|
+
coinPrices
|
|
3042
|
+
] = await Promise.all([
|
|
3043
|
+
query.getMarketPools(poolCoinNames, indexer),
|
|
3044
|
+
query.getSpools(stakeMarketCoinNames, indexer),
|
|
3045
|
+
query.getCoinAmounts(poolCoinNames, ownerAddress),
|
|
3046
|
+
query.getMarketCoinAmounts(marketCoinNames, ownerAddress),
|
|
3047
|
+
query.getAllStakeAccounts(ownerAddress),
|
|
3048
|
+
query.utils.getCoinPrices(poolCoinNames)
|
|
3049
|
+
]);
|
|
2719
3050
|
const lendings = {};
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
3051
|
+
await Promise.allSettled(
|
|
3052
|
+
poolCoinNames.map(async (poolCoinName) => {
|
|
3053
|
+
const stakeMarketCoinName = stakeMarketCoinNames.find(
|
|
3054
|
+
(marketCoinName2) => marketCoinName2 === query.utils.parseMarketCoinName(poolCoinName)
|
|
3055
|
+
);
|
|
3056
|
+
const marketCoinName = query.utils.parseMarketCoinName(poolCoinName);
|
|
3057
|
+
lendings[poolCoinName] = await getLending(
|
|
3058
|
+
query,
|
|
3059
|
+
poolCoinName,
|
|
3060
|
+
ownerAddress,
|
|
3061
|
+
indexer,
|
|
3062
|
+
marketPools?.[poolCoinName],
|
|
3063
|
+
stakeMarketCoinName ? spools[stakeMarketCoinName] : void 0,
|
|
3064
|
+
stakeMarketCoinName ? allStakeAccounts[stakeMarketCoinName] : void 0,
|
|
3065
|
+
coinAmounts?.[poolCoinName],
|
|
3066
|
+
marketCoinAmounts?.[marketCoinName],
|
|
3067
|
+
coinPrices?.[poolCoinName] ?? 0
|
|
3068
|
+
);
|
|
3069
|
+
})
|
|
3070
|
+
);
|
|
2738
3071
|
return lendings;
|
|
2739
3072
|
};
|
|
2740
3073
|
var getLending = async (query, poolCoinName, ownerAddress, indexer = false, marketPool, spool, stakeAccounts, coinAmount, marketCoinAmount, coinPrice) => {
|
|
@@ -3202,6 +3535,7 @@ var getTotalValueLocked = async (query, indexer = false) => {
|
|
|
3202
3535
|
import BigNumber5 from "bignumber.js";
|
|
3203
3536
|
import { SUI_CLOCK_OBJECT_ID, SuiTxBlock as SuiTxBlock2 } from "@scallop-io/sui-kit";
|
|
3204
3537
|
import { bcs } from "@mysten/sui.js/bcs";
|
|
3538
|
+
import { z as zod } from "zod";
|
|
3205
3539
|
var getVescaKeys = async (query, ownerAddress) => {
|
|
3206
3540
|
const owner = ownerAddress || query.suiKit.currentAddress();
|
|
3207
3541
|
const veScaObjId = query.address.get("vesca.object");
|
|
@@ -3230,10 +3564,9 @@ var getVescaKeys = async (query, ownerAddress) => {
|
|
|
3230
3564
|
};
|
|
3231
3565
|
var getVeScas = async (query, ownerAddress) => {
|
|
3232
3566
|
const keyObjectDatas = await getVescaKeys(query, ownerAddress);
|
|
3233
|
-
const
|
|
3234
|
-
const
|
|
3235
|
-
|
|
3236
|
-
const veSca = await getVeSca(query, keyId);
|
|
3567
|
+
const veScas = Array(keyObjectDatas.length).fill(null);
|
|
3568
|
+
const tasks = keyObjectDatas.map(async (veScaKey, idx) => {
|
|
3569
|
+
const veSca = await getVeSca(query, veScaKey);
|
|
3237
3570
|
if (veSca) {
|
|
3238
3571
|
veScas[idx] = veSca;
|
|
3239
3572
|
}
|
|
@@ -3241,15 +3574,25 @@ var getVeScas = async (query, ownerAddress) => {
|
|
|
3241
3574
|
await Promise.allSettled(tasks);
|
|
3242
3575
|
return veScas.filter(Boolean).sort((a, b) => b.currentVeScaBalance - a.currentVeScaBalance);
|
|
3243
3576
|
};
|
|
3244
|
-
var
|
|
3577
|
+
var SuiObjectRefZod = zod.object({
|
|
3578
|
+
objectId: zod.string(),
|
|
3579
|
+
digest: zod.string(),
|
|
3580
|
+
version: zod.string()
|
|
3581
|
+
});
|
|
3582
|
+
var getVeSca = async (query, veScaKey, ownerAddress) => {
|
|
3245
3583
|
const tableId = query.address.get(`vesca.tableId`);
|
|
3246
|
-
|
|
3584
|
+
veScaKey = veScaKey || (await getVescaKeys(query, ownerAddress))[0];
|
|
3585
|
+
if (!veScaKey)
|
|
3586
|
+
return void 0;
|
|
3587
|
+
if (typeof veScaKey === "object") {
|
|
3588
|
+
veScaKey = SuiObjectRefZod.parse(veScaKey);
|
|
3589
|
+
}
|
|
3247
3590
|
let vesca = void 0;
|
|
3248
3591
|
const veScaDynamicFieldObjectResponse = await query.cache.queryGetDynamicFieldObject({
|
|
3249
3592
|
parentId: tableId,
|
|
3250
3593
|
name: {
|
|
3251
3594
|
type: "0x2::object::ID",
|
|
3252
|
-
value:
|
|
3595
|
+
value: typeof veScaKey === "string" ? veScaKey : veScaKey.objectId
|
|
3253
3596
|
}
|
|
3254
3597
|
});
|
|
3255
3598
|
const veScaDynamicFieldObject = veScaDynamicFieldObjectResponse.data;
|
|
@@ -3264,7 +3607,9 @@ var getVeSca = async (query, veScaKeyId, ownerAddress) => {
|
|
|
3264
3607
|
const currentVeScaBalance = lockedScaCoin * (Math.floor(remainingLockPeriodInMilliseconds / 1e3) / MAX_LOCK_DURATION);
|
|
3265
3608
|
vesca = {
|
|
3266
3609
|
id: veScaDynamicFieldObject.objectId,
|
|
3267
|
-
keyId:
|
|
3610
|
+
keyId: typeof veScaKey === "string" ? veScaKey : veScaKey.objectId,
|
|
3611
|
+
keyObject: typeof veScaKey === "string" ? void 0 : veScaKey,
|
|
3612
|
+
object: SuiObjectRefZod.parse(veScaDynamicFieldObjectResponse.data),
|
|
3268
3613
|
lockedScaAmount,
|
|
3269
3614
|
lockedScaCoin,
|
|
3270
3615
|
currentVeScaBalance,
|
|
@@ -3273,10 +3618,10 @@ var getVeSca = async (query, veScaKeyId, ownerAddress) => {
|
|
|
3273
3618
|
}
|
|
3274
3619
|
return vesca;
|
|
3275
3620
|
};
|
|
3276
|
-
var getTotalVeScaTreasuryAmount = async (query) => {
|
|
3621
|
+
var getTotalVeScaTreasuryAmount = async (query, veScaTreasury) => {
|
|
3277
3622
|
const veScaPkgId = query.address.get("vesca.id");
|
|
3278
3623
|
const veScaConfig = query.address.get("vesca.config");
|
|
3279
|
-
|
|
3624
|
+
veScaTreasury = veScaTreasury ?? query.address.get("vesca.treasury");
|
|
3280
3625
|
const refreshQueryTarget = `${veScaPkgId}::treasury::refresh`;
|
|
3281
3626
|
const refreshArgs = [veScaConfig, veScaTreasury, SUI_CLOCK_OBJECT_ID];
|
|
3282
3627
|
const veScaAmountQueryTarget = `${veScaPkgId}::treasury::total_ve_sca_amount`;
|
|
@@ -3312,8 +3657,7 @@ var getTotalVeScaTreasuryAmount = async (query) => {
|
|
|
3312
3657
|
],
|
|
3313
3658
|
queryFn: async () => {
|
|
3314
3659
|
return await query.suiKit.inspectTxn(txBytes);
|
|
3315
|
-
}
|
|
3316
|
-
staleTime: 8e3
|
|
3660
|
+
}
|
|
3317
3661
|
});
|
|
3318
3662
|
const results = res.results;
|
|
3319
3663
|
if (results && results[1].returnValues) {
|
|
@@ -3323,6 +3667,30 @@ var getTotalVeScaTreasuryAmount = async (query) => {
|
|
|
3323
3667
|
}
|
|
3324
3668
|
return "0";
|
|
3325
3669
|
};
|
|
3670
|
+
var getVeScaTreasuryInfo = async (query) => {
|
|
3671
|
+
const veScaTreasuryId = query.address.get("vesca.treasury");
|
|
3672
|
+
const veScaTreasury = await query.cache.queryGetObject(veScaTreasuryId, {
|
|
3673
|
+
showContent: true
|
|
3674
|
+
});
|
|
3675
|
+
if (!veScaTreasury || veScaTreasury.data?.content?.dataType !== "moveObject")
|
|
3676
|
+
return null;
|
|
3677
|
+
const treasuryFields = veScaTreasury.data.content.fields;
|
|
3678
|
+
console.log(treasuryFields);
|
|
3679
|
+
const totalLockedSca = BigNumber5(
|
|
3680
|
+
treasuryFields.unlock_schedule.fields.locked_sca_amount
|
|
3681
|
+
).shiftedBy(-9).toNumber();
|
|
3682
|
+
const totalVeSca = BigNumber5(
|
|
3683
|
+
await getTotalVeScaTreasuryAmount(query, veScaTreasury.data) ?? 0
|
|
3684
|
+
).shiftedBy(-9).toNumber();
|
|
3685
|
+
const averageLockingPeriod = totalLockedSca > 0 ? totalVeSca / totalLockedSca * 4 : 0;
|
|
3686
|
+
const averageLockingPeriodUnit = "year";
|
|
3687
|
+
return {
|
|
3688
|
+
totalLockedSca,
|
|
3689
|
+
totalVeSca,
|
|
3690
|
+
averageLockingPeriod,
|
|
3691
|
+
averageLockingPeriodUnit
|
|
3692
|
+
};
|
|
3693
|
+
};
|
|
3326
3694
|
|
|
3327
3695
|
// src/queries/referralQuery.ts
|
|
3328
3696
|
var queryVeScaKeyIdFromReferralBindings = async (query, refereeAddress) => {
|
|
@@ -3340,6 +3708,57 @@ var queryVeScaKeyIdFromReferralBindings = async (query, refereeAddress) => {
|
|
|
3340
3708
|
return fields.value;
|
|
3341
3709
|
};
|
|
3342
3710
|
|
|
3711
|
+
// src/queries/loyaltyProgramQuery.ts
|
|
3712
|
+
import BigNumber6 from "bignumber.js";
|
|
3713
|
+
import { z as zod2 } from "zod";
|
|
3714
|
+
var rewardPoolFieldsZod = zod2.object({
|
|
3715
|
+
balance: zod2.string(),
|
|
3716
|
+
enable_claim: zod2.boolean()
|
|
3717
|
+
}).transform((value) => ({
|
|
3718
|
+
totalPoolReward: BigNumber6(value.balance).shiftedBy(-9).toNumber(),
|
|
3719
|
+
isClaimEnabled: value.enable_claim
|
|
3720
|
+
}));
|
|
3721
|
+
var userRewardFieldsZod = zod2.object({
|
|
3722
|
+
value: zod2.string()
|
|
3723
|
+
}).transform((value) => BigNumber6(value.value).shiftedBy(-9).toNumber());
|
|
3724
|
+
var getLoyaltyProgramInformations = async (query, veScaKey) => {
|
|
3725
|
+
const rewardPool = query.address.get("loyaltyProgram.rewardPool");
|
|
3726
|
+
const rewardPoolObject = await query.cache.queryGetObject(rewardPool, {
|
|
3727
|
+
showContent: true
|
|
3728
|
+
});
|
|
3729
|
+
if (rewardPoolObject.data?.content?.dataType !== "moveObject")
|
|
3730
|
+
return null;
|
|
3731
|
+
const rewardPoolFields = rewardPoolObject.data.content.fields;
|
|
3732
|
+
const { isClaimEnabled, totalPoolReward } = rewardPoolFieldsZod.parse(
|
|
3733
|
+
rewardPoolFields
|
|
3734
|
+
);
|
|
3735
|
+
const result = {
|
|
3736
|
+
pendingReward: 0,
|
|
3737
|
+
totalPoolReward,
|
|
3738
|
+
isClaimEnabled
|
|
3739
|
+
};
|
|
3740
|
+
veScaKey = veScaKey || (await query.getVeScas())[0]?.keyObject;
|
|
3741
|
+
if (!veScaKey)
|
|
3742
|
+
return result;
|
|
3743
|
+
const userRewardTableId = query.address.get(
|
|
3744
|
+
"loyaltyProgram.userRewardTableId"
|
|
3745
|
+
);
|
|
3746
|
+
const userRewardObject = await query.cache.queryGetDynamicFieldObject({
|
|
3747
|
+
parentId: userRewardTableId,
|
|
3748
|
+
name: {
|
|
3749
|
+
type: "0x2::object::ID",
|
|
3750
|
+
value: typeof veScaKey === "string" ? veScaKey : veScaKey.objectId
|
|
3751
|
+
}
|
|
3752
|
+
});
|
|
3753
|
+
if (userRewardObject.data?.content?.dataType !== "moveObject")
|
|
3754
|
+
return result;
|
|
3755
|
+
const userRewardFields = userRewardObject.data.content.fields;
|
|
3756
|
+
result.pendingReward = userRewardFieldsZod.parse(
|
|
3757
|
+
userRewardFields
|
|
3758
|
+
);
|
|
3759
|
+
return result;
|
|
3760
|
+
};
|
|
3761
|
+
|
|
3343
3762
|
// src/models/scallopIndexer.ts
|
|
3344
3763
|
import axios2 from "axios";
|
|
3345
3764
|
var ScallopIndexer = class {
|
|
@@ -3764,15 +4183,17 @@ var ScallopQuery = class {
|
|
|
3764
4183
|
async getStakeRewardPools(stakeMarketCoinNames) {
|
|
3765
4184
|
stakeMarketCoinNames = stakeMarketCoinNames ?? [...SUPPORT_SPOOLS];
|
|
3766
4185
|
const stakeRewardPools = {};
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
4186
|
+
await Promise.allSettled(
|
|
4187
|
+
stakeMarketCoinNames.map(async (stakeMarketCoinName) => {
|
|
4188
|
+
const stakeRewardPool = await getStakeRewardPool(
|
|
4189
|
+
this,
|
|
4190
|
+
stakeMarketCoinName
|
|
4191
|
+
);
|
|
4192
|
+
if (stakeRewardPool) {
|
|
4193
|
+
stakeRewardPools[stakeMarketCoinName] = stakeRewardPool;
|
|
4194
|
+
}
|
|
4195
|
+
})
|
|
4196
|
+
);
|
|
3776
4197
|
return stakeRewardPools;
|
|
3777
4198
|
}
|
|
3778
4199
|
/**
|
|
@@ -3886,11 +4307,11 @@ var ScallopQuery = class {
|
|
|
3886
4307
|
* Get total vesca treasury with movecall
|
|
3887
4308
|
* @returns Promise<string | undefined>
|
|
3888
4309
|
*/
|
|
3889
|
-
async
|
|
3890
|
-
return await
|
|
4310
|
+
async getVeScaTreasuryInfo() {
|
|
4311
|
+
return await getVeScaTreasuryInfo(this);
|
|
3891
4312
|
}
|
|
3892
4313
|
/**
|
|
3893
|
-
* Return binded veScaKeyId of walletAddress if exist
|
|
4314
|
+
* Return binded referrer veScaKeyId of referee walletAddress if exist
|
|
3894
4315
|
* @param walletAddress
|
|
3895
4316
|
* @returns veScaKeyId
|
|
3896
4317
|
*/
|
|
@@ -3913,6 +4334,14 @@ var ScallopQuery = class {
|
|
|
3913
4334
|
async getBindedVeScaKey(obligationId) {
|
|
3914
4335
|
return await getBindedVeScaKey(this, obligationId);
|
|
3915
4336
|
}
|
|
4337
|
+
/**
|
|
4338
|
+
* Get user's veSCA loyalty program informations
|
|
4339
|
+
* @param walletAddress
|
|
4340
|
+
* @returns Loyalty program information
|
|
4341
|
+
*/
|
|
4342
|
+
async getLoyaltyProgramInfos(veScaKey) {
|
|
4343
|
+
return await getLoyaltyProgramInformations(this, veScaKey);
|
|
4344
|
+
}
|
|
3916
4345
|
};
|
|
3917
4346
|
|
|
3918
4347
|
// src/constants/pyth.ts
|
|
@@ -4264,9 +4693,9 @@ var ScallopUtils = class {
|
|
|
4264
4693
|
* @param unlockAtInSecondTimestamp The unlock timestamp from veSca object.
|
|
4265
4694
|
* @return New unlock at in seconds timestamp.
|
|
4266
4695
|
*/
|
|
4267
|
-
getUnlockAt(extendLockPeriodInDay,
|
|
4696
|
+
getUnlockAt(extendLockPeriodInDay, unlockAtInMillisTimestamp) {
|
|
4268
4697
|
const now = Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3);
|
|
4269
|
-
const remainingLockPeriod =
|
|
4698
|
+
const remainingLockPeriod = unlockAtInMillisTimestamp ? Math.max(Math.floor(unlockAtInMillisTimestamp / 1e3) - now, 0) : 0;
|
|
4270
4699
|
let newUnlockAtInSecondTimestamp = 0;
|
|
4271
4700
|
if (remainingLockPeriod === 0) {
|
|
4272
4701
|
const lockPeriod = (extendLockPeriodInDay ?? 1) * UNLOCK_ROUND_DURATION;
|
|
@@ -5166,7 +5595,10 @@ var generateQuickVeScaMethod = ({
|
|
|
5166
5595
|
},
|
|
5167
5596
|
extendLockPeriodQuick: async (lockPeriodInDays, veScaKey, autoCheck = true) => {
|
|
5168
5597
|
const veSca = await requireVeSca(builder, txBlock, veScaKey);
|
|
5169
|
-
const newUnlockAt = builder.utils.getUnlockAt(
|
|
5598
|
+
const newUnlockAt = builder.utils.getUnlockAt(
|
|
5599
|
+
lockPeriodInDays,
|
|
5600
|
+
veSca?.unlockAt
|
|
5601
|
+
);
|
|
5170
5602
|
if (autoCheck)
|
|
5171
5603
|
checkExtendLockPeriod(lockPeriodInDays, newUnlockAt, veSca?.unlockAt);
|
|
5172
5604
|
if (veSca) {
|
|
@@ -5636,12 +6068,90 @@ var newReferralTxBlock = (builder, initTxBlock) => {
|
|
|
5636
6068
|
});
|
|
5637
6069
|
};
|
|
5638
6070
|
|
|
6071
|
+
// src/builders/loyaltyProgramBuilder.ts
|
|
6072
|
+
import { TransactionBlock as TransactionBlock6 } from "@mysten/sui.js/transactions";
|
|
6073
|
+
import { SuiTxBlock as SuiKitTxBlock6 } from "@scallop-io/sui-kit";
|
|
6074
|
+
var generateLoyaltyProgramNormalMethod = ({ builder, txBlock }) => {
|
|
6075
|
+
const loyaltyProgramIds = {
|
|
6076
|
+
loyaltyProgramPkgId: builder.address.get("loyaltyProgram.id"),
|
|
6077
|
+
rewardPool: builder.address.get("loyaltyProgram.rewardPool"),
|
|
6078
|
+
userRewardTableId: builder.address.get(
|
|
6079
|
+
"loyaltyProgram.userRewardTableId"
|
|
6080
|
+
)
|
|
6081
|
+
};
|
|
6082
|
+
return {
|
|
6083
|
+
claimLoyaltyRevenue: (veScaKey) => {
|
|
6084
|
+
return txBlock.moveCall(
|
|
6085
|
+
`${loyaltyProgramIds.loyaltyProgramPkgId}::reward_pool::redeem_reward`,
|
|
6086
|
+
[loyaltyProgramIds.rewardPool, veScaKey]
|
|
6087
|
+
);
|
|
6088
|
+
}
|
|
6089
|
+
};
|
|
6090
|
+
};
|
|
6091
|
+
var generateLoyaltyProgramQuickMethod = ({
|
|
6092
|
+
builder,
|
|
6093
|
+
txBlock
|
|
6094
|
+
}) => {
|
|
6095
|
+
return {
|
|
6096
|
+
claimLoyaltyRevenueQuick: async (veScaKey) => {
|
|
6097
|
+
veScaKey = veScaKey || (await builder.query.getVeScas())[0]?.keyObject;
|
|
6098
|
+
const sender = requireSender(txBlock);
|
|
6099
|
+
if (!veScaKey)
|
|
6100
|
+
throw new Error(`No veScaKey found for user ${sender}`);
|
|
6101
|
+
const toTransferObject = [];
|
|
6102
|
+
const rewardCoin = txBlock.claimLoyaltyRevenue(veScaKey);
|
|
6103
|
+
try {
|
|
6104
|
+
const existingScaCoin = await builder.suiKit.suiInteractor.selectCoins(
|
|
6105
|
+
sender,
|
|
6106
|
+
Infinity,
|
|
6107
|
+
coinIds.sca
|
|
6108
|
+
);
|
|
6109
|
+
txBlock.mergeCoins(rewardCoin, existingScaCoin);
|
|
6110
|
+
} catch (e) {
|
|
6111
|
+
} finally {
|
|
6112
|
+
toTransferObject.push(rewardCoin);
|
|
6113
|
+
}
|
|
6114
|
+
if (toTransferObject.length > 0) {
|
|
6115
|
+
txBlock.transferObjects(toTransferObject, sender);
|
|
6116
|
+
}
|
|
6117
|
+
}
|
|
6118
|
+
};
|
|
6119
|
+
};
|
|
6120
|
+
var newLoyaltyProgramTxBlock = (builder, initTxBlock) => {
|
|
6121
|
+
const txBlock = initTxBlock instanceof TransactionBlock6 ? new SuiKitTxBlock6(initTxBlock) : initTxBlock ? initTxBlock : new SuiKitTxBlock6();
|
|
6122
|
+
const normalMethod = generateLoyaltyProgramNormalMethod({
|
|
6123
|
+
builder,
|
|
6124
|
+
txBlock
|
|
6125
|
+
});
|
|
6126
|
+
const normalTxBlock = new Proxy(txBlock, {
|
|
6127
|
+
get: (target, prop) => {
|
|
6128
|
+
if (prop in normalMethod) {
|
|
6129
|
+
return Reflect.get(normalMethod, prop);
|
|
6130
|
+
}
|
|
6131
|
+
return Reflect.get(target, prop);
|
|
6132
|
+
}
|
|
6133
|
+
});
|
|
6134
|
+
const quickMethod = generateLoyaltyProgramQuickMethod({
|
|
6135
|
+
builder,
|
|
6136
|
+
txBlock: normalTxBlock
|
|
6137
|
+
});
|
|
6138
|
+
return new Proxy(normalTxBlock, {
|
|
6139
|
+
get: (target, prop) => {
|
|
6140
|
+
if (prop in quickMethod) {
|
|
6141
|
+
return Reflect.get(quickMethod, prop);
|
|
6142
|
+
}
|
|
6143
|
+
return Reflect.get(target, prop);
|
|
6144
|
+
}
|
|
6145
|
+
});
|
|
6146
|
+
};
|
|
6147
|
+
|
|
5639
6148
|
// src/builders/index.ts
|
|
5640
6149
|
var newScallopTxBlock = (builder, initTxBlock) => {
|
|
5641
6150
|
const vescaTxBlock = newVeScaTxBlock(builder, initTxBlock);
|
|
6151
|
+
const loyaltyTxBlock = newLoyaltyProgramTxBlock(builder, vescaTxBlock);
|
|
5642
6152
|
const borrowIncentiveTxBlock = newBorrowIncentiveTxBlock(
|
|
5643
6153
|
builder,
|
|
5644
|
-
|
|
6154
|
+
loyaltyTxBlock
|
|
5645
6155
|
);
|
|
5646
6156
|
const referralTxBlock = newReferralTxBlock(builder, borrowIncentiveTxBlock);
|
|
5647
6157
|
const spoolTxBlock = newSpoolTxBlock(builder, referralTxBlock);
|
|
@@ -5656,6 +6166,8 @@ var newScallopTxBlock = (builder, initTxBlock) => {
|
|
|
5656
6166
|
return Reflect.get(referralTxBlock, prop);
|
|
5657
6167
|
} else if (prop in spoolTxBlock) {
|
|
5658
6168
|
return Reflect.get(spoolTxBlock, prop);
|
|
6169
|
+
} else if (prop in loyaltyTxBlock) {
|
|
6170
|
+
return Reflect.get(loyaltyTxBlock, prop);
|
|
5659
6171
|
}
|
|
5660
6172
|
return Reflect.get(target, prop);
|
|
5661
6173
|
}
|