@glowlabs-org/utils 0.2.97 → 0.2.99

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.
@@ -5,8 +5,9 @@ import type {
5
5
  SponsoredFarmsResponse,
6
6
  EstimateRewardScoreParams,
7
7
  RewardScoreResponse,
8
- EstimateRewardScoreApiResponse,
9
8
  EstimateRewardScoreErrorResponse,
9
+ EstimateRewardScoresBatchParams,
10
+ EstimateRewardScoresBatchResponse,
10
11
  } from "../types";
11
12
 
12
13
  function parseApiError(error: unknown): string {
@@ -48,9 +49,8 @@ export function FarmsRouter(baseUrl: string) {
48
49
  params: EstimateRewardScoreParams
49
50
  ): Promise<RewardScoreResponse> => {
50
51
  try {
51
- // First try to get the success response
52
52
  const data = await request<
53
- EstimateRewardScoreApiResponse | EstimateRewardScoreErrorResponse
53
+ RewardScoreResponse | EstimateRewardScoreErrorResponse
54
54
  >("/farms/estimate-reward-score", {
55
55
  method: "POST",
56
56
  headers: {
@@ -64,7 +64,7 @@ export function FarmsRouter(baseUrl: string) {
64
64
  throw new Error(data.error);
65
65
  }
66
66
 
67
- // At this point, TypeScript knows it's EstimateRewardScoreApiResponse
67
+ // At this point, TypeScript knows it's RewardScoreResponse
68
68
  // All fields are required in the success response based on the API spec
69
69
  return data as RewardScoreResponse;
70
70
  } catch (error) {
@@ -72,8 +72,30 @@ export function FarmsRouter(baseUrl: string) {
72
72
  }
73
73
  };
74
74
 
75
+ const estimateRewardScoresBatch = async (
76
+ params: EstimateRewardScoresBatchParams
77
+ ): Promise<EstimateRewardScoresBatchResponse> => {
78
+ try {
79
+ const data = await request<EstimateRewardScoresBatchResponse>(
80
+ "/farms/estimate-reward-scores-batch",
81
+ {
82
+ method: "POST",
83
+ headers: {
84
+ "Content-Type": "application/json",
85
+ },
86
+ body: JSON.stringify(params),
87
+ }
88
+ );
89
+
90
+ return data;
91
+ } catch (error) {
92
+ throw new Error(parseApiError(error));
93
+ }
94
+ };
95
+
75
96
  return {
76
97
  fetchSponsoredFarms,
77
98
  estimateRewardScore,
99
+ estimateRewardScoresBatch,
78
100
  } as const;
79
101
  }
@@ -476,10 +476,7 @@ export interface EstimateRewardScoreParams {
476
476
  protocolDepositAmount: string;
477
477
  paymentCurrency: PaymentCurrency;
478
478
  adjustedWeeklyCarbonCredits: number;
479
- zone: {
480
- id: number;
481
- name?: string;
482
- };
479
+ regionId: number;
483
480
  }
484
481
 
485
482
  export interface RewardScoreResponse {
@@ -495,7 +492,6 @@ export interface RewardScoreResponse {
495
492
  glwPriceUsd6: string;
496
493
  regionInfo: {
497
494
  regionId: number;
498
- regionName: string;
499
495
  existingFarmCount: number;
500
496
  existingTotalDepositsUsd: string;
501
497
  currencyBreakdown: {
@@ -508,34 +504,36 @@ export interface RewardScoreResponse {
508
504
  };
509
505
  }
510
506
 
511
- export interface EstimateRewardScoreApiResponse {
512
- rewardScore: number;
513
- userWeeklyPdRewards: string;
514
- userWeeklyPdRewardsUsd: string;
515
- userWeeklyGlwRewards: string;
516
- userWeeklyGlwValueUsd: string;
517
- userEstimatedWeeklyCash: string;
518
- userProtocolDeposit: string;
519
- userGlowSplitPercent: string;
520
- userDepositSplitPercent: string;
521
- glwPriceUsd6: string;
522
- regionInfo: {
507
+ export interface EstimateRewardScoreErrorResponse {
508
+ error: string;
509
+ }
510
+
511
+ // ----------------------------- Farms Batch Reward Score ---------------------
512
+ export interface EstimateRewardScoresBatchParams {
513
+ farms: EstimateRewardScoreParams[];
514
+ }
515
+
516
+ export interface BatchRewardScoreSuccessResult {
517
+ success: true;
518
+ data: RewardScoreResponse;
519
+ }
520
+
521
+ export interface BatchRewardScoreFailureResult {
522
+ success: false;
523
+ error: string;
524
+ farmData: {
525
+ userId: string;
523
526
  regionId: number;
524
- regionName: string;
525
- existingFarmCount: number;
526
- existingTotalDepositsUsd: string;
527
- currencyBreakdown: {
528
- currency: string;
529
- protocolDepositSum: string;
530
- carbonCreditProductionSum: string;
531
- }[];
532
- regionGctlStaked: string;
533
- totalGctlStakedAllRegions: string;
527
+ paymentCurrency: string;
534
528
  };
535
529
  }
536
530
 
537
- export interface EstimateRewardScoreErrorResponse {
538
- error: string;
531
+ export type BatchRewardScoreResult =
532
+ | BatchRewardScoreSuccessResult
533
+ | BatchRewardScoreFailureResult;
534
+
535
+ export interface EstimateRewardScoresBatchResponse {
536
+ results: BatchRewardScoreResult[];
539
537
  }
540
538
 
541
539
  // ---------------------------------------------------------------------------