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