@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.
- package/dist/cjs/browser.js +1 -1
- package/dist/cjs/{farms-router-CDsqKkP6.js → farms-router-CJrriLMx.js} +18 -3
- package/dist/cjs/farms-router-CJrriLMx.js.map +1 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/lib/control-api/farms-router.d.ts +2 -1
- package/dist/cjs/lib/types/index.d.ts +20 -29
- package/dist/esm/browser.js +2 -2
- package/dist/esm/{farms-router-Da1P3B8g.js → farms-router-C1A8W28q.js} +18 -3
- package/dist/esm/farms-router-C1A8W28q.js.map +1 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/lib/control-api/farms-router.d.ts +2 -1
- package/dist/esm/lib/types/index.d.ts +20 -29
- package/package.json +1 -1
- package/src/lib/control-api/farms-router.ts +26 -4
- package/src/lib/types/index.ts +27 -29
- package/dist/cjs/farms-router-CDsqKkP6.js.map +0 -1
- package/dist/esm/farms-router-Da1P3B8g.js.map +0 -1
|
@@ -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
|
-
|
|
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
|
|
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
|
}
|
package/src/lib/types/index.ts
CHANGED
|
@@ -476,10 +476,7 @@ export interface EstimateRewardScoreParams {
|
|
|
476
476
|
protocolDepositAmount: string;
|
|
477
477
|
paymentCurrency: PaymentCurrency;
|
|
478
478
|
adjustedWeeklyCarbonCredits: number;
|
|
479
|
-
|
|
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
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
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
|
-
|
|
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
|
|
538
|
-
|
|
531
|
+
export type BatchRewardScoreResult =
|
|
532
|
+
| BatchRewardScoreSuccessResult
|
|
533
|
+
| BatchRewardScoreFailureResult;
|
|
534
|
+
|
|
535
|
+
export interface EstimateRewardScoresBatchResponse {
|
|
536
|
+
results: BatchRewardScoreResult[];
|
|
539
537
|
}
|
|
540
538
|
|
|
541
539
|
// ---------------------------------------------------------------------------
|