Fix: read what the workers actually write on the finance data path - #202
Merged
paragmore merged 2 commits intoAug 27, 2026
Merged
Conversation
…the record Ocean stamps pool earnings with an ISO-8601 string, which normalizeTimestampMs returned unchanged, turning into NaN in getStartOfDay so every earning was silently skipped. Numeric strings failed the same way. ISO strings carry no timezone designator and are treated as UTC rather than host-local, and processDailyRevenueBtc no longer coerces with Number() before normalizing.
Three defects on the same finance data contract: - getEbitda and getHashRevenue asked the mempool worker for key 'prices', which is the one field its fallback reply destructures away. Both fell back to the current spot price, valuing every historical day at today's rate. The other four call sites already used HISTORICAL_PRICES. - aggregateByPeriod grouped and stamped monthly/yearly buckets with local-time getters over UTC day timestamps, so west of UTC a day's revenue could land in the previous month. The weekly branch was already UTC. - The production-cost month key was derived with local getters at four sites, pricing a UTC first-of-month against the previous month's costs and LCOE. Also adds powerW, energyRevenuePerMWh and allInCostPerMWh to the energy-balance meanKeys, so rate columns are averaged over a period rather than summed, as revenue-summary already does.
tekwani
approved these changes
Aug 27, 2026
paragmore
approved these changes
Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes four defects where the finance handlers disagreed with what the workers actually write, each of which failed silently rather than erroring.
Ocean revenue was being dropped entirely. Ocean stamps pool earnings with an ISO-8601 string (
"2026-05-28T16:46:30");normalizeTimestampMsreturned it unchanged,getStartOfDayturned it intoNaN, and theif (!ts) continueguard skipped every record. Replaying the live dev-moria minerpool payload throughprocessTransactions:Numeric strings failed the same way, ISO strings are now pinned to UTC rather than read as host-local, and
processDailyRevenueBtcno longer coerces withNumber()before normalizing.getEbitdaandgetHashRevenueasked the mempool worker for key'prices'— the one field its fallback reply destructures away (const { prices, ...apiData } = this.mempoolData). Both silently fell back to the current spot price, valuing every historical day at today's rate on/auth/finance/ebitdaand/auth/finance/hash-revenue. The other four call sites already usedHISTORICAL_PRICES.Monthly and yearly buckets were grouped in host-local time over UTC day timestamps, so west of UTC a day's revenue could land in the previous month. The weekly branch was already UTC. Same fix for the production-cost month key, duplicated at four sites, which priced a UTC first-of-month against the previous month's costs and pinned LCOE.
energy-balancemeanKeysomittedpowerW,energyRevenuePerMWhandallInCostPerMWh, so a monthly bucket reported 62 MW and 2 MW for the same site in one object.revenue-summaryalready lists these.Note:
npm run test:unithas a pre-existing failure ondevelop(getEbitda - a monthly LCOE override only moves its own month) whose unhandled rejection aborts the run; confirmed present before these changes, unrelated to them.finance.utilsandperiod.utilssuites are green, andfinance.handlerspasses the same 85 assertions asdevelopup to that abort.