@glowlabs-org/utils 0.2.154 → 0.2.155
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-DwbBMkUd.js → farms-router-BOXNLl3m.js} +64 -1
- package/dist/cjs/farms-router-BOXNLl3m.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/control-api/region-router.d.ts +2 -1
- package/dist/cjs/lib/control-api/wallets-router.d.ts +2 -2
- package/dist/cjs/lib/types/index.d.ts +77 -1
- package/dist/esm/browser.js +2 -2
- package/dist/esm/{farms-router-C0g4hf2Z.js → farms-router-BYpMNa_b.js} +64 -1
- package/dist/esm/farms-router-BYpMNa_b.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/control-api/region-router.d.ts +2 -1
- package/dist/esm/lib/control-api/wallets-router.d.ts +2 -2
- package/dist/esm/lib/types/index.d.ts +77 -1
- package/package.json +1 -1
- package/src/lib/control-api/farms-router.ts +33 -0
- package/src/lib/control-api/region-router.ts +29 -0
- package/src/lib/control-api/wallets-router.ts +36 -2
- package/src/lib/types/index.ts +91 -1
- package/dist/cjs/farms-router-DwbBMkUd.js.map +0 -1
- package/dist/esm/farms-router-C0g4hf2Z.js.map +0 -1
package/dist/cjs/index.js
CHANGED
|
@@ -15,7 +15,7 @@ var viem = require('viem');
|
|
|
15
15
|
var merkletreejs = require('merkletreejs');
|
|
16
16
|
var ethers = require('ethers');
|
|
17
17
|
var Decimal = require('decimal.js');
|
|
18
|
-
var farmsRouter = require('./farms-router-
|
|
18
|
+
var farmsRouter = require('./farms-router-BOXNLl3m.js');
|
|
19
19
|
|
|
20
20
|
const GENESIS_TIMESTAMP = 1700352000;
|
|
21
21
|
|
|
@@ -28,11 +28,12 @@
|
|
|
28
28
|
* Calculates mining scores for existing farms that are already live on the protocol.
|
|
29
29
|
* The mining score represents the return on investment for a miner based on the farm's total GLW rewards.
|
|
30
30
|
*/
|
|
31
|
-
import type { SponsoredFarm, EstimateRewardScoreParams, RewardScoreResponse, EstimateRewardScoresBatchParams, EstimateRewardScoresBatchResponse, FarmWithRewards, FarmRewardSplit, MiningScoresBatchParams, MiningScoresBatchResponse } from "../types";
|
|
31
|
+
import type { SponsoredFarm, EstimateRewardScoreParams, RewardScoreResponse, EstimateRewardScoresBatchParams, EstimateRewardScoresBatchResponse, FarmWithRewards, FarmRewardSplit, MiningScoresBatchParams, MiningScoresBatchResponse, FarmWeeklyRewardsResponse, FarmWeeklyRewardsQuery } from "../types";
|
|
32
32
|
export declare function FarmsRouter(baseUrl: string): {
|
|
33
33
|
readonly fetchFarmRewardSplits: (farmId: string) => Promise<FarmRewardSplit[]>;
|
|
34
34
|
readonly fetchSponsoredFarms: (sponsorWallet?: string) => Promise<SponsoredFarm[]>;
|
|
35
35
|
readonly fetchWalletFarmsWithRewards: (walletAddress: string) => Promise<FarmWithRewards[]>;
|
|
36
|
+
readonly fetchFarmWeeklyRewards: (farmId: string, query?: FarmWeeklyRewardsQuery) => Promise<FarmWeeklyRewardsResponse>;
|
|
36
37
|
readonly estimateRewardScore: (params: EstimateRewardScoreParams) => Promise<RewardScoreResponse>;
|
|
37
38
|
readonly estimateRewardScoresBatch: (params: EstimateRewardScoresBatchParams) => Promise<EstimateRewardScoresBatchResponse>;
|
|
38
39
|
readonly calculateMiningScoresBatch: (params: MiningScoresBatchParams) => Promise<MiningScoresBatchResponse>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RegionWithMetadata, ActivationConfig, ActivationEvent, RegionDetails, SponsoredFarm, ActiveRegionsSummaryResponse, RecentRegionActivityResponse, InstallerApplicationPayload, InstallerApplicationResponse } from "../types";
|
|
1
|
+
import type { RegionWithMetadata, ActivationConfig, ActivationEvent, RegionDetails, SponsoredFarm, ActiveRegionsSummaryResponse, RecentRegionActivityResponse, InstallerApplicationPayload, InstallerApplicationResponse, RegionWeeklyRewardsResponse, RegionWeeklyRewardsQuery } from "../types";
|
|
2
2
|
export declare function RegionRouter(baseUrl: string): {
|
|
3
3
|
readonly fetchRegions: (params?: {
|
|
4
4
|
isActive?: boolean;
|
|
@@ -9,6 +9,7 @@ export declare function RegionRouter(baseUrl: string): {
|
|
|
9
9
|
readonly fetchRegionSolarFarms: (regionId: number) => Promise<SponsoredFarm[]>;
|
|
10
10
|
readonly fetchActiveSummary: () => Promise<ActiveRegionsSummaryResponse>;
|
|
11
11
|
readonly fetchRecentActivity: () => Promise<RecentRegionActivityResponse>;
|
|
12
|
+
readonly fetchRegionWeeklyRewards: (regionId: number, query?: RegionWeeklyRewardsQuery) => Promise<RegionWeeklyRewardsResponse>;
|
|
12
13
|
readonly getRegionByCode: (code: string) => RegionWithMetadata | null;
|
|
13
14
|
readonly applyInstallerCertification: (payload: InstallerApplicationPayload) => Promise<InstallerApplicationResponse>;
|
|
14
15
|
readonly regions: RegionWithMetadata[];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ControlWallet, WalletDetails } from "../types";
|
|
2
|
-
import type { MintedEvent, StakedEvent } from "../types";
|
|
1
|
+
import type { ControlWallet, WalletDetails, MintedEvent, StakedEvent, WalletWeeklyRewardsResponse, WeeklyRewardsQuery } from "../types";
|
|
3
2
|
export declare function WalletsRouter(baseUrl: string): {
|
|
4
3
|
readonly fetchAllWallets: () => Promise<ControlWallet[]>;
|
|
5
4
|
readonly fetchWalletByAddress: (wallet: string) => Promise<WalletDetails>;
|
|
6
5
|
readonly fetchWalletMintedEvents: (wallet: string, page?: number, limit?: number) => Promise<MintedEvent[]>;
|
|
7
6
|
readonly fetchWalletStakeEvents: (wallet: string, page?: number, limit?: number, regionId?: number) => Promise<StakedEvent[]>;
|
|
7
|
+
readonly fetchWalletWeeklyRewards: (wallet: string, query?: WeeklyRewardsQuery) => Promise<WalletWeeklyRewardsResponse>;
|
|
8
8
|
};
|
|
@@ -478,7 +478,9 @@ export interface WalletFarmInfo {
|
|
|
478
478
|
protocolDepositPaidAmount: string;
|
|
479
479
|
protocolDepositPaidCurrency: string;
|
|
480
480
|
builtEpoch: number;
|
|
481
|
-
builtAt
|
|
481
|
+
builtAt?: string;
|
|
482
|
+
glowSplitPercent6Decimals: string;
|
|
483
|
+
depositSplitPercent6Decimals: string;
|
|
482
484
|
}
|
|
483
485
|
export interface WalletDetails {
|
|
484
486
|
wallet: string;
|
|
@@ -489,6 +491,80 @@ export interface WalletDetails {
|
|
|
489
491
|
regions: WalletRegionStakeTotal[];
|
|
490
492
|
ownedFarms: WalletFarmInfo[];
|
|
491
493
|
}
|
|
494
|
+
export interface WeeklyReward {
|
|
495
|
+
weekNumber: number;
|
|
496
|
+
paymentCurrency: PaymentCurrency;
|
|
497
|
+
protocolDepositRewardsReceived: string;
|
|
498
|
+
glowInflationTotal: string;
|
|
499
|
+
}
|
|
500
|
+
export interface WeeklyRewardsSummary {
|
|
501
|
+
totalProtocolDepositRewardsReceived: string;
|
|
502
|
+
totalGlowInflation: string;
|
|
503
|
+
weeksActive: number;
|
|
504
|
+
}
|
|
505
|
+
export interface WalletWeeklyRewardsResponse {
|
|
506
|
+
wallet: string;
|
|
507
|
+
summary: WeeklyRewardsSummary;
|
|
508
|
+
rewards: WeeklyReward[];
|
|
509
|
+
}
|
|
510
|
+
export interface WeeklyRewardsQuery {
|
|
511
|
+
startWeek?: number;
|
|
512
|
+
endWeek?: number;
|
|
513
|
+
paymentCurrency?: PaymentCurrency;
|
|
514
|
+
limit?: number;
|
|
515
|
+
}
|
|
516
|
+
export interface FarmWeeklyReward {
|
|
517
|
+
weekNumber: number;
|
|
518
|
+
paymentCurrency: PaymentCurrency;
|
|
519
|
+
protocolDepositPaidTotal: string;
|
|
520
|
+
glowInflationTotal: string;
|
|
521
|
+
expectedProductionTotal: string;
|
|
522
|
+
protocolDepositRewardsDistributed: string;
|
|
523
|
+
}
|
|
524
|
+
export interface FarmWeeklyRewardsSummary {
|
|
525
|
+
totalProtocolDepositPaid: string;
|
|
526
|
+
totalGlowInflation: string;
|
|
527
|
+
totalExpectedProduction: string;
|
|
528
|
+
weeksActive: number;
|
|
529
|
+
}
|
|
530
|
+
export interface FarmWeeklyRewardsResponse {
|
|
531
|
+
farmId: string;
|
|
532
|
+
summary: FarmWeeklyRewardsSummary;
|
|
533
|
+
rewards: FarmWeeklyReward[];
|
|
534
|
+
}
|
|
535
|
+
export interface FarmWeeklyRewardsQuery {
|
|
536
|
+
startWeek?: number;
|
|
537
|
+
endWeek?: number;
|
|
538
|
+
paymentCurrency?: PaymentCurrency;
|
|
539
|
+
limit?: number;
|
|
540
|
+
}
|
|
541
|
+
export interface RegionWeeklyReward {
|
|
542
|
+
weekNumber: number;
|
|
543
|
+
paymentCurrency: PaymentCurrency;
|
|
544
|
+
protocolDepositPaidTotal: string;
|
|
545
|
+
glowInflationTotal: string;
|
|
546
|
+
expectedProductionTotal: string;
|
|
547
|
+
protocolDepositRewardsDistributed: string;
|
|
548
|
+
createdAt?: string;
|
|
549
|
+
updatedAt?: string;
|
|
550
|
+
}
|
|
551
|
+
export interface RegionWeeklyRewardsSummary {
|
|
552
|
+
totalProtocolDepositPaid: string;
|
|
553
|
+
totalGlowInflation: string;
|
|
554
|
+
totalExpectedProduction: string;
|
|
555
|
+
weeksActive: number;
|
|
556
|
+
}
|
|
557
|
+
export interface RegionWeeklyRewardsResponse {
|
|
558
|
+
regionId: number;
|
|
559
|
+
summary: RegionWeeklyRewardsSummary;
|
|
560
|
+
rewards: RegionWeeklyReward[];
|
|
561
|
+
}
|
|
562
|
+
export interface RegionWeeklyRewardsQuery {
|
|
563
|
+
startWeek?: number;
|
|
564
|
+
endWeek?: number;
|
|
565
|
+
paymentCurrency?: PaymentCurrency;
|
|
566
|
+
limit?: number;
|
|
567
|
+
}
|
|
492
568
|
export interface EstimateRewardScoreParams {
|
|
493
569
|
userId: string;
|
|
494
570
|
sponsorSplitPercent: number;
|
package/dist/esm/browser.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as TRANSFER_TYPES } from './farms-router-
|
|
2
|
-
export { C as ControlRouter, D as DECIMALS_BY_TOKEN, j as FORWARDER_ABI, F as FarmsRouter, e as ForwarderError, m as GCA_URLS, G as GLOW_WEIGHT_DECIMAL_PRECISION, H as HUB_URL, d as KICKSTARTER_STATUS, K as KickstarterRouter, M as MAX_WEIGHT, k as OFFCHAIN_FRACTIONS_ABI, O as OFF_CHAIN_PAYMENT_CURRENCIES, f as OffchainFractionsError, P as PAYMENT_CURRENCIES, b as REGIONS, R as RegionRouter, S as STAKING_DIRECTIONS, U as USDG_WEIGHT_DECIMAL_PRECISION, W as WalletsRouter, g as allRegions, c as configureSentry, i as countries, l as getAddresses, n as parseEthersError, p as parseViemError, r as regionMetadata, h as usStates, u as useForwarder, a as useOffchainFractions, o as waitForEthersTransactionWithRetry, w as waitForViemTransactionWithRetry } from './farms-router-
|
|
1
|
+
import { T as TRANSFER_TYPES } from './farms-router-BYpMNa_b.js';
|
|
2
|
+
export { C as ControlRouter, D as DECIMALS_BY_TOKEN, j as FORWARDER_ABI, F as FarmsRouter, e as ForwarderError, m as GCA_URLS, G as GLOW_WEIGHT_DECIMAL_PRECISION, H as HUB_URL, d as KICKSTARTER_STATUS, K as KickstarterRouter, M as MAX_WEIGHT, k as OFFCHAIN_FRACTIONS_ABI, O as OFF_CHAIN_PAYMENT_CURRENCIES, f as OffchainFractionsError, P as PAYMENT_CURRENCIES, b as REGIONS, R as RegionRouter, S as STAKING_DIRECTIONS, U as USDG_WEIGHT_DECIMAL_PRECISION, W as WalletsRouter, g as allRegions, c as configureSentry, i as countries, l as getAddresses, n as parseEthersError, p as parseViemError, r as regionMetadata, h as usStates, u as useForwarder, a as useOffchainFractions, o as waitForEthersTransactionWithRetry, w as waitForViemTransactionWithRetry } from './farms-router-BYpMNa_b.js';
|
|
3
3
|
import { verifyTypedData, checksumAddress } from 'viem';
|
|
4
4
|
import 'ethers';
|
|
5
5
|
|
|
@@ -3828,6 +3828,25 @@ function RegionRouter(baseUrl) {
|
|
|
3828
3828
|
throw new Error(parseApiError$3(error));
|
|
3829
3829
|
}
|
|
3830
3830
|
};
|
|
3831
|
+
const fetchRegionWeeklyRewards = async (regionId, query) => {
|
|
3832
|
+
try {
|
|
3833
|
+
const params = new URLSearchParams();
|
|
3834
|
+
if (query?.startWeek !== undefined)
|
|
3835
|
+
params.set("startWeek", query.startWeek.toString());
|
|
3836
|
+
if (query?.endWeek !== undefined)
|
|
3837
|
+
params.set("endWeek", query.endWeek.toString());
|
|
3838
|
+
if (query?.paymentCurrency)
|
|
3839
|
+
params.set("paymentCurrency", query.paymentCurrency);
|
|
3840
|
+
if (query?.limit !== undefined)
|
|
3841
|
+
params.set("limit", query.limit.toString());
|
|
3842
|
+
const queryString = params.toString();
|
|
3843
|
+
const path = `/regions/weekly-rewards/${regionId}${queryString ? `?${queryString}` : ""}`;
|
|
3844
|
+
return await request(path);
|
|
3845
|
+
}
|
|
3846
|
+
catch (error) {
|
|
3847
|
+
throw new Error(parseApiError$3(error));
|
|
3848
|
+
}
|
|
3849
|
+
};
|
|
3831
3850
|
const applyInstallerCertification = async (payload) => {
|
|
3832
3851
|
try {
|
|
3833
3852
|
return await request(`/regions/installers/apply`, {
|
|
@@ -3889,6 +3908,7 @@ function RegionRouter(baseUrl) {
|
|
|
3889
3908
|
fetchRegionSolarFarms,
|
|
3890
3909
|
fetchActiveSummary,
|
|
3891
3910
|
fetchRecentActivity,
|
|
3911
|
+
fetchRegionWeeklyRewards,
|
|
3892
3912
|
getRegionByCode,
|
|
3893
3913
|
applyInstallerCertification,
|
|
3894
3914
|
// Cached data & flags
|
|
@@ -4106,11 +4126,31 @@ function WalletsRouter(baseUrl) {
|
|
|
4106
4126
|
throw new Error(parseApiError$1(error));
|
|
4107
4127
|
}
|
|
4108
4128
|
};
|
|
4129
|
+
const fetchWalletWeeklyRewards = async (wallet, query) => {
|
|
4130
|
+
try {
|
|
4131
|
+
const params = new URLSearchParams();
|
|
4132
|
+
if (query?.startWeek !== undefined)
|
|
4133
|
+
params.set("startWeek", query.startWeek.toString());
|
|
4134
|
+
if (query?.endWeek !== undefined)
|
|
4135
|
+
params.set("endWeek", query.endWeek.toString());
|
|
4136
|
+
if (query?.paymentCurrency)
|
|
4137
|
+
params.set("paymentCurrency", query.paymentCurrency);
|
|
4138
|
+
if (query?.limit !== undefined)
|
|
4139
|
+
params.set("limit", query.limit.toString());
|
|
4140
|
+
const queryString = params.toString();
|
|
4141
|
+
const path = `/wallets/address/${encodeURIComponent(wallet)}/weekly-rewards${queryString ? `?${queryString}` : ""}`;
|
|
4142
|
+
return await request(path);
|
|
4143
|
+
}
|
|
4144
|
+
catch (error) {
|
|
4145
|
+
throw new Error(parseApiError$1(error));
|
|
4146
|
+
}
|
|
4147
|
+
};
|
|
4109
4148
|
return {
|
|
4110
4149
|
fetchAllWallets,
|
|
4111
4150
|
fetchWalletByAddress,
|
|
4112
4151
|
fetchWalletMintedEvents,
|
|
4113
4152
|
fetchWalletStakeEvents,
|
|
4153
|
+
fetchWalletWeeklyRewards,
|
|
4114
4154
|
};
|
|
4115
4155
|
}
|
|
4116
4156
|
|
|
@@ -4174,6 +4214,28 @@ function FarmsRouter(baseUrl) {
|
|
|
4174
4214
|
throw new Error(parseApiError(error));
|
|
4175
4215
|
}
|
|
4176
4216
|
};
|
|
4217
|
+
const fetchFarmWeeklyRewards = async (farmId, query) => {
|
|
4218
|
+
try {
|
|
4219
|
+
if (!farmId) {
|
|
4220
|
+
throw new Error("Farm ID is required");
|
|
4221
|
+
}
|
|
4222
|
+
const params = new URLSearchParams();
|
|
4223
|
+
if (query?.startWeek !== undefined)
|
|
4224
|
+
params.set("startWeek", query.startWeek.toString());
|
|
4225
|
+
if (query?.endWeek !== undefined)
|
|
4226
|
+
params.set("endWeek", query.endWeek.toString());
|
|
4227
|
+
if (query?.paymentCurrency)
|
|
4228
|
+
params.set("paymentCurrency", query.paymentCurrency);
|
|
4229
|
+
if (query?.limit !== undefined)
|
|
4230
|
+
params.set("limit", query.limit.toString());
|
|
4231
|
+
const queryString = params.toString();
|
|
4232
|
+
const path = `/farms/${encodeURIComponent(farmId)}/weekly-rewards${queryString ? `?${queryString}` : ""}`;
|
|
4233
|
+
return await request(path);
|
|
4234
|
+
}
|
|
4235
|
+
catch (error) {
|
|
4236
|
+
throw new Error(parseApiError(error));
|
|
4237
|
+
}
|
|
4238
|
+
};
|
|
4177
4239
|
const estimateRewardScore = async (params) => {
|
|
4178
4240
|
try {
|
|
4179
4241
|
sentryAddBreadcrumb({
|
|
@@ -4264,6 +4326,7 @@ function FarmsRouter(baseUrl) {
|
|
|
4264
4326
|
fetchFarmRewardSplits,
|
|
4265
4327
|
fetchSponsoredFarms,
|
|
4266
4328
|
fetchWalletFarmsWithRewards,
|
|
4329
|
+
fetchFarmWeeklyRewards,
|
|
4267
4330
|
estimateRewardScore,
|
|
4268
4331
|
estimateRewardScoresBatch,
|
|
4269
4332
|
calculateMiningScoresBatch,
|
|
@@ -4271,4 +4334,4 @@ function FarmsRouter(baseUrl) {
|
|
|
4271
4334
|
}
|
|
4272
4335
|
|
|
4273
4336
|
export { ControlRouter as C, DECIMALS_BY_TOKEN as D, FarmsRouter as F, GLOW_WEIGHT_DECIMAL_PRECISION as G, HUB_URL as H, KickstarterRouter as K, MAX_WEIGHT as M, OFF_CHAIN_PAYMENT_CURRENCIES as O, PAYMENT_CURRENCIES as P, RegionRouter as R, STAKING_DIRECTIONS as S, TRANSFER_TYPES as T, USDG_WEIGHT_DECIMAL_PRECISION as U, WalletsRouter as W, useOffchainFractions as a, REGIONS as b, configureSentry as c, KICKSTARTER_STATUS as d, ForwarderError as e, OffchainFractionsError as f, allRegions as g, usStates as h, countries as i, FORWARDER_ABI as j, OFFCHAIN_FRACTIONS_ABI as k, getAddresses as l, GCA_URLS as m, parseEthersError as n, waitForEthersTransactionWithRetry as o, parseViemError as p, regionMetadata as r, useForwarder as u, waitForViemTransactionWithRetry as w };
|
|
4274
|
-
//# sourceMappingURL=farms-router-
|
|
4337
|
+
//# sourceMappingURL=farms-router-BYpMNa_b.js.map
|