@glowlabs-org/utils 0.2.106 → 0.2.108

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
  };
@@ -247,7 +247,6 @@ export interface SponsoredFarm {
247
247
  protocolDepositUSDC6Decimals: string;
248
248
  protocolDepositPaidAmount: string;
249
249
  protocolDepositPaidCurrency: string;
250
- protocolDepositPayerWallet: string | null;
251
250
  builtEpoch: number;
252
251
  builtAt: string;
253
252
  afterInstallPictures: {
@@ -372,7 +371,6 @@ export interface WalletFarmInfo {
372
371
  adjustedWeeklyCarbonCredits: string;
373
372
  protocolDepositPaidAmount: string;
374
373
  protocolDepositPaidCurrency: string;
375
- protocolDepositPayerWallet: string | null;
376
374
  builtEpoch: number;
377
375
  builtAt: string;
378
376
  }
@@ -440,4 +438,17 @@ export type BatchRewardScoreResult = BatchRewardScoreSuccessResult | BatchReward
440
438
  export interface EstimateRewardScoresBatchResponse {
441
439
  results: BatchRewardScoreResult[];
442
440
  }
441
+ export interface UserWeeklyRewards {
442
+ protocolDepositRewards: string;
443
+ glwInflationRewards: string;
444
+ userGlowSplitPercent: string;
445
+ userDepositSplitPercent: string;
446
+ }
447
+ export interface FarmWithRewards extends SponsoredFarm {
448
+ userWeeklyRewards: UserWeeklyRewards;
449
+ }
450
+ export interface WalletFarmsWithRewardsResponse {
451
+ farms: FarmWithRewards[];
452
+ totalFarms: number;
453
+ }
443
454
  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.106",
3
+ "version": "0.2.108",
4
4
  "description": "A library containing all typechain types and addresses relating to the glow guarded launch",
5
5
  "keywords": [],
6
6
  "author": "",
@@ -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;
@@ -307,7 +307,7 @@ export interface SponsoredFarm {
307
307
  protocolDepositUSDC6Decimals: string;
308
308
  protocolDepositPaidAmount: string;
309
309
  protocolDepositPaidCurrency: string;
310
- protocolDepositPayerWallet: string | null;
310
+
311
311
  builtEpoch: number;
312
312
  builtAt: string;
313
313
  afterInstallPictures: {
@@ -457,7 +457,7 @@ export interface WalletFarmInfo {
457
457
  adjustedWeeklyCarbonCredits: string;
458
458
  protocolDepositPaidAmount: string;
459
459
  protocolDepositPaidCurrency: string;
460
- protocolDepositPayerWallet: string | null;
460
+
461
461
  builtEpoch: number;
462
462
  builtAt: string; // ISO 8601
463
463
  }
@@ -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
  // ---------------------------------------------------------------------------