@glowlabs-org/utils 0.2.96 → 0.2.97

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/esm/index.js CHANGED
@@ -13,8 +13,8 @@ import { parseUnits, formatUnits } from 'viem';
13
13
  import { MerkleTree } from 'merkletreejs';
14
14
  import { solidityPackedKeccak256, keccak256 } from 'ethers';
15
15
  import Decimal from 'decimal.js';
16
- import { H as HUB_URL, U as USDG_WEIGHT_DECIMAL_PRECISION, G as GLOW_WEIGHT_DECIMAL_PRECISION, M as MAX_WEIGHT } from './farms-router-BCnakF0d.js';
17
- export { C as ControlRouter, F as FarmsRouter, K as KickstarterRouter, R as RegionRouter, W as WalletsRouter, u as useForwarder, a as useOffchainFractions } from './farms-router-BCnakF0d.js';
16
+ import { H as HUB_URL, U as USDG_WEIGHT_DECIMAL_PRECISION, G as GLOW_WEIGHT_DECIMAL_PRECISION, M as MAX_WEIGHT } from './farms-router-Da1P3B8g.js';
17
+ export { C as ControlRouter, F as FarmsRouter, K as KickstarterRouter, R as RegionRouter, W as WalletsRouter, u as useForwarder, a as useOffchainFractions } from './farms-router-Da1P3B8g.js';
18
18
 
19
19
  const GENESIS_TIMESTAMP = 1700352000;
20
20
 
@@ -1,4 +1,5 @@
1
- import type { SponsoredFarm } from "../types";
1
+ import type { SponsoredFarm, EstimateRewardScoreParams, RewardScoreResponse } from "../types";
2
2
  export declare function FarmsRouter(baseUrl: string): {
3
3
  readonly fetchSponsoredFarms: (sponsorWallet?: string) => Promise<SponsoredFarm[]>;
4
+ readonly estimateRewardScore: (params: EstimateRewardScoreParams) => Promise<RewardScoreResponse>;
4
5
  };
@@ -383,4 +383,68 @@ export interface WalletDetails {
383
383
  ownedFarms: WalletFarmInfo[];
384
384
  purchasedFarms: WalletFarmInfo[];
385
385
  }
386
+ export interface EstimateRewardScoreParams {
387
+ userId: string;
388
+ sponsorSplitPercent: number;
389
+ protocolDepositAmount: string;
390
+ paymentCurrency: PaymentCurrency;
391
+ adjustedWeeklyCarbonCredits: number;
392
+ zone: {
393
+ id: number;
394
+ name?: string;
395
+ };
396
+ }
397
+ export interface RewardScoreResponse {
398
+ rewardScore: number;
399
+ userWeeklyPdRewards: string;
400
+ userWeeklyPdRewardsUsd: string;
401
+ userWeeklyGlwRewards: string;
402
+ userWeeklyGlwValueUsd: string;
403
+ userEstimatedWeeklyCash: string;
404
+ userProtocolDeposit: string;
405
+ userGlowSplitPercent: string;
406
+ userDepositSplitPercent: string;
407
+ glwPriceUsd6: string;
408
+ regionInfo: {
409
+ regionId: number;
410
+ regionName: string;
411
+ existingFarmCount: number;
412
+ existingTotalDepositsUsd: string;
413
+ currencyBreakdown: {
414
+ currency: string;
415
+ protocolDepositSum: string;
416
+ carbonCreditProductionSum: string;
417
+ }[];
418
+ regionGctlStaked: string;
419
+ totalGctlStakedAllRegions: string;
420
+ };
421
+ }
422
+ export interface EstimateRewardScoreApiResponse {
423
+ rewardScore: number;
424
+ userWeeklyPdRewards: string;
425
+ userWeeklyPdRewardsUsd: string;
426
+ userWeeklyGlwRewards: string;
427
+ userWeeklyGlwValueUsd: string;
428
+ userEstimatedWeeklyCash: string;
429
+ userProtocolDeposit: string;
430
+ userGlowSplitPercent: string;
431
+ userDepositSplitPercent: string;
432
+ glwPriceUsd6: string;
433
+ regionInfo: {
434
+ regionId: number;
435
+ regionName: string;
436
+ existingFarmCount: number;
437
+ existingTotalDepositsUsd: string;
438
+ currencyBreakdown: {
439
+ currency: string;
440
+ protocolDepositSum: string;
441
+ carbonCreditProductionSum: string;
442
+ }[];
443
+ regionGctlStaked: string;
444
+ totalGctlStakedAllRegions: string;
445
+ };
446
+ }
447
+ export interface EstimateRewardScoreErrorResponse {
448
+ error: string;
449
+ }
386
450
  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.96",
3
+ "version": "0.2.97",
4
4
  "description": "A library containing all typechain types and addresses relating to the glow guarded launch",
5
5
  "keywords": [],
6
6
  "author": "",
@@ -1,7 +1,13 @@
1
1
  "use strict";
2
2
 
3
- import type { SponsoredFarm } from "../types";
4
- import type { SponsoredFarmsResponse } from "../types";
3
+ import type {
4
+ SponsoredFarm,
5
+ SponsoredFarmsResponse,
6
+ EstimateRewardScoreParams,
7
+ RewardScoreResponse,
8
+ EstimateRewardScoreApiResponse,
9
+ EstimateRewardScoreErrorResponse,
10
+ } from "../types";
5
11
 
6
12
  function parseApiError(error: unknown): string {
7
13
  if (!error) return "Unknown error";
@@ -38,7 +44,36 @@ export function FarmsRouter(baseUrl: string) {
38
44
  }
39
45
  };
40
46
 
47
+ const estimateRewardScore = async (
48
+ params: EstimateRewardScoreParams
49
+ ): Promise<RewardScoreResponse> => {
50
+ try {
51
+ // First try to get the success response
52
+ const data = await request<
53
+ EstimateRewardScoreApiResponse | EstimateRewardScoreErrorResponse
54
+ >("/farms/estimate-reward-score", {
55
+ method: "POST",
56
+ headers: {
57
+ "Content-Type": "application/json",
58
+ },
59
+ body: JSON.stringify(params),
60
+ });
61
+
62
+ // Check if it's an error response
63
+ if ("error" in data) {
64
+ throw new Error(data.error);
65
+ }
66
+
67
+ // At this point, TypeScript knows it's EstimateRewardScoreApiResponse
68
+ // All fields are required in the success response based on the API spec
69
+ return data as RewardScoreResponse;
70
+ } catch (error) {
71
+ throw new Error(parseApiError(error));
72
+ }
73
+ };
74
+
41
75
  return {
42
76
  fetchSponsoredFarms,
77
+ estimateRewardScore,
43
78
  } as const;
44
79
  }
@@ -469,6 +469,75 @@ export interface WalletDetails {
469
469
  purchasedFarms: WalletFarmInfo[];
470
470
  }
471
471
 
472
+ // ----------------------------- Farms Reward Score ---------------------------
473
+ export interface EstimateRewardScoreParams {
474
+ userId: string;
475
+ sponsorSplitPercent: number;
476
+ protocolDepositAmount: string;
477
+ paymentCurrency: PaymentCurrency;
478
+ adjustedWeeklyCarbonCredits: number;
479
+ zone: {
480
+ id: number;
481
+ name?: string;
482
+ };
483
+ }
484
+
485
+ export interface RewardScoreResponse {
486
+ rewardScore: number;
487
+ userWeeklyPdRewards: string;
488
+ userWeeklyPdRewardsUsd: string;
489
+ userWeeklyGlwRewards: string;
490
+ userWeeklyGlwValueUsd: string;
491
+ userEstimatedWeeklyCash: string;
492
+ userProtocolDeposit: string;
493
+ userGlowSplitPercent: string;
494
+ userDepositSplitPercent: string;
495
+ glwPriceUsd6: string;
496
+ regionInfo: {
497
+ regionId: number;
498
+ regionName: string;
499
+ existingFarmCount: number;
500
+ existingTotalDepositsUsd: string;
501
+ currencyBreakdown: {
502
+ currency: string;
503
+ protocolDepositSum: string;
504
+ carbonCreditProductionSum: string;
505
+ }[];
506
+ regionGctlStaked: string;
507
+ totalGctlStakedAllRegions: string;
508
+ };
509
+ }
510
+
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: {
523
+ 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;
534
+ };
535
+ }
536
+
537
+ export interface EstimateRewardScoreErrorResponse {
538
+ error: string;
539
+ }
540
+
472
541
  // ---------------------------------------------------------------------------
473
542
  // Barrel exports (convenience)
474
543
  // ---------------------------------------------------------------------------