@glowlabs-org/utils 0.1.1 → 0.1.3
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.js
CHANGED
@@ -18923,11 +18923,6 @@ async function createWeeklyReport({ week, gcaUrls, apiUrl, }) {
|
|
18923
18923
|
for (const sid of activeShortIds)
|
18924
18924
|
shortIdToAdjustedCredit.set(String(sid), splitBigInt);
|
18925
18925
|
}
|
18926
|
-
const farmShortIds = new Set(farms.map((f) => String(f.shortId)));
|
18927
|
-
audits.forEach((audit) => audit.activeShortIds?.forEach((sid) => {
|
18928
|
-
if (!farmShortIds.has(String(sid)))
|
18929
|
-
throw new Error(`activeShortId ${sid} from audit ${audit.id} missing in filteredFarms`);
|
18930
|
-
}));
|
18931
18926
|
let totalCreditsProduced18dp = BigInt(0);
|
18932
18927
|
for (const farm of farms) {
|
18933
18928
|
if (farm.status === "Unassigned") {
|
@@ -18937,7 +18932,7 @@ async function createWeeklyReport({ week, gcaUrls, apiUrl, }) {
|
|
18937
18932
|
throw new Error(`farm ${farm.shortId} has no rewardSplits`);
|
18938
18933
|
if (farm.carbonCreditsProduced < 0) {
|
18939
18934
|
console.log(`Farm: ${farm.shortId} has ${farm.carbonCreditsProduced} carbon credits produced`);
|
18940
|
-
throw new Error("Carbon credits produced is less than 0");
|
18935
|
+
throw new Error("Carbon credits produced is less than 0 for farm " + farm.shortId);
|
18941
18936
|
}
|
18942
18937
|
totalCreditsProduced18dp += viem.parseUnits(customToFixed(farm.carbonCreditsProduced, 18), 18);
|
18943
18938
|
const sumGlow = farm.rewardSplits.reduce((acc, r) => acc + r.glowSplitPercent, 0);
|
@@ -18949,6 +18944,8 @@ async function createWeeklyReport({ week, gcaUrls, apiUrl, }) {
|
|
18949
18944
|
throw new Error(`USDG splits ≠1 for farm ${farm.shortId}`);
|
18950
18945
|
const glowBase = viem.parseUnits(customToFixed(farm.weeklyPayment, GLOW_WEIGHT_DECIMAL_PRECISION), GLOW_WEIGHT_DECIMAL_PRECISION);
|
18951
18946
|
const adjustedCreditBigInt = shortIdToAdjustedCredit.get(String(farm.shortId)) ?? BigInt(0);
|
18947
|
+
if (adjustedCreditBigInt <= BigInt(0))
|
18948
|
+
throw new Error(`Adjusted credit is less than or equal to 0 for farm ${farm.shortId}`);
|
18952
18949
|
for (const split of farm.rewardSplits) {
|
18953
18950
|
const glowWeight = multiplyBigIntByDecimalPercentage(glowBase, GLOW_WEIGHT_DECIMAL_PRECISION, split.glowSplitPercent);
|
18954
18951
|
const usdgWeight = multiplyBigIntByDecimalPercentage(adjustedCreditBigInt, USDG_WEIGHT_DECIMAL_PRECISION, split.usdgSplitPercent);
|