@glowlabs-org/utils 0.2.154 → 0.2.156
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/README.md +175 -17
- package/dist/cjs/browser.d.ts +2 -0
- package/dist/cjs/browser.js +7 -1
- package/dist/cjs/browser.js.map +1 -1
- package/dist/cjs/{farms-router-DwbBMkUd.js → farms-router-DekpTBQj.js} +750 -11
- package/dist/cjs/farms-router-DekpTBQj.js.map +1 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/abis/rewardKernelABI.d.ts +418 -0
- package/dist/cjs/lib/control-api/farms-router.d.ts +2 -1
- package/dist/cjs/lib/control-api/region-router.d.ts +2 -1
- package/dist/cjs/lib/control-api/wallets-router.d.ts +2 -2
- package/dist/cjs/lib/hooks/use-rewards-kernel.d.ts +45 -0
- package/dist/cjs/lib/types/index.d.ts +77 -1
- package/dist/esm/browser.d.ts +2 -0
- package/dist/esm/browser.js +2 -2
- package/dist/esm/{farms-router-C0g4hf2Z.js → farms-router-L56VPDNz.js} +749 -12
- package/dist/esm/farms-router-L56VPDNz.js.map +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/lib/abis/rewardKernelABI.d.ts +418 -0
- package/dist/esm/lib/control-api/farms-router.d.ts +2 -1
- package/dist/esm/lib/control-api/region-router.d.ts +2 -1
- package/dist/esm/lib/control-api/wallets-router.d.ts +2 -2
- package/dist/esm/lib/hooks/use-rewards-kernel.d.ts +45 -0
- package/dist/esm/lib/types/index.d.ts +77 -1
- package/package.json +1 -1
- package/src/browser.ts +2 -0
- package/src/index.ts +1 -0
- package/src/lib/abis/rewardKernelABI.ts +264 -0
- package/src/lib/control-api/farms-router.ts +33 -0
- package/src/lib/control-api/region-router.ts +29 -0
- package/src/lib/control-api/wallets-router.ts +36 -2
- package/src/lib/hooks/README.md +295 -0
- package/src/lib/hooks/use-rewards-kernel.ts +547 -0
- package/src/lib/types/index.ts +91 -1
- package/dist/cjs/farms-router-DwbBMkUd.js.map +0 -1
- package/dist/esm/farms-router-C0g4hf2Z.js.map +0 -1
|
@@ -1564,7 +1564,7 @@ exports.OffchainFractionsError = void 0;
|
|
|
1564
1564
|
OffchainFractionsError["INSUFFICIENT_ALLOWANCE"] = "Insufficient allowance";
|
|
1565
1565
|
})(exports.OffchainFractionsError || (exports.OffchainFractionsError = {}));
|
|
1566
1566
|
// Type-guard style helper to ensure a wallet client exists throughout the rest of the function.
|
|
1567
|
-
function assertWalletClient(maybeWalletClient) {
|
|
1567
|
+
function assertWalletClient$1(maybeWalletClient) {
|
|
1568
1568
|
if (!maybeWalletClient) {
|
|
1569
1569
|
throw new Error(exports.OffchainFractionsError.SIGNER_NOT_AVAILABLE);
|
|
1570
1570
|
}
|
|
@@ -1632,7 +1632,7 @@ function useOffchainFractions(walletClient, publicClient, CHAIN_ID) {
|
|
|
1632
1632
|
* @param amount Amount to approve (BigNumber)
|
|
1633
1633
|
*/
|
|
1634
1634
|
async function approveToken(tokenAddress, amount) {
|
|
1635
|
-
assertWalletClient(walletClient);
|
|
1635
|
+
assertWalletClient$1(walletClient);
|
|
1636
1636
|
assertPublicClient(publicClient);
|
|
1637
1637
|
try {
|
|
1638
1638
|
setIsProcessing(true);
|
|
@@ -1659,7 +1659,7 @@ function useOffchainFractions(walletClient, publicClient, CHAIN_ID) {
|
|
|
1659
1659
|
* @param params Parameters for creating the fraction
|
|
1660
1660
|
*/
|
|
1661
1661
|
async function createFraction(params) {
|
|
1662
|
-
assertWalletClient(walletClient);
|
|
1662
|
+
assertWalletClient$1(walletClient);
|
|
1663
1663
|
assertPublicClient(publicClient);
|
|
1664
1664
|
try {
|
|
1665
1665
|
setIsProcessing(true);
|
|
@@ -1761,7 +1761,7 @@ function useOffchainFractions(walletClient, publicClient, CHAIN_ID) {
|
|
|
1761
1761
|
* @param params Parameters for buying fractions
|
|
1762
1762
|
*/
|
|
1763
1763
|
async function buyFractions(params) {
|
|
1764
|
-
assertWalletClient(walletClient);
|
|
1764
|
+
assertWalletClient$1(walletClient);
|
|
1765
1765
|
assertPublicClient(publicClient);
|
|
1766
1766
|
try {
|
|
1767
1767
|
setIsProcessing(true);
|
|
@@ -1891,7 +1891,7 @@ function useOffchainFractions(walletClient, publicClient, CHAIN_ID) {
|
|
|
1891
1891
|
* @param id The unique identifier of the fraction sale
|
|
1892
1892
|
*/
|
|
1893
1893
|
async function claimRefund(user, creator, id) {
|
|
1894
|
-
assertWalletClient(walletClient);
|
|
1894
|
+
assertWalletClient$1(walletClient);
|
|
1895
1895
|
assertPublicClient(publicClient);
|
|
1896
1896
|
try {
|
|
1897
1897
|
setIsProcessing(true);
|
|
@@ -1995,7 +1995,7 @@ function useOffchainFractions(walletClient, publicClient, CHAIN_ID) {
|
|
|
1995
1995
|
* @param id The unique identifier of the fraction sale to close
|
|
1996
1996
|
*/
|
|
1997
1997
|
async function closeFraction(creator, id) {
|
|
1998
|
-
assertWalletClient(walletClient);
|
|
1998
|
+
assertWalletClient$1(walletClient);
|
|
1999
1999
|
assertPublicClient(publicClient);
|
|
2000
2000
|
try {
|
|
2001
2001
|
setIsProcessing(true);
|
|
@@ -2176,7 +2176,7 @@ function useOffchainFractions(walletClient, publicClient, CHAIN_ID) {
|
|
|
2176
2176
|
* @param useCounterfactualAddress Whether to use counterfactual address for refunds
|
|
2177
2177
|
*/
|
|
2178
2178
|
async function setRefundDetails(creator, id, refundTo, useCounterfactualAddress) {
|
|
2179
|
-
assertWalletClient(walletClient);
|
|
2179
|
+
assertWalletClient$1(walletClient);
|
|
2180
2180
|
assertPublicClient(publicClient);
|
|
2181
2181
|
try {
|
|
2182
2182
|
setIsProcessing(true);
|
|
@@ -2264,7 +2264,7 @@ function useOffchainFractions(walletClient, publicClient, CHAIN_ID) {
|
|
|
2264
2264
|
* @param isApproved Whether to approve or revoke the operator
|
|
2265
2265
|
*/
|
|
2266
2266
|
async function setRefundOperatorStatus(refundOperator, isApproved) {
|
|
2267
|
-
assertWalletClient(walletClient);
|
|
2267
|
+
assertWalletClient$1(walletClient);
|
|
2268
2268
|
assertPublicClient(publicClient);
|
|
2269
2269
|
try {
|
|
2270
2270
|
setIsProcessing(true);
|
|
@@ -2449,7 +2449,7 @@ function useOffchainFractions(walletClient, publicClient, CHAIN_ID) {
|
|
|
2449
2449
|
* @param ethPriceInUSD Current ETH price in USD (for cost estimation)
|
|
2450
2450
|
*/
|
|
2451
2451
|
async function estimateGasForCreateFraction(params, ethPriceInUSD) {
|
|
2452
|
-
assertWalletClient(walletClient);
|
|
2452
|
+
assertWalletClient$1(walletClient);
|
|
2453
2453
|
assertPublicClient(publicClient);
|
|
2454
2454
|
try {
|
|
2455
2455
|
const { id, token, step, totalSteps, expiration, to, useCounterfactualAddress, minSharesToRaise, closer, } = params;
|
|
@@ -2494,7 +2494,7 @@ function useOffchainFractions(walletClient, publicClient, CHAIN_ID) {
|
|
|
2494
2494
|
* @param ethPriceInUSD Current ETH price in USD (for cost estimation)
|
|
2495
2495
|
*/
|
|
2496
2496
|
async function estimateGasForBuyFractions(params, ethPriceInUSD) {
|
|
2497
|
-
assertWalletClient(walletClient);
|
|
2497
|
+
assertWalletClient$1(walletClient);
|
|
2498
2498
|
assertPublicClient(publicClient);
|
|
2499
2499
|
try {
|
|
2500
2500
|
const { creator, id, stepsToBuy, minStepsToBuy, refundTo, creditTo, useCounterfactualAddressForRefund, } = params;
|
|
@@ -2570,6 +2570,680 @@ function useOffchainFractions(walletClient, publicClient, CHAIN_ID) {
|
|
|
2570
2570
|
};
|
|
2571
2571
|
}
|
|
2572
2572
|
|
|
2573
|
+
const REWARDS_KERNEL_ABI = [
|
|
2574
|
+
{
|
|
2575
|
+
inputs: [
|
|
2576
|
+
{ internalType: "address", name: "_foundationMultisig", type: "address" },
|
|
2577
|
+
{ internalType: "address", name: "_rejectionMultisig", type: "address" },
|
|
2578
|
+
{
|
|
2579
|
+
internalType: "contract CounterfactualHolderFactory",
|
|
2580
|
+
name: "f",
|
|
2581
|
+
type: "address",
|
|
2582
|
+
},
|
|
2583
|
+
{ internalType: "uint256", name: "_finality", type: "uint256" },
|
|
2584
|
+
],
|
|
2585
|
+
stateMutability: "payable",
|
|
2586
|
+
type: "constructor",
|
|
2587
|
+
},
|
|
2588
|
+
{
|
|
2589
|
+
inputs: [{ internalType: "address", name: "target", type: "address" }],
|
|
2590
|
+
name: "AddressEmptyCode",
|
|
2591
|
+
type: "error",
|
|
2592
|
+
},
|
|
2593
|
+
{
|
|
2594
|
+
inputs: [{ internalType: "address", name: "account", type: "address" }],
|
|
2595
|
+
name: "AddressInsufficientBalance",
|
|
2596
|
+
type: "error",
|
|
2597
|
+
},
|
|
2598
|
+
{ inputs: [], name: "AlreadyClaimedNonce", type: "error" },
|
|
2599
|
+
{ inputs: [], name: "AlreadyFinalized", type: "error" },
|
|
2600
|
+
{ inputs: [], name: "AlreadyRejected", type: "error" },
|
|
2601
|
+
{ inputs: [], name: "CannotClaimFromRejectedNonce", type: "error" },
|
|
2602
|
+
{ inputs: [], name: "CannotPostZeroRoot", type: "error" },
|
|
2603
|
+
{ inputs: [], name: "DuplicateToken", type: "error" },
|
|
2604
|
+
{ inputs: [], name: "FailedInnerCall", type: "error" },
|
|
2605
|
+
{ inputs: [], name: "InvalidMerkleProof", type: "error" },
|
|
2606
|
+
{ inputs: [], name: "LengthsDontMatch", type: "error" },
|
|
2607
|
+
{ inputs: [], name: "MaxClaimedExceeded", type: "error" },
|
|
2608
|
+
{ inputs: [], name: "NonexistentDataAtNonce", type: "error" },
|
|
2609
|
+
{ inputs: [], name: "NotFoundationMultisig", type: "error" },
|
|
2610
|
+
{ inputs: [], name: "NotRejectionMultisig", type: "error" },
|
|
2611
|
+
{ inputs: [], name: "NotYetFinalized", type: "error" },
|
|
2612
|
+
{ inputs: [], name: "ReentrancyGuardReentrantCall", type: "error" },
|
|
2613
|
+
{
|
|
2614
|
+
inputs: [{ internalType: "address", name: "token", type: "address" }],
|
|
2615
|
+
name: "SafeERC20FailedOperation",
|
|
2616
|
+
type: "error",
|
|
2617
|
+
},
|
|
2618
|
+
{
|
|
2619
|
+
anonymous: false,
|
|
2620
|
+
inputs: [
|
|
2621
|
+
{
|
|
2622
|
+
indexed: true,
|
|
2623
|
+
internalType: "uint256",
|
|
2624
|
+
name: "nonce",
|
|
2625
|
+
type: "uint256",
|
|
2626
|
+
},
|
|
2627
|
+
],
|
|
2628
|
+
name: "NonceRejected",
|
|
2629
|
+
type: "event",
|
|
2630
|
+
},
|
|
2631
|
+
{
|
|
2632
|
+
anonymous: false,
|
|
2633
|
+
inputs: [
|
|
2634
|
+
{ indexed: true, internalType: "address", name: "user", type: "address" },
|
|
2635
|
+
{ indexed: true, internalType: "address", name: "to", type: "address" },
|
|
2636
|
+
{
|
|
2637
|
+
indexed: true,
|
|
2638
|
+
internalType: "uint256",
|
|
2639
|
+
name: "nonce",
|
|
2640
|
+
type: "uint256",
|
|
2641
|
+
},
|
|
2642
|
+
{
|
|
2643
|
+
indexed: false,
|
|
2644
|
+
internalType: "address",
|
|
2645
|
+
name: "from",
|
|
2646
|
+
type: "address",
|
|
2647
|
+
},
|
|
2648
|
+
{
|
|
2649
|
+
components: [
|
|
2650
|
+
{ internalType: "address", name: "token", type: "address" },
|
|
2651
|
+
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
2652
|
+
],
|
|
2653
|
+
indexed: false,
|
|
2654
|
+
internalType: "struct FoundationRewardKernel.TokenAndAmount[]",
|
|
2655
|
+
name: "taa",
|
|
2656
|
+
type: "tuple[]",
|
|
2657
|
+
},
|
|
2658
|
+
{
|
|
2659
|
+
indexed: false,
|
|
2660
|
+
internalType: "bool[]",
|
|
2661
|
+
name: "isGuarded",
|
|
2662
|
+
type: "bool[]",
|
|
2663
|
+
},
|
|
2664
|
+
],
|
|
2665
|
+
name: "RewardClaimed",
|
|
2666
|
+
type: "event",
|
|
2667
|
+
},
|
|
2668
|
+
{
|
|
2669
|
+
anonymous: false,
|
|
2670
|
+
inputs: [
|
|
2671
|
+
{
|
|
2672
|
+
indexed: true,
|
|
2673
|
+
internalType: "uint256",
|
|
2674
|
+
name: "nonce",
|
|
2675
|
+
type: "uint256",
|
|
2676
|
+
},
|
|
2677
|
+
{ indexed: true, internalType: "bytes32", name: "root", type: "bytes32" },
|
|
2678
|
+
{
|
|
2679
|
+
components: [
|
|
2680
|
+
{ internalType: "address", name: "token", type: "address" },
|
|
2681
|
+
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
2682
|
+
],
|
|
2683
|
+
indexed: false,
|
|
2684
|
+
internalType: "struct FoundationRewardKernel.TokenAndAmount[]",
|
|
2685
|
+
name: "taa",
|
|
2686
|
+
type: "tuple[]",
|
|
2687
|
+
},
|
|
2688
|
+
],
|
|
2689
|
+
name: "RootPosted",
|
|
2690
|
+
type: "event",
|
|
2691
|
+
},
|
|
2692
|
+
{
|
|
2693
|
+
inputs: [],
|
|
2694
|
+
name: "$nextPostNonce",
|
|
2695
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
2696
|
+
stateMutability: "view",
|
|
2697
|
+
type: "function",
|
|
2698
|
+
},
|
|
2699
|
+
{
|
|
2700
|
+
inputs: [],
|
|
2701
|
+
name: "CFH_FACTORY",
|
|
2702
|
+
outputs: [
|
|
2703
|
+
{
|
|
2704
|
+
internalType: "contract CounterfactualHolderFactory",
|
|
2705
|
+
name: "",
|
|
2706
|
+
type: "address",
|
|
2707
|
+
},
|
|
2708
|
+
],
|
|
2709
|
+
stateMutability: "view",
|
|
2710
|
+
type: "function",
|
|
2711
|
+
},
|
|
2712
|
+
{
|
|
2713
|
+
inputs: [],
|
|
2714
|
+
name: "FINALITY",
|
|
2715
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
2716
|
+
stateMutability: "view",
|
|
2717
|
+
type: "function",
|
|
2718
|
+
},
|
|
2719
|
+
{
|
|
2720
|
+
inputs: [],
|
|
2721
|
+
name: "FOUNDATION_MULTISIG",
|
|
2722
|
+
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
2723
|
+
stateMutability: "view",
|
|
2724
|
+
type: "function",
|
|
2725
|
+
},
|
|
2726
|
+
{
|
|
2727
|
+
inputs: [],
|
|
2728
|
+
name: "REJECTION_MULTISIG",
|
|
2729
|
+
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
2730
|
+
stateMutability: "view",
|
|
2731
|
+
type: "function",
|
|
2732
|
+
},
|
|
2733
|
+
{
|
|
2734
|
+
inputs: [
|
|
2735
|
+
{ internalType: "uint256", name: "nonce", type: "uint256" },
|
|
2736
|
+
{ internalType: "bytes32[]", name: "proof", type: "bytes32[]" },
|
|
2737
|
+
{
|
|
2738
|
+
components: [
|
|
2739
|
+
{ internalType: "address", name: "token", type: "address" },
|
|
2740
|
+
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
2741
|
+
],
|
|
2742
|
+
internalType: "struct FoundationRewardKernel.TokenAndAmount[]",
|
|
2743
|
+
name: "taa",
|
|
2744
|
+
type: "tuple[]",
|
|
2745
|
+
},
|
|
2746
|
+
{ internalType: "address", name: "from", type: "address" },
|
|
2747
|
+
{ internalType: "address", name: "to", type: "address" },
|
|
2748
|
+
{ internalType: "bool[]", name: "isGuardedToken", type: "bool[]" },
|
|
2749
|
+
{ internalType: "bool[]", name: "toCounterfactual", type: "bool[]" },
|
|
2750
|
+
],
|
|
2751
|
+
name: "claimPayout",
|
|
2752
|
+
outputs: [],
|
|
2753
|
+
stateMutability: "nonpayable",
|
|
2754
|
+
type: "function",
|
|
2755
|
+
},
|
|
2756
|
+
{
|
|
2757
|
+
inputs: [
|
|
2758
|
+
{ internalType: "uint256", name: "nonce", type: "uint256" },
|
|
2759
|
+
{ internalType: "address", name: "token", type: "address" },
|
|
2760
|
+
],
|
|
2761
|
+
name: "getAmountClaimed",
|
|
2762
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
2763
|
+
stateMutability: "view",
|
|
2764
|
+
type: "function",
|
|
2765
|
+
},
|
|
2766
|
+
{
|
|
2767
|
+
inputs: [
|
|
2768
|
+
{ internalType: "uint256", name: "nonce", type: "uint256" },
|
|
2769
|
+
{ internalType: "address", name: "token", type: "address" },
|
|
2770
|
+
],
|
|
2771
|
+
name: "getMaxReward",
|
|
2772
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
2773
|
+
stateMutability: "view",
|
|
2774
|
+
type: "function",
|
|
2775
|
+
},
|
|
2776
|
+
{
|
|
2777
|
+
inputs: [{ internalType: "uint256", name: "nonce", type: "uint256" }],
|
|
2778
|
+
name: "getRewardMeta",
|
|
2779
|
+
outputs: [
|
|
2780
|
+
{ internalType: "bytes32", name: "merkleRoot", type: "bytes32" },
|
|
2781
|
+
{ internalType: "uint48", name: "pushTimestamp", type: "uint48" },
|
|
2782
|
+
{ internalType: "bool", name: "rejected", type: "bool" },
|
|
2783
|
+
],
|
|
2784
|
+
stateMutability: "view",
|
|
2785
|
+
type: "function",
|
|
2786
|
+
},
|
|
2787
|
+
{
|
|
2788
|
+
inputs: [
|
|
2789
|
+
{ internalType: "address", name: "user", type: "address" },
|
|
2790
|
+
{ internalType: "uint256", name: "nonce", type: "uint256" },
|
|
2791
|
+
],
|
|
2792
|
+
name: "isClaimed",
|
|
2793
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
2794
|
+
stateMutability: "view",
|
|
2795
|
+
type: "function",
|
|
2796
|
+
},
|
|
2797
|
+
{
|
|
2798
|
+
inputs: [{ internalType: "uint256", name: "nonce", type: "uint256" }],
|
|
2799
|
+
name: "isFinalized",
|
|
2800
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
2801
|
+
stateMutability: "view",
|
|
2802
|
+
type: "function",
|
|
2803
|
+
},
|
|
2804
|
+
{
|
|
2805
|
+
inputs: [{ internalType: "bytes[]", name: "data", type: "bytes[]" }],
|
|
2806
|
+
name: "multicall",
|
|
2807
|
+
outputs: [{ internalType: "bytes[]", name: "results", type: "bytes[]" }],
|
|
2808
|
+
stateMutability: "nonpayable",
|
|
2809
|
+
type: "function",
|
|
2810
|
+
},
|
|
2811
|
+
{
|
|
2812
|
+
inputs: [
|
|
2813
|
+
{ internalType: "bytes32", name: "root", type: "bytes32" },
|
|
2814
|
+
{
|
|
2815
|
+
components: [
|
|
2816
|
+
{ internalType: "address", name: "token", type: "address" },
|
|
2817
|
+
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
2818
|
+
],
|
|
2819
|
+
internalType: "struct FoundationRewardKernel.TokenAndAmount[]",
|
|
2820
|
+
name: "taa",
|
|
2821
|
+
type: "tuple[]",
|
|
2822
|
+
},
|
|
2823
|
+
],
|
|
2824
|
+
name: "postPayoutRoot",
|
|
2825
|
+
outputs: [],
|
|
2826
|
+
stateMutability: "nonpayable",
|
|
2827
|
+
type: "function",
|
|
2828
|
+
},
|
|
2829
|
+
{
|
|
2830
|
+
inputs: [{ internalType: "uint256", name: "nonce", type: "uint256" }],
|
|
2831
|
+
name: "rejectNonce",
|
|
2832
|
+
outputs: [],
|
|
2833
|
+
stateMutability: "nonpayable",
|
|
2834
|
+
type: "function",
|
|
2835
|
+
},
|
|
2836
|
+
];
|
|
2837
|
+
|
|
2838
|
+
exports.RewardsKernelError = void 0;
|
|
2839
|
+
(function (RewardsKernelError) {
|
|
2840
|
+
RewardsKernelError["CONTRACT_NOT_AVAILABLE"] = "Contract not available";
|
|
2841
|
+
RewardsKernelError["SIGNER_NOT_AVAILABLE"] = "Signer not available";
|
|
2842
|
+
RewardsKernelError["UNKNOWN_ERROR"] = "Unknown error";
|
|
2843
|
+
RewardsKernelError["INVALID_PARAMETERS"] = "Invalid parameters";
|
|
2844
|
+
RewardsKernelError["ALREADY_CLAIMED"] = "Already claimed from this nonce";
|
|
2845
|
+
RewardsKernelError["NOT_FINALIZED"] = "Nonce not yet finalized";
|
|
2846
|
+
RewardsKernelError["NONCE_REJECTED"] = "Cannot claim from rejected nonce";
|
|
2847
|
+
})(exports.RewardsKernelError || (exports.RewardsKernelError = {}));
|
|
2848
|
+
// Type-guard style helper to ensure a wallet client exists
|
|
2849
|
+
function assertWalletClient(maybeWalletClient) {
|
|
2850
|
+
if (!maybeWalletClient) {
|
|
2851
|
+
throw new Error(exports.RewardsKernelError.SIGNER_NOT_AVAILABLE);
|
|
2852
|
+
}
|
|
2853
|
+
if (!maybeWalletClient.account) {
|
|
2854
|
+
throw new Error("Wallet client must have an account");
|
|
2855
|
+
}
|
|
2856
|
+
}
|
|
2857
|
+
function useRewardsKernel(walletClient, publicClient, CHAIN_ID) {
|
|
2858
|
+
// Use dynamic addresses based on chain configuration
|
|
2859
|
+
const ADDRESSES = getAddresses(CHAIN_ID);
|
|
2860
|
+
// Framework-agnostic processing flag
|
|
2861
|
+
let isProcessing = false;
|
|
2862
|
+
const setIsProcessing = (value) => {
|
|
2863
|
+
isProcessing = value;
|
|
2864
|
+
};
|
|
2865
|
+
// Helper to assert public client is available
|
|
2866
|
+
function assertPublicClient(maybePublicClient) {
|
|
2867
|
+
if (!maybePublicClient) {
|
|
2868
|
+
throw new Error("Public client not available");
|
|
2869
|
+
}
|
|
2870
|
+
}
|
|
2871
|
+
/**
|
|
2872
|
+
* Claim payout from a finalized nonce
|
|
2873
|
+
* @param params Parameters for claiming the payout
|
|
2874
|
+
*/
|
|
2875
|
+
async function claimPayout(params) {
|
|
2876
|
+
assertWalletClient(walletClient);
|
|
2877
|
+
assertPublicClient(publicClient);
|
|
2878
|
+
try {
|
|
2879
|
+
setIsProcessing(true);
|
|
2880
|
+
sentryAddBreadcrumb({
|
|
2881
|
+
category: "rewards-kernel",
|
|
2882
|
+
message: "claimPayout.start",
|
|
2883
|
+
level: "info",
|
|
2884
|
+
data: {
|
|
2885
|
+
chainId: walletClient?.chain?.id,
|
|
2886
|
+
contract: ADDRESSES.REWARDS_KERNEL,
|
|
2887
|
+
nonce: params.nonce.toString(),
|
|
2888
|
+
to: params.to,
|
|
2889
|
+
from: params.from,
|
|
2890
|
+
tokensCount: params.tokensAndAmounts.length,
|
|
2891
|
+
},
|
|
2892
|
+
});
|
|
2893
|
+
const { nonce, proof, tokensAndAmounts, from, to, isGuardedToken, toCounterfactual, } = params;
|
|
2894
|
+
// Validate parameters
|
|
2895
|
+
if (!proof || proof.length === 0) {
|
|
2896
|
+
throw new Error("Merkle proof is required");
|
|
2897
|
+
}
|
|
2898
|
+
if (!tokensAndAmounts || tokensAndAmounts.length === 0) {
|
|
2899
|
+
throw new Error("Tokens and amounts are required");
|
|
2900
|
+
}
|
|
2901
|
+
if (isGuardedToken.length !== tokensAndAmounts.length) {
|
|
2902
|
+
throw new Error("isGuardedToken array length must match tokensAndAmounts");
|
|
2903
|
+
}
|
|
2904
|
+
if (toCounterfactual.length !== tokensAndAmounts.length) {
|
|
2905
|
+
throw new Error("toCounterfactual array length must match tokensAndAmounts");
|
|
2906
|
+
}
|
|
2907
|
+
if (!from || !to) {
|
|
2908
|
+
throw new Error(exports.RewardsKernelError.INVALID_PARAMETERS);
|
|
2909
|
+
}
|
|
2910
|
+
// Check if already claimed
|
|
2911
|
+
const owner = walletClient.account?.address;
|
|
2912
|
+
if (!owner) {
|
|
2913
|
+
throw new Error("No account found in wallet client");
|
|
2914
|
+
}
|
|
2915
|
+
const alreadyClaimed = await isClaimed(owner, nonce);
|
|
2916
|
+
if (alreadyClaimed) {
|
|
2917
|
+
throw new Error(exports.RewardsKernelError.ALREADY_CLAIMED);
|
|
2918
|
+
}
|
|
2919
|
+
// Check if finalized
|
|
2920
|
+
const finalized = await isFinalized(nonce);
|
|
2921
|
+
if (!finalized) {
|
|
2922
|
+
throw new Error(exports.RewardsKernelError.NOT_FINALIZED);
|
|
2923
|
+
}
|
|
2924
|
+
// Run a simulation first to surface any revert reason
|
|
2925
|
+
try {
|
|
2926
|
+
await publicClient.simulateContract({
|
|
2927
|
+
address: ADDRESSES.REWARDS_KERNEL,
|
|
2928
|
+
abi: REWARDS_KERNEL_ABI,
|
|
2929
|
+
functionName: "claimPayout",
|
|
2930
|
+
args: [
|
|
2931
|
+
nonce,
|
|
2932
|
+
proof,
|
|
2933
|
+
tokensAndAmounts,
|
|
2934
|
+
from,
|
|
2935
|
+
to,
|
|
2936
|
+
isGuardedToken,
|
|
2937
|
+
toCounterfactual,
|
|
2938
|
+
],
|
|
2939
|
+
account: walletClient.account,
|
|
2940
|
+
});
|
|
2941
|
+
}
|
|
2942
|
+
catch (simulationError) {
|
|
2943
|
+
sentryCaptureException(simulationError, {
|
|
2944
|
+
action: "claimPayout.simulate",
|
|
2945
|
+
chainId: walletClient?.chain?.id,
|
|
2946
|
+
contract: ADDRESSES.REWARDS_KERNEL,
|
|
2947
|
+
nonce: nonce.toString(),
|
|
2948
|
+
});
|
|
2949
|
+
throw new Error(parseViemError(simulationError));
|
|
2950
|
+
}
|
|
2951
|
+
// Execute the transaction
|
|
2952
|
+
const hash = await walletClient.writeContract({
|
|
2953
|
+
address: ADDRESSES.REWARDS_KERNEL,
|
|
2954
|
+
abi: REWARDS_KERNEL_ABI,
|
|
2955
|
+
functionName: "claimPayout",
|
|
2956
|
+
args: [
|
|
2957
|
+
nonce,
|
|
2958
|
+
proof,
|
|
2959
|
+
tokensAndAmounts,
|
|
2960
|
+
from,
|
|
2961
|
+
to,
|
|
2962
|
+
isGuardedToken,
|
|
2963
|
+
toCounterfactual,
|
|
2964
|
+
],
|
|
2965
|
+
chain: walletClient.chain,
|
|
2966
|
+
account: walletClient.account,
|
|
2967
|
+
});
|
|
2968
|
+
await waitForViemTransactionWithRetry(publicClient, hash);
|
|
2969
|
+
return hash;
|
|
2970
|
+
}
|
|
2971
|
+
catch (error) {
|
|
2972
|
+
sentryCaptureException(error, {
|
|
2973
|
+
action: "claimPayout",
|
|
2974
|
+
chainId: walletClient?.chain?.id,
|
|
2975
|
+
contract: ADDRESSES.REWARDS_KERNEL,
|
|
2976
|
+
nonce: params.nonce.toString(),
|
|
2977
|
+
from: params.from,
|
|
2978
|
+
to: params.to,
|
|
2979
|
+
});
|
|
2980
|
+
throw new Error(parseViemError(error));
|
|
2981
|
+
}
|
|
2982
|
+
finally {
|
|
2983
|
+
setIsProcessing(false);
|
|
2984
|
+
}
|
|
2985
|
+
}
|
|
2986
|
+
/**
|
|
2987
|
+
* Get reward metadata for a specific nonce
|
|
2988
|
+
* @param nonce The nonce to query
|
|
2989
|
+
*/
|
|
2990
|
+
async function getRewardMeta(nonce) {
|
|
2991
|
+
assertPublicClient(publicClient);
|
|
2992
|
+
try {
|
|
2993
|
+
const result = (await publicClient.readContract({
|
|
2994
|
+
address: ADDRESSES.REWARDS_KERNEL,
|
|
2995
|
+
abi: REWARDS_KERNEL_ABI,
|
|
2996
|
+
functionName: "getRewardMeta",
|
|
2997
|
+
args: [nonce],
|
|
2998
|
+
}));
|
|
2999
|
+
return {
|
|
3000
|
+
merkleRoot: result[0],
|
|
3001
|
+
pushTimestamp: Number(result[1]),
|
|
3002
|
+
rejected: result[2],
|
|
3003
|
+
};
|
|
3004
|
+
}
|
|
3005
|
+
catch (error) {
|
|
3006
|
+
throw new Error(parseViemError(error));
|
|
3007
|
+
}
|
|
3008
|
+
}
|
|
3009
|
+
/**
|
|
3010
|
+
* Get the maximum claimable amount for a token at a specific nonce
|
|
3011
|
+
* @param nonce The nonce to query
|
|
3012
|
+
* @param token The token address
|
|
3013
|
+
*/
|
|
3014
|
+
async function getMaxReward(nonce, token) {
|
|
3015
|
+
assertPublicClient(publicClient);
|
|
3016
|
+
try {
|
|
3017
|
+
const result = (await publicClient.readContract({
|
|
3018
|
+
address: ADDRESSES.REWARDS_KERNEL,
|
|
3019
|
+
abi: REWARDS_KERNEL_ABI,
|
|
3020
|
+
functionName: "getMaxReward",
|
|
3021
|
+
args: [nonce, token],
|
|
3022
|
+
}));
|
|
3023
|
+
return result;
|
|
3024
|
+
}
|
|
3025
|
+
catch (error) {
|
|
3026
|
+
throw new Error(parseViemError(error));
|
|
3027
|
+
}
|
|
3028
|
+
}
|
|
3029
|
+
/**
|
|
3030
|
+
* Get the amount already claimed for a token at a specific nonce
|
|
3031
|
+
* @param nonce The nonce to query
|
|
3032
|
+
* @param token The token address
|
|
3033
|
+
*/
|
|
3034
|
+
async function getAmountClaimed(nonce, token) {
|
|
3035
|
+
assertPublicClient(publicClient);
|
|
3036
|
+
try {
|
|
3037
|
+
const result = (await publicClient.readContract({
|
|
3038
|
+
address: ADDRESSES.REWARDS_KERNEL,
|
|
3039
|
+
abi: REWARDS_KERNEL_ABI,
|
|
3040
|
+
functionName: "getAmountClaimed",
|
|
3041
|
+
args: [nonce, token],
|
|
3042
|
+
}));
|
|
3043
|
+
return result;
|
|
3044
|
+
}
|
|
3045
|
+
catch (error) {
|
|
3046
|
+
throw new Error(parseViemError(error));
|
|
3047
|
+
}
|
|
3048
|
+
}
|
|
3049
|
+
/**
|
|
3050
|
+
* Check if a nonce is finalized and claimable
|
|
3051
|
+
* @param nonce The nonce to check
|
|
3052
|
+
*/
|
|
3053
|
+
async function isFinalized(nonce) {
|
|
3054
|
+
assertPublicClient(publicClient);
|
|
3055
|
+
try {
|
|
3056
|
+
const result = (await publicClient.readContract({
|
|
3057
|
+
address: ADDRESSES.REWARDS_KERNEL,
|
|
3058
|
+
abi: REWARDS_KERNEL_ABI,
|
|
3059
|
+
functionName: "isFinalized",
|
|
3060
|
+
args: [nonce],
|
|
3061
|
+
}));
|
|
3062
|
+
return result;
|
|
3063
|
+
}
|
|
3064
|
+
catch (error) {
|
|
3065
|
+
throw new Error(parseViemError(error));
|
|
3066
|
+
}
|
|
3067
|
+
}
|
|
3068
|
+
/**
|
|
3069
|
+
* Check if a user has already claimed from a specific nonce
|
|
3070
|
+
* @param user The user address
|
|
3071
|
+
* @param nonce The nonce to check
|
|
3072
|
+
*/
|
|
3073
|
+
async function isClaimed(user, nonce) {
|
|
3074
|
+
assertPublicClient(publicClient);
|
|
3075
|
+
try {
|
|
3076
|
+
const result = (await publicClient.readContract({
|
|
3077
|
+
address: ADDRESSES.REWARDS_KERNEL,
|
|
3078
|
+
abi: REWARDS_KERNEL_ABI,
|
|
3079
|
+
functionName: "isClaimed",
|
|
3080
|
+
args: [user, nonce],
|
|
3081
|
+
}));
|
|
3082
|
+
return result;
|
|
3083
|
+
}
|
|
3084
|
+
catch (error) {
|
|
3085
|
+
throw new Error(parseViemError(error));
|
|
3086
|
+
}
|
|
3087
|
+
}
|
|
3088
|
+
/**
|
|
3089
|
+
* Get the next nonce that will be used for posting
|
|
3090
|
+
*/
|
|
3091
|
+
async function getNextPostNonce() {
|
|
3092
|
+
assertPublicClient(publicClient);
|
|
3093
|
+
try {
|
|
3094
|
+
const result = (await publicClient.readContract({
|
|
3095
|
+
address: ADDRESSES.REWARDS_KERNEL,
|
|
3096
|
+
abi: REWARDS_KERNEL_ABI,
|
|
3097
|
+
functionName: "$nextPostNonce",
|
|
3098
|
+
args: [],
|
|
3099
|
+
}));
|
|
3100
|
+
return result;
|
|
3101
|
+
}
|
|
3102
|
+
catch (error) {
|
|
3103
|
+
throw new Error(parseViemError(error));
|
|
3104
|
+
}
|
|
3105
|
+
}
|
|
3106
|
+
/**
|
|
3107
|
+
* Get the finality period in seconds
|
|
3108
|
+
*/
|
|
3109
|
+
async function getFinality() {
|
|
3110
|
+
assertPublicClient(publicClient);
|
|
3111
|
+
try {
|
|
3112
|
+
const result = (await publicClient.readContract({
|
|
3113
|
+
address: ADDRESSES.REWARDS_KERNEL,
|
|
3114
|
+
abi: REWARDS_KERNEL_ABI,
|
|
3115
|
+
functionName: "FINALITY",
|
|
3116
|
+
args: [],
|
|
3117
|
+
}));
|
|
3118
|
+
return result;
|
|
3119
|
+
}
|
|
3120
|
+
catch (error) {
|
|
3121
|
+
throw new Error(parseViemError(error));
|
|
3122
|
+
}
|
|
3123
|
+
}
|
|
3124
|
+
/**
|
|
3125
|
+
* Get the foundation multisig address
|
|
3126
|
+
*/
|
|
3127
|
+
async function getFoundationMultisig() {
|
|
3128
|
+
assertPublicClient(publicClient);
|
|
3129
|
+
try {
|
|
3130
|
+
const result = (await publicClient.readContract({
|
|
3131
|
+
address: ADDRESSES.REWARDS_KERNEL,
|
|
3132
|
+
abi: REWARDS_KERNEL_ABI,
|
|
3133
|
+
functionName: "FOUNDATION_MULTISIG",
|
|
3134
|
+
args: [],
|
|
3135
|
+
}));
|
|
3136
|
+
return result;
|
|
3137
|
+
}
|
|
3138
|
+
catch (error) {
|
|
3139
|
+
throw new Error(parseViemError(error));
|
|
3140
|
+
}
|
|
3141
|
+
}
|
|
3142
|
+
/**
|
|
3143
|
+
* Get the rejection multisig address
|
|
3144
|
+
*/
|
|
3145
|
+
async function getRejectionMultisig() {
|
|
3146
|
+
assertPublicClient(publicClient);
|
|
3147
|
+
try {
|
|
3148
|
+
const result = (await publicClient.readContract({
|
|
3149
|
+
address: ADDRESSES.REWARDS_KERNEL,
|
|
3150
|
+
abi: REWARDS_KERNEL_ABI,
|
|
3151
|
+
functionName: "REJECTION_MULTISIG",
|
|
3152
|
+
args: [],
|
|
3153
|
+
}));
|
|
3154
|
+
return result;
|
|
3155
|
+
}
|
|
3156
|
+
catch (error) {
|
|
3157
|
+
throw new Error(parseViemError(error));
|
|
3158
|
+
}
|
|
3159
|
+
}
|
|
3160
|
+
/**
|
|
3161
|
+
* Get the counterfactual holder factory address
|
|
3162
|
+
*/
|
|
3163
|
+
async function getCFHFactory() {
|
|
3164
|
+
assertPublicClient(publicClient);
|
|
3165
|
+
try {
|
|
3166
|
+
const result = (await publicClient.readContract({
|
|
3167
|
+
address: ADDRESSES.REWARDS_KERNEL,
|
|
3168
|
+
abi: REWARDS_KERNEL_ABI,
|
|
3169
|
+
functionName: "CFH_FACTORY",
|
|
3170
|
+
args: [],
|
|
3171
|
+
}));
|
|
3172
|
+
return result;
|
|
3173
|
+
}
|
|
3174
|
+
catch (error) {
|
|
3175
|
+
throw new Error(parseViemError(error));
|
|
3176
|
+
}
|
|
3177
|
+
}
|
|
3178
|
+
/**
|
|
3179
|
+
* Estimate gas for claiming a payout
|
|
3180
|
+
* @param params Parameters for claiming the payout
|
|
3181
|
+
* @param ethPriceInUSD Current ETH price in USD (for cost estimation)
|
|
3182
|
+
*/
|
|
3183
|
+
async function estimateGasForClaimPayout(params, ethPriceInUSD) {
|
|
3184
|
+
assertWalletClient(walletClient);
|
|
3185
|
+
assertPublicClient(publicClient);
|
|
3186
|
+
try {
|
|
3187
|
+
const { nonce, proof, tokensAndAmounts, from, to, isGuardedToken, toCounterfactual, } = params;
|
|
3188
|
+
const gasPrice = await publicClient.getGasPrice();
|
|
3189
|
+
if (!gasPrice) {
|
|
3190
|
+
throw new Error("Could not fetch gas price to estimate cost.");
|
|
3191
|
+
}
|
|
3192
|
+
const estimatedGas = await publicClient.estimateContractGas({
|
|
3193
|
+
address: ADDRESSES.REWARDS_KERNEL,
|
|
3194
|
+
abi: REWARDS_KERNEL_ABI,
|
|
3195
|
+
functionName: "claimPayout",
|
|
3196
|
+
args: [
|
|
3197
|
+
nonce,
|
|
3198
|
+
proof,
|
|
3199
|
+
tokensAndAmounts,
|
|
3200
|
+
from,
|
|
3201
|
+
to,
|
|
3202
|
+
isGuardedToken,
|
|
3203
|
+
toCounterfactual,
|
|
3204
|
+
],
|
|
3205
|
+
account: walletClient.account,
|
|
3206
|
+
});
|
|
3207
|
+
const estimatedCost = estimatedGas * gasPrice;
|
|
3208
|
+
if (ethPriceInUSD) {
|
|
3209
|
+
const estimatedCostInEth = viem.formatEther(estimatedCost);
|
|
3210
|
+
const estimatedCostInUSD = (parseFloat(estimatedCostInEth) * ethPriceInUSD).toFixed(2);
|
|
3211
|
+
return estimatedCostInUSD;
|
|
3212
|
+
}
|
|
3213
|
+
else {
|
|
3214
|
+
throw new Error("Could not fetch the ETH price to calculate cost in USD.");
|
|
3215
|
+
}
|
|
3216
|
+
}
|
|
3217
|
+
catch (error) {
|
|
3218
|
+
throw new Error(parseViemError(error));
|
|
3219
|
+
}
|
|
3220
|
+
}
|
|
3221
|
+
return {
|
|
3222
|
+
// Core contract functions
|
|
3223
|
+
claimPayout,
|
|
3224
|
+
// View functions
|
|
3225
|
+
getRewardMeta,
|
|
3226
|
+
getMaxReward,
|
|
3227
|
+
getAmountClaimed,
|
|
3228
|
+
isFinalized,
|
|
3229
|
+
isClaimed,
|
|
3230
|
+
getNextPostNonce,
|
|
3231
|
+
getFinality,
|
|
3232
|
+
getFoundationMultisig,
|
|
3233
|
+
getRejectionMultisig,
|
|
3234
|
+
getCFHFactory,
|
|
3235
|
+
// Gas estimation
|
|
3236
|
+
estimateGasForClaimPayout,
|
|
3237
|
+
// State
|
|
3238
|
+
get isProcessing() {
|
|
3239
|
+
return isProcessing;
|
|
3240
|
+
},
|
|
3241
|
+
addresses: ADDRESSES,
|
|
3242
|
+
// Wallet client availability
|
|
3243
|
+
isSignerAvailable: !!walletClient,
|
|
3244
|
+
};
|
|
3245
|
+
}
|
|
3246
|
+
|
|
2573
3247
|
// --------------------------------------------------------------------------
|
|
2574
3248
|
/**
|
|
2575
3249
|
* Extract a useful error message from an unknown error value.
|
|
@@ -3830,6 +4504,25 @@ function RegionRouter(baseUrl) {
|
|
|
3830
4504
|
throw new Error(parseApiError$3(error));
|
|
3831
4505
|
}
|
|
3832
4506
|
};
|
|
4507
|
+
const fetchRegionWeeklyRewards = async (regionId, query) => {
|
|
4508
|
+
try {
|
|
4509
|
+
const params = new URLSearchParams();
|
|
4510
|
+
if (query?.startWeek !== undefined)
|
|
4511
|
+
params.set("startWeek", query.startWeek.toString());
|
|
4512
|
+
if (query?.endWeek !== undefined)
|
|
4513
|
+
params.set("endWeek", query.endWeek.toString());
|
|
4514
|
+
if (query?.paymentCurrency)
|
|
4515
|
+
params.set("paymentCurrency", query.paymentCurrency);
|
|
4516
|
+
if (query?.limit !== undefined)
|
|
4517
|
+
params.set("limit", query.limit.toString());
|
|
4518
|
+
const queryString = params.toString();
|
|
4519
|
+
const path = `/regions/weekly-rewards/${regionId}${queryString ? `?${queryString}` : ""}`;
|
|
4520
|
+
return await request(path);
|
|
4521
|
+
}
|
|
4522
|
+
catch (error) {
|
|
4523
|
+
throw new Error(parseApiError$3(error));
|
|
4524
|
+
}
|
|
4525
|
+
};
|
|
3833
4526
|
const applyInstallerCertification = async (payload) => {
|
|
3834
4527
|
try {
|
|
3835
4528
|
return await request(`/regions/installers/apply`, {
|
|
@@ -3891,6 +4584,7 @@ function RegionRouter(baseUrl) {
|
|
|
3891
4584
|
fetchRegionSolarFarms,
|
|
3892
4585
|
fetchActiveSummary,
|
|
3893
4586
|
fetchRecentActivity,
|
|
4587
|
+
fetchRegionWeeklyRewards,
|
|
3894
4588
|
getRegionByCode,
|
|
3895
4589
|
applyInstallerCertification,
|
|
3896
4590
|
// Cached data & flags
|
|
@@ -4108,11 +4802,31 @@ function WalletsRouter(baseUrl) {
|
|
|
4108
4802
|
throw new Error(parseApiError$1(error));
|
|
4109
4803
|
}
|
|
4110
4804
|
};
|
|
4805
|
+
const fetchWalletWeeklyRewards = async (wallet, query) => {
|
|
4806
|
+
try {
|
|
4807
|
+
const params = new URLSearchParams();
|
|
4808
|
+
if (query?.startWeek !== undefined)
|
|
4809
|
+
params.set("startWeek", query.startWeek.toString());
|
|
4810
|
+
if (query?.endWeek !== undefined)
|
|
4811
|
+
params.set("endWeek", query.endWeek.toString());
|
|
4812
|
+
if (query?.paymentCurrency)
|
|
4813
|
+
params.set("paymentCurrency", query.paymentCurrency);
|
|
4814
|
+
if (query?.limit !== undefined)
|
|
4815
|
+
params.set("limit", query.limit.toString());
|
|
4816
|
+
const queryString = params.toString();
|
|
4817
|
+
const path = `/wallets/address/${encodeURIComponent(wallet)}/weekly-rewards${queryString ? `?${queryString}` : ""}`;
|
|
4818
|
+
return await request(path);
|
|
4819
|
+
}
|
|
4820
|
+
catch (error) {
|
|
4821
|
+
throw new Error(parseApiError$1(error));
|
|
4822
|
+
}
|
|
4823
|
+
};
|
|
4111
4824
|
return {
|
|
4112
4825
|
fetchAllWallets,
|
|
4113
4826
|
fetchWalletByAddress,
|
|
4114
4827
|
fetchWalletMintedEvents,
|
|
4115
4828
|
fetchWalletStakeEvents,
|
|
4829
|
+
fetchWalletWeeklyRewards,
|
|
4116
4830
|
};
|
|
4117
4831
|
}
|
|
4118
4832
|
|
|
@@ -4176,6 +4890,28 @@ function FarmsRouter(baseUrl) {
|
|
|
4176
4890
|
throw new Error(parseApiError(error));
|
|
4177
4891
|
}
|
|
4178
4892
|
};
|
|
4893
|
+
const fetchFarmWeeklyRewards = async (farmId, query) => {
|
|
4894
|
+
try {
|
|
4895
|
+
if (!farmId) {
|
|
4896
|
+
throw new Error("Farm ID is required");
|
|
4897
|
+
}
|
|
4898
|
+
const params = new URLSearchParams();
|
|
4899
|
+
if (query?.startWeek !== undefined)
|
|
4900
|
+
params.set("startWeek", query.startWeek.toString());
|
|
4901
|
+
if (query?.endWeek !== undefined)
|
|
4902
|
+
params.set("endWeek", query.endWeek.toString());
|
|
4903
|
+
if (query?.paymentCurrency)
|
|
4904
|
+
params.set("paymentCurrency", query.paymentCurrency);
|
|
4905
|
+
if (query?.limit !== undefined)
|
|
4906
|
+
params.set("limit", query.limit.toString());
|
|
4907
|
+
const queryString = params.toString();
|
|
4908
|
+
const path = `/farms/${encodeURIComponent(farmId)}/weekly-rewards${queryString ? `?${queryString}` : ""}`;
|
|
4909
|
+
return await request(path);
|
|
4910
|
+
}
|
|
4911
|
+
catch (error) {
|
|
4912
|
+
throw new Error(parseApiError(error));
|
|
4913
|
+
}
|
|
4914
|
+
};
|
|
4179
4915
|
const estimateRewardScore = async (params) => {
|
|
4180
4916
|
try {
|
|
4181
4917
|
sentryAddBreadcrumb({
|
|
@@ -4266,6 +5002,7 @@ function FarmsRouter(baseUrl) {
|
|
|
4266
5002
|
fetchFarmRewardSplits,
|
|
4267
5003
|
fetchSponsoredFarms,
|
|
4268
5004
|
fetchWalletFarmsWithRewards,
|
|
5005
|
+
fetchFarmWeeklyRewards,
|
|
4269
5006
|
estimateRewardScore,
|
|
4270
5007
|
estimateRewardScoresBatch,
|
|
4271
5008
|
calculateMiningScoresBatch,
|
|
@@ -4284,6 +5021,7 @@ exports.MAX_WEIGHT = MAX_WEIGHT;
|
|
|
4284
5021
|
exports.OFFCHAIN_FRACTIONS_ABI = OFFCHAIN_FRACTIONS_ABI;
|
|
4285
5022
|
exports.OFF_CHAIN_PAYMENT_CURRENCIES = OFF_CHAIN_PAYMENT_CURRENCIES;
|
|
4286
5023
|
exports.PAYMENT_CURRENCIES = PAYMENT_CURRENCIES;
|
|
5024
|
+
exports.REWARDS_KERNEL_ABI = REWARDS_KERNEL_ABI;
|
|
4287
5025
|
exports.RegionRouter = RegionRouter;
|
|
4288
5026
|
exports.TRANSFER_TYPES = TRANSFER_TYPES;
|
|
4289
5027
|
exports.USDG_WEIGHT_DECIMAL_PRECISION = USDG_WEIGHT_DECIMAL_PRECISION;
|
|
@@ -4298,6 +5036,7 @@ exports.regionMetadata = regionMetadata;
|
|
|
4298
5036
|
exports.usStates = usStates;
|
|
4299
5037
|
exports.useForwarder = useForwarder;
|
|
4300
5038
|
exports.useOffchainFractions = useOffchainFractions;
|
|
5039
|
+
exports.useRewardsKernel = useRewardsKernel;
|
|
4301
5040
|
exports.waitForEthersTransactionWithRetry = waitForEthersTransactionWithRetry;
|
|
4302
5041
|
exports.waitForViemTransactionWithRetry = waitForViemTransactionWithRetry;
|
|
4303
|
-
//# sourceMappingURL=farms-router-
|
|
5042
|
+
//# sourceMappingURL=farms-router-DekpTBQj.js.map
|