@glowlabs-org/utils 0.2.105 → 0.2.107

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.
@@ -1,6 +1,29 @@
1
- import type { SponsoredFarm, EstimateRewardScoreParams, RewardScoreResponse, EstimateRewardScoresBatchParams, EstimateRewardScoresBatchResponse } from "../types";
1
+ /**
2
+ * # Farms Router
3
+ *
4
+ * This router handles operations related to solar farms.
5
+ *
6
+ * ## Endpoints
7
+ *
8
+ * ### GET `/farms/sponsored`
9
+ * Returns all sponsored farms, optionally filtered by sponsor wallet.
10
+ *
11
+ * ### GET `/farms/wallet/:walletAddress/farms-with-rewards`
12
+ * Returns all farms where the specified wallet address has reward splits,
13
+ * along with their calculated weekly rewards for that wallet.
14
+ *
15
+ * ### POST `/farms/estimate-reward-score`
16
+ * Calculates the reward score for a potential marketplace farm based on its
17
+ * parameters and current region data.
18
+ *
19
+ * ### POST `/farms/estimate-reward-scores-batch`
20
+ * Calculates reward scores for multiple potential marketplace farms.
21
+ * Each farm is calculated independently as if joining the protocol by itself.
22
+ */
23
+ import type { SponsoredFarm, EstimateRewardScoreParams, RewardScoreResponse, EstimateRewardScoresBatchParams, EstimateRewardScoresBatchResponse, FarmWithRewards } from "../types";
2
24
  export declare function FarmsRouter(baseUrl: string): {
3
25
  readonly fetchSponsoredFarms: (sponsorWallet?: string) => Promise<SponsoredFarm[]>;
26
+ readonly fetchWalletFarmsWithRewards: (walletAddress: string) => Promise<FarmWithRewards[]>;
4
27
  readonly estimateRewardScore: (params: EstimateRewardScoreParams) => Promise<RewardScoreResponse>;
5
28
  readonly estimateRewardScoresBatch: (params: EstimateRewardScoresBatchParams) => Promise<EstimateRewardScoresBatchResponse>;
6
29
  };
@@ -440,4 +440,17 @@ export type BatchRewardScoreResult = BatchRewardScoreSuccessResult | BatchReward
440
440
  export interface EstimateRewardScoresBatchResponse {
441
441
  results: BatchRewardScoreResult[];
442
442
  }
443
+ export interface UserWeeklyRewards {
444
+ protocolDepositRewards: string;
445
+ glwInflationRewards: string;
446
+ userGlowSplitPercent: string;
447
+ userDepositSplitPercent: string;
448
+ }
449
+ export interface FarmWithRewards extends SponsoredFarm {
450
+ userWeeklyRewards: UserWeeklyRewards;
451
+ }
452
+ export interface WalletFarmsWithRewardsResponse {
453
+ farms: FarmWithRewards[];
454
+ totalFarms: number;
455
+ }
443
456
  export type { MintedEvent as ControlMintedEvent };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glowlabs-org/utils",
3
- "version": "0.2.105",
3
+ "version": "0.2.107",
4
4
  "description": "A library containing all typechain types and addresses relating to the glow guarded launch",
5
5
  "keywords": [],
6
6
  "author": "",
@@ -42,7 +42,7 @@ const sepoliaAddresses: Record<ContractKeys, `0x${string}`> = {
42
42
  USDG_UNISWAP: "0x2a085A3aEA8982396533327c854753Ce521B666d",
43
43
  GLW_UNISWAP: "0x8e27016D0B866a56CE74A1a280c749dD679bb0Fa",
44
44
  FORWARDER: "0xDaC24F18171224eeaf6a9B38f5C5081aDbDff969",
45
- OFFCHAIN_FRACTIONS: "0x0095F2F0C7bbEEd97eCF058D28a8b768Ece32Ac3",
45
+ OFFCHAIN_FRACTIONS: "0xFc3928e923B440393A6D977AE97C069600BC9ad8",
46
46
  COUNTERFACTUAL_HOLDER_FACTORY: "0x2c3AB887746F6f4a8a4b9Db6aC800eb71945509A",
47
47
  FOUNDATION_WALLET: "0x5e230FED487c86B90f6508104149F087d9B1B0A7",
48
48
  UNISWAP_V2_ROUTER: "0xeE567Fe1712Faf6149d80dA1E6934E354124CfE3",
@@ -1,5 +1,28 @@
1
1
  "use strict";
2
2
 
3
+ /**
4
+ * # Farms Router
5
+ *
6
+ * This router handles operations related to solar farms.
7
+ *
8
+ * ## Endpoints
9
+ *
10
+ * ### GET `/farms/sponsored`
11
+ * Returns all sponsored farms, optionally filtered by sponsor wallet.
12
+ *
13
+ * ### GET `/farms/wallet/:walletAddress/farms-with-rewards`
14
+ * Returns all farms where the specified wallet address has reward splits,
15
+ * along with their calculated weekly rewards for that wallet.
16
+ *
17
+ * ### POST `/farms/estimate-reward-score`
18
+ * Calculates the reward score for a potential marketplace farm based on its
19
+ * parameters and current region data.
20
+ *
21
+ * ### POST `/farms/estimate-reward-scores-batch`
22
+ * Calculates reward scores for multiple potential marketplace farms.
23
+ * Each farm is calculated independently as if joining the protocol by itself.
24
+ */
25
+
3
26
  import type {
4
27
  SponsoredFarm,
5
28
  SponsoredFarmsResponse,
@@ -8,6 +31,8 @@ import type {
8
31
  EstimateRewardScoreErrorResponse,
9
32
  EstimateRewardScoresBatchParams,
10
33
  EstimateRewardScoresBatchResponse,
34
+ WalletFarmsWithRewardsResponse,
35
+ FarmWithRewards,
11
36
  } from "../types";
12
37
 
13
38
  function parseApiError(error: unknown): string {
@@ -45,6 +70,23 @@ export function FarmsRouter(baseUrl: string) {
45
70
  }
46
71
  };
47
72
 
73
+ const fetchWalletFarmsWithRewards = async (
74
+ walletAddress: string
75
+ ): Promise<FarmWithRewards[]> => {
76
+ try {
77
+ if (!walletAddress) {
78
+ throw new Error("Wallet address is required");
79
+ }
80
+
81
+ const data = await request<WalletFarmsWithRewardsResponse>(
82
+ `/farms/wallet/${encodeURIComponent(walletAddress)}/farms-with-rewards`
83
+ );
84
+ return data.farms ?? [];
85
+ } catch (error) {
86
+ throw new Error(parseApiError(error));
87
+ }
88
+ };
89
+
48
90
  const estimateRewardScore = async (
49
91
  params: EstimateRewardScoreParams
50
92
  ): Promise<RewardScoreResponse> => {
@@ -95,6 +137,7 @@ export function FarmsRouter(baseUrl: string) {
95
137
 
96
138
  return {
97
139
  fetchSponsoredFarms,
140
+ fetchWalletFarmsWithRewards,
98
141
  estimateRewardScore,
99
142
  estimateRewardScoresBatch,
100
143
  } as const;
@@ -539,6 +539,23 @@ export interface EstimateRewardScoresBatchResponse {
539
539
  results: BatchRewardScoreResult[];
540
540
  }
541
541
 
542
+ // ----------------------------- Wallet Farm Rewards ---------------------------
543
+ export interface UserWeeklyRewards {
544
+ protocolDepositRewards: string; // User's weekly protocol deposit rewards in the farm's payment currency
545
+ glwInflationRewards: string; // User's weekly GLW inflation rewards (18 decimals)
546
+ userGlowSplitPercent: string; // User's GLW split percentage (6 decimals)
547
+ userDepositSplitPercent: string; // User's deposit split percentage (6 decimals)
548
+ }
549
+
550
+ export interface FarmWithRewards extends SponsoredFarm {
551
+ userWeeklyRewards: UserWeeklyRewards;
552
+ }
553
+
554
+ export interface WalletFarmsWithRewardsResponse {
555
+ farms: FarmWithRewards[];
556
+ totalFarms: number;
557
+ }
558
+
542
559
  // ---------------------------------------------------------------------------
543
560
  // Barrel exports (convenience)
544
561
  // ---------------------------------------------------------------------------