Skip to content

fix: cost-summary propagates per-day btcPrice#64

Closed
mukama wants to merge 1 commit intotetherto:developfrom
mukama:fix/cost-summary-btc-price
Closed

fix: cost-summary propagates per-day btcPrice#64
mukama wants to merge 1 commit intotetherto:developfrom
mukama:fix/cost-summary-btc-price

Conversation

@mukama
Copy link
Copy Markdown
Contributor

@mukama mukama commented Apr 28, 2026

Summary

Fixes Bug D from the FE refactor smoke test: cost-summary returned btcPrice: 0 for every log entry, leaving ProductionCostPriceChart's overlay at 0. Two compounding bugs — wrong RPC key ('prices' returns the live mempool snapshot; the right key is 'HISTORICAL_PRICES') plus the same flat-array shape bug fixed in PR #63 (processEbitdaPrices only handled wrapper shapes). Side effect: getRevenueSummary / getHashRevenue now use real per-day prices instead of the currentBtcPrice fallback. getEbitda (line 344) still has the wrong key — flagged as a follow-up.

Asana: https://app.asana.com/1/45238840754660/project/1205537444723387/task/1214118048367154

Test plan

  • 61/61 unit tests pass; standard lint clean
  • Verified end-to-end against dev-moria.tether.to/auth/ext-data?type=mempool&key=HISTORICAL_PRICES — fixed processEbitdaPrices produces 59 distinct daily prices (range $65,204–$78,658) from the real production response. Pre-fix produces {}.
  • Smoke against dev-moria once deployed: /auth/finance/cost-summary returns non-zero btcPrice per entry; ProductionCostPriceChart overlay renders.

Two compounding bugs in getCostSummary caused btcPrice=0 for every log
entry, leaving ProductionCostPriceChart's overlay line at 0:

1. Wrong RPC key. The handler queried mempool with key: 'prices', which
   the worker doesn't recognize and so returns the live snapshot
   ({currentPrice, blockHeight, ...}). Switched to 'HISTORICAL_PRICES',
   which returns [{ts, priceUSD}, ...].

2. processEbitdaPrices couldn't parse the production shape. Same class
   as the processBlockData fix (Bug C): the mempool worker returns a flat
   per-ORK array of records, not a wrapper. Detect when entry has
   .ts/.timestamp/.time and process it as the item directly; also accept
   priceUSD (the actual upstream field name) alongside price.

The processEbitdaPrices fix incidentally makes getRevenueSummary and
getHashRevenue use real per-day prices instead of falling back to
currentBtcPrice. getEbitda still uses the wrong key: 'prices' (line 344)
and is left for a follow-up.
@mukama
Copy link
Copy Markdown
Contributor Author

mukama commented Apr 28, 2026

Consolidated into #67.

@mukama mukama closed this Apr 28, 2026
@mukama mukama deleted the fix/cost-summary-btc-price branch April 28, 2026 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant