@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.
@@ -14,7 +14,7 @@ export type CreateWeeklyReportArgs = {
14
14
  gcaUrls: string[];
15
15
  apiUrl: string;
16
16
  };
17
- export declare function createWeeklyReport({ week, gcaUrls, apiUrl, }: CreateWeeklyReportArgs): Promise<{
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;
@@ -1,3 +1,3 @@
1
1
  export * from "./lib/create-weekly-report/types/index";
2
2
  export * from "./constants/index";
3
- export { createWeeklyReport } from "./lib/create-weekly-report/index";
3
+ export { createWeeklyReport, createWeeklyReportLegacy, } from "./lib/create-weekly-report/index";
package/dist/esm/index.js CHANGED
@@ -18895,9 +18895,6 @@ async function createWeeklyReportLegacy(args) {
18895
18895
  };
18896
18896
  }
18897
18897
  async function createWeeklyReport({ week, gcaUrls, apiUrl, }) {
18898
- if (week < 72) {
18899
- return createWeeklyReportLegacy({ week, gcaUrls, apiUrl });
18900
- }
18901
18898
  const map = new Map();
18902
18899
  const [apiResponse, auditsRes] = await Promise.all([
18903
18900
  fetchFarmsForWeek(week, gcaUrls, apiUrl),
@@ -18921,11 +18918,6 @@ async function createWeeklyReport({ week, gcaUrls, apiUrl, }) {
18921
18918
  for (const sid of activeShortIds)
18922
18919
  shortIdToAdjustedCredit.set(String(sid), splitBigInt);
18923
18920
  }
18924
- const farmShortIds = new Set(farms.map((f) => String(f.shortId)));
18925
- audits.forEach((audit) => audit.activeShortIds?.forEach((sid) => {
18926
- if (!farmShortIds.has(String(sid)))
18927
- throw new Error(`activeShortId ${sid} from audit ${audit.id} missing in filteredFarms`);
18928
- }));
18929
18921
  let totalCreditsProduced18dp = BigInt(0);
18930
18922
  for (const farm of farms) {
18931
18923
  if (farm.status === "Unassigned") {
@@ -18947,6 +18939,8 @@ async function createWeeklyReport({ week, gcaUrls, apiUrl, }) {
18947
18939
  throw new Error(`USDG splits ≠1 for farm ${farm.shortId}`);
18948
18940
  const glowBase = parseUnits(customToFixed(farm.weeklyPayment, GLOW_WEIGHT_DECIMAL_PRECISION), GLOW_WEIGHT_DECIMAL_PRECISION);
18949
18941
  const adjustedCreditBigInt = shortIdToAdjustedCredit.get(String(farm.shortId)) ?? BigInt(0);
18942
+ if (adjustedCreditBigInt <= BigInt(0))
18943
+ throw new Error(`Adjusted credit is less than or equal to 0 for farm ${farm.shortId}`);
18950
18944
  for (const split of farm.rewardSplits) {
18951
18945
  const glowWeight = multiplyBigIntByDecimalPercentage(glowBase, GLOW_WEIGHT_DECIMAL_PRECISION, split.glowSplitPercent);
18952
18946
  const usdgWeight = multiplyBigIntByDecimalPercentage(adjustedCreditBigInt, USDG_WEIGHT_DECIMAL_PRECISION, split.usdgSplitPercent);
@@ -19084,5 +19078,5 @@ async function createWeeklyReport({ week, gcaUrls, apiUrl, }) {
19084
19078
  };
19085
19079
  }
19086
19080
 
19087
- export { GENESIS_TIMESTAMP, createWeeklyReport };
19081
+ export { GENESIS_TIMESTAMP, createWeeklyReport, createWeeklyReportLegacy };
19088
19082
  //# sourceMappingURL=index.js.map