@glowlabs-org/utils 0.1.2 → 0.1.4
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/index.d.ts +1 -1
- package/dist/cjs/index.js +3 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/create-weekly-report/index.d.ts +3 -2
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +3 -9
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/create-weekly-report/index.d.ts +3 -2
- package/package.json +1 -1
- package/src/index.ts +4 -1
- package/src/lib/create-weekly-report/index.ts +6 -15
@@ -14,7 +14,7 @@ export type CreateWeeklyReportArgs = {
|
|
14
14
|
gcaUrls: string[];
|
15
15
|
apiUrl: string;
|
16
16
|
};
|
17
|
-
export declare function
|
17
|
+
export declare function createWeeklyReportLegacy(args: CreateWeeklyReportArgs): Promise<{
|
18
18
|
headlineStats: {
|
19
19
|
weekNumber: number;
|
20
20
|
totalCreditsProduced: string;
|
@@ -36,7 +36,8 @@ export declare function createWeeklyReport({ week, gcaUrls, apiUrl, }: CreateWee
|
|
36
36
|
}[];
|
37
37
|
farms: import("./types").Farm[];
|
38
38
|
rawData: import("./types").GCAServerResponse;
|
39
|
-
}
|
39
|
+
}>;
|
40
|
+
export declare function createWeeklyReport({ week, gcaUrls, apiUrl, }: CreateWeeklyReportArgs): Promise<{
|
40
41
|
headlineStats: {
|
41
42
|
weekNumber: number;
|
42
43
|
totalCreditsProduced: string;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
@@ -1,3 +1,6 @@
|
|
1
1
|
export * from "./lib/create-weekly-report/types/index";
|
2
2
|
export * from "./constants/index";
|
3
|
-
export {
|
3
|
+
export {
|
4
|
+
createWeeklyReport,
|
5
|
+
createWeeklyReportLegacy,
|
6
|
+
} from "./lib/create-weekly-report/index";
|
@@ -39,7 +39,7 @@ export type CreateWeeklyReportArgs = {
|
|
39
39
|
apiUrl: string;
|
40
40
|
};
|
41
41
|
|
42
|
-
async function createWeeklyReportLegacy(args: CreateWeeklyReportArgs) {
|
42
|
+
export async function createWeeklyReportLegacy(args: CreateWeeklyReportArgs) {
|
43
43
|
const mapLegacy = new Map<string, MerkleLeafIntermediary>();
|
44
44
|
|
45
45
|
function addValueToMapLegacy(
|
@@ -372,10 +372,6 @@ export async function createWeeklyReport({
|
|
372
372
|
gcaUrls,
|
373
373
|
apiUrl,
|
374
374
|
}: CreateWeeklyReportArgs) {
|
375
|
-
if (week < 72) {
|
376
|
-
return createWeeklyReportLegacy({ week, gcaUrls, apiUrl });
|
377
|
-
}
|
378
|
-
|
379
375
|
const map = new Map<string, MerkleLeaf>();
|
380
376
|
|
381
377
|
const [apiResponse, auditsRes] = await Promise.all([
|
@@ -414,16 +410,6 @@ export async function createWeeklyReport({
|
|
414
410
|
shortIdToAdjustedCredit.set(String(sid), splitBigInt);
|
415
411
|
}
|
416
412
|
|
417
|
-
const farmShortIds = new Set(farms.map((f: any) => String(f.shortId)));
|
418
|
-
audits.forEach((audit: any) =>
|
419
|
-
audit.activeShortIds?.forEach((sid: string | number) => {
|
420
|
-
if (!farmShortIds.has(String(sid)))
|
421
|
-
throw new Error(
|
422
|
-
`activeShortId ${sid} from audit ${audit.id} missing in filteredFarms`
|
423
|
-
);
|
424
|
-
})
|
425
|
-
);
|
426
|
-
|
427
413
|
let totalCreditsProduced18dp = BigInt(0);
|
428
414
|
|
429
415
|
for (const farm of farms) {
|
@@ -470,6 +456,11 @@ export async function createWeeklyReport({
|
|
470
456
|
const adjustedCreditBigInt =
|
471
457
|
shortIdToAdjustedCredit.get(String(farm.shortId)) ?? BigInt(0);
|
472
458
|
|
459
|
+
if (adjustedCreditBigInt <= BigInt(0))
|
460
|
+
throw new Error(
|
461
|
+
`Adjusted credit is less than or equal to 0 for farm ${farm.shortId}`
|
462
|
+
);
|
463
|
+
|
473
464
|
for (const split of farm.rewardSplits) {
|
474
465
|
const glowWeight = multiplyBigIntByDecimalPercentage(
|
475
466
|
glowBase,
|