@glowlabs-org/utils 0.2.151 → 0.2.152

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-Cpy_o4_u.js';
17
- export { C as ControlRouter, F as FarmsRouter, d as KICKSTARTER_STATUS, K as KickstarterRouter, O as OFF_CHAIN_PAYMENT_CURRENCIES, P as PAYMENT_CURRENCIES, b as REGIONS, R as RegionRouter, S as STAKING_DIRECTIONS, T as TRANSFER_TYPES, W as WalletsRouter, c as configureSentry, u as useForwarder, a as useOffchainFractions } from './farms-router-Cpy_o4_u.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-C0g4hf2Z.js';
17
+ export { C as ControlRouter, F as FarmsRouter, d as KICKSTARTER_STATUS, K as KickstarterRouter, O as OFF_CHAIN_PAYMENT_CURRENCIES, P as PAYMENT_CURRENCIES, b as REGIONS, R as RegionRouter, S as STAKING_DIRECTIONS, T as TRANSFER_TYPES, W as WalletsRouter, c as configureSentry, u as useForwarder, a as useOffchainFractions } from './farms-router-C0g4hf2Z.js';
18
18
 
19
19
  const GENESIS_TIMESTAMP = 1700352000;
20
20
 
@@ -1,4 +1,4 @@
1
- import type { RegionWithMetadata, ActivationConfig, ActivationEvent, RegionDetails, SponsoredFarm, ActiveRegionsSummaryResponse, InstallerApplicationPayload, InstallerApplicationResponse } from "../types";
1
+ import type { RegionWithMetadata, ActivationConfig, ActivationEvent, RegionDetails, SponsoredFarm, ActiveRegionsSummaryResponse, RecentRegionActivityResponse, InstallerApplicationPayload, InstallerApplicationResponse } from "../types";
2
2
  export declare function RegionRouter(baseUrl: string): {
3
3
  readonly fetchRegions: (params?: {
4
4
  isActive?: boolean;
@@ -8,6 +8,7 @@ export declare function RegionRouter(baseUrl: string): {
8
8
  readonly fetchRegionByIdOrSlug: (idOrSlug: string) => Promise<RegionDetails>;
9
9
  readonly fetchRegionSolarFarms: (regionId: number) => Promise<SponsoredFarm[]>;
10
10
  readonly fetchActiveSummary: () => Promise<ActiveRegionsSummaryResponse>;
11
+ readonly fetchRecentActivity: () => Promise<RecentRegionActivityResponse>;
11
12
  readonly getRegionByCode: (code: string) => RegionWithMetadata | null;
12
13
  readonly applyInstallerCertification: (payload: InstallerApplicationPayload) => Promise<InstallerApplicationResponse>;
13
14
  readonly regions: RegionWithMetadata[];
@@ -311,14 +311,17 @@ export interface RegionDetails extends RegionWithMetadata {
311
311
  carbonCreditsIssued: number;
312
312
  carbonCreditsPerWeek: number;
313
313
  }
314
- export interface ActiveRegionSnapshot {
314
+ export interface ActiveRegionDataPoint {
315
315
  epoch: number;
316
- totals: {
317
- gctlStaked: string;
318
- pendingUnstake: string;
319
- pendingRestakeOut: string;
320
- pendingRestakeIn: string;
321
- };
316
+ timestamp: number;
317
+ gctlStaked: string;
318
+ pendingUnstake: string;
319
+ pendingRestakeOut: string;
320
+ pendingRestakeIn: string;
321
+ netPending: string;
322
+ eventCount: number;
323
+ firstEventTimestamp?: number;
324
+ lastEventTimestamp?: number;
322
325
  }
323
326
  export interface ActiveRegionSummary {
324
327
  id: number;
@@ -326,20 +329,47 @@ export interface ActiveRegionSummary {
326
329
  code: string;
327
330
  slug: string;
328
331
  isUs: boolean;
329
- gctlStaked: string;
332
+ currentGctlStaked: string;
330
333
  glwRewardPerWeek: string;
331
334
  rewardShare: string;
332
- pendingUnstake: string;
333
- pendingRestakeOut: string;
334
- pendingRestakeIn: string;
335
- snapshots: ActiveRegionSnapshot[];
335
+ data: ActiveRegionDataPoint[];
336
336
  }
337
337
  export interface ActiveRegionsSummaryResponse {
338
+ metadata: {
339
+ epochs: number[];
340
+ epochTimestamps: {
341
+ [epoch: string]: number;
342
+ };
343
+ currentEpoch: number;
344
+ };
338
345
  total: {
339
346
  totalGctlStaked: string;
340
347
  totalGlwRewards: string;
341
348
  };
342
349
  regions: ActiveRegionSummary[];
350
+ aggregate: {
351
+ epochs: number[];
352
+ timestamps: number[];
353
+ totalGctlStaked: string[];
354
+ totalPendingUnstake: string[];
355
+ totalNetPending: string[];
356
+ };
357
+ }
358
+ export interface RegionActivityPeriod {
359
+ stakes: number;
360
+ unstakes: number;
361
+ restakes: number;
362
+ immediateUnstakes: number;
363
+ netChange: string;
364
+ }
365
+ export interface RegionActivity {
366
+ regionId: number;
367
+ regionName: string;
368
+ last24h: RegionActivityPeriod;
369
+ last7d: RegionActivityPeriod;
370
+ }
371
+ export interface RecentRegionActivityResponse {
372
+ activity: RegionActivity[];
343
373
  }
344
374
  export interface InstallerApplicationPayload {
345
375
  wallet: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glowlabs-org/utils",
3
- "version": "0.2.151",
3
+ "version": "0.2.152",
4
4
  "description": "A library containing all typechain types and addresses relating to the glow guarded launch",
5
5
  "keywords": [],
6
6
  "author": "",
@@ -1,58 +1,5 @@
1
1
  "use strict";
2
2
 
3
- /**
4
- * # Regions Router
5
- *
6
- * This router wraps the Control API endpoints that power Kickstarter-style
7
- * activation across geographic regions. It surfaces read APIs for activation
8
- * progress plus the installer certification mutation.
9
- *
10
- * ## Components
11
- * - **router.ts**: exports the `RegionRouter` factory with helpers for each
12
- * endpoint:
13
- * - `GET /regions/all` – list regions with activation progress (stake, farms,
14
- * installers). Accepts optional `?isActive=true|false` filter.
15
- * - `GET /regions/:idOrSlug` – return region VCR view.
16
- * - `GET /regions/active/summary` – aggregate GLW/week distribution, pending
17
- * restakes, and recent epoch snapshots for active regions.
18
- * - `GET /regions/solar-farms/:regionId` – list sponsored farms for a region.
19
- * - `POST /regions/installers/apply` – certify an installer via signature.
20
- * - `GET /regions/activation-events` – activation-event timeline, optional
21
- * `regionId` filter.
22
- * - `GET /regions/activation-config` – static activation thresholds and
23
- * campaign duration for a region code.
24
- * - **getters.ts**: shared data aggregation utilities used by the router
25
- * implementation.
26
- * - **db/schema.ts**: Drizzle schema for `regions`, `region_kickstarters`,
27
- * `solar_farms`, `certified_installers`, and `region_activation_events`.
28
- * - **constants**: activation thresholds imported from `@src/constants`:
29
- * ```ts
30
- * import {
31
- * MIN_FARMS,
32
- * US_STAKE_THRESHOLD,
33
- * NON_US_STAKE_THRESHOLD,
34
- * CAMPAIGN_DURATION_DAYS,
35
- * MIN_INSTALLERS,
36
- * US_STAKED_TRESHOLD_BIGINT,
37
- * NON_US_STAKED_TRESHOLD_BIGINT,
38
- * } from "@src/constants";
39
- * ```
40
- * - Region metadata: `regionMetadata` from `@glowlabs-org/utils/browser` feeds
41
- * `/activation-config` responses.
42
- * - Kickstarter endpoints live in `KickstarterRouter`.
43
- *
44
- * ## Activation Criteria
45
- * A region activates when it satisfies all of:
46
- * 1. Stake threshold met (≥ 20 000 GCTL for US, ≥ 200 000 GCTL otherwise).
47
- * 2. At least 10 solar farms registered.
48
- * 3. At least 1 certified installer.
49
- *
50
- * ## API Responses
51
- * All numeric stake values are returned as strings (atomic units) to avoid
52
- * precision loss. Dates are ISO 8601 strings. The router exposes typed helpers
53
- * for the full dataset described above.
54
- */
55
-
56
3
  import { generateSlug } from "src/utils/generate-slug";
57
4
  import { regionMetadata } from "../region-metadata";
58
5
  import type {
@@ -62,6 +9,7 @@ import type {
62
9
  RegionDetails,
63
10
  SponsoredFarm,
64
11
  ActiveRegionsSummaryResponse,
12
+ RecentRegionActivityResponse,
65
13
  InstallerApplicationPayload,
66
14
  InstallerApplicationResponse,
67
15
  } from "../types";
@@ -186,6 +134,17 @@ export function RegionRouter(baseUrl: string) {
186
134
  }
187
135
  };
188
136
 
137
+ const fetchRecentActivity =
138
+ async (): Promise<RecentRegionActivityResponse> => {
139
+ try {
140
+ return await request<RecentRegionActivityResponse>(
141
+ `/regions/active/recent-activity`
142
+ );
143
+ } catch (error) {
144
+ throw new Error(parseApiError(error));
145
+ }
146
+ };
147
+
189
148
  const applyInstallerCertification = async (
190
149
  payload: InstallerApplicationPayload
191
150
  ): Promise<InstallerApplicationResponse> => {
@@ -258,6 +217,7 @@ export function RegionRouter(baseUrl: string) {
258
217
  fetchRegionByIdOrSlug,
259
218
  fetchRegionSolarFarms,
260
219
  fetchActiveSummary,
220
+ fetchRecentActivity,
261
221
  getRegionByCode,
262
222
  applyInstallerCertification,
263
223
 
@@ -377,14 +377,17 @@ export interface RegionDetails extends RegionWithMetadata {
377
377
  carbonCreditsPerWeek: number;
378
378
  }
379
379
 
380
- export interface ActiveRegionSnapshot {
380
+ export interface ActiveRegionDataPoint {
381
381
  epoch: number;
382
- totals: {
383
- gctlStaked: string;
384
- pendingUnstake: string;
385
- pendingRestakeOut: string;
386
- pendingRestakeIn: string;
387
- };
382
+ timestamp: number;
383
+ gctlStaked: string;
384
+ pendingUnstake: string;
385
+ pendingRestakeOut: string;
386
+ pendingRestakeIn: string;
387
+ netPending: string;
388
+ eventCount: number;
389
+ firstEventTimestamp?: number;
390
+ lastEventTimestamp?: number;
388
391
  }
389
392
 
390
393
  export interface ActiveRegionSummary {
@@ -393,21 +396,49 @@ export interface ActiveRegionSummary {
393
396
  code: string;
394
397
  slug: string;
395
398
  isUs: boolean;
396
- gctlStaked: string;
399
+ currentGctlStaked: string;
397
400
  glwRewardPerWeek: string;
398
401
  rewardShare: string;
399
- pendingUnstake: string;
400
- pendingRestakeOut: string;
401
- pendingRestakeIn: string;
402
- snapshots: ActiveRegionSnapshot[];
402
+ data: ActiveRegionDataPoint[];
403
403
  }
404
404
 
405
405
  export interface ActiveRegionsSummaryResponse {
406
+ metadata: {
407
+ epochs: number[];
408
+ epochTimestamps: { [epoch: string]: number };
409
+ currentEpoch: number;
410
+ };
406
411
  total: {
407
412
  totalGctlStaked: string;
408
413
  totalGlwRewards: string;
409
414
  };
410
415
  regions: ActiveRegionSummary[];
416
+ aggregate: {
417
+ epochs: number[];
418
+ timestamps: number[];
419
+ totalGctlStaked: string[];
420
+ totalPendingUnstake: string[];
421
+ totalNetPending: string[];
422
+ };
423
+ }
424
+
425
+ export interface RegionActivityPeriod {
426
+ stakes: number;
427
+ unstakes: number;
428
+ restakes: number;
429
+ immediateUnstakes: number;
430
+ netChange: string; // atomic units (can be negative)
431
+ }
432
+
433
+ export interface RegionActivity {
434
+ regionId: number;
435
+ regionName: string;
436
+ last24h: RegionActivityPeriod;
437
+ last7d: RegionActivityPeriod;
438
+ }
439
+
440
+ export interface RecentRegionActivityResponse {
441
+ activity: RegionActivity[];
411
442
  }
412
443
 
413
444
  export interface InstallerApplicationPayload {