Skip to content

Comments

feat: add finance revenue and revenue-summary endpoints#22

Open
mukama wants to merge 10 commits intotetherto:developfrom
mukama:feat/finance-endpoints
Open

feat: add finance revenue and revenue-summary endpoints#22
mukama wants to merge 10 commits intotetherto:developfrom
mukama:feat/finance-endpoints

Conversation

@mukama
Copy link
Contributor

@mukama mukama commented Feb 20, 2026

Summary

  • Adds GET /auth/finance/revenue — per-pool transaction revenue with fees breakdown
  • Adds GET /auth/finance/revenue-summary — comprehensive revenue dashboard with EBITDA, costs, hashrate, block data, curtailment, and power utilization
  • Extracts shared utilities into finance.utils.js (validateStartEnd, normalizeTimestampMs, processTransactions, extractCurrentPrice, processBlockData)
  • Consolidates 3 near-identical transaction processing functions into one
  • Fixes bugs: missing timestamp normalization in EBITDA transactions, incorrect BTC_SATS division
  • Renames calculateRevenueSummarySummarycalculateDetailedRevenueSummary

Supersedes #15 and #16.

Port pool transaction revenue data from legacy dashboard to API v2.
Separates revenue from pool fees, supporting both F2Pool (changed_balance
+ tx_fee) and Ocean (satoshis_net_earned + fees_colected_satoshis) formats.
Aggregates by period with optional pool filter.
Most impactful endpoint — replaces 9 API calls + ~1500 LOC of frontend
processing. Merges transaction data, BTC prices, costs, power, hashrate,
block data, and electricity data into comprehensive daily rows with EBITDA,
production cost, hash revenue, curtailment, and power utilization metrics.
- Create finance.utils.js with shared utilities:
  - validateStartEnd: replaces duplicated validation in every handler
  - normalizeTimestampMs: moved from finance.handlers.js
  - processTransactions: consolidates processTransactionData and
    processEbitdaTransactions (fixes missing normalizeTimestampMs and
    incorrect BTC_SATS division bugs), supports trackFees option
  - extractCurrentPrice: merges flat and nested EBITDA price formats
  - processBlockData: extracted for reuse across revenue endpoints
- Refactor finance.handlers.js to use shared utils
- Add comprehensive unit tests for all utils (24 tests)
- Update handler tests to remove tests for deleted functions
- Merge refactor/finance-utils branch
- Replace processRevenueTransactions with processTransactions({trackFees: true})
- Replace inline validation with validateStartEnd in getRevenue
- Remove duplicate processRevenueTransactions tests (covered by utils)
Merge refactor/finance-utils and apply revenue-summary specific changes:
- Replace processRevenueTransactions with processTransactions({trackFees: true})
- Remove local processBlockData (now imported from finance.utils)
- Rename calculateRevenueSummarySummary to calculateDetailedRevenueSummary
- Replace inline validation with validateStartEnd
- Replace extractEbitdaCurrentPrice with extractCurrentPrice
Merge feat/finance-revenue (PR tetherto#15) and feat/finance-revenue-summary (PR tetherto#16)
into a single branch with shared finance utilities refactor:
- GET /auth/finance/revenue - per-pool transaction revenue with fees
- GET /auth/finance/revenue-summary - comprehensive revenue dashboard
- Shared finance.utils.js with consolidated transaction processing
- Fixes duplicate code, normalizes timestamp handling, renames ambiguous functions
Resolve conflicts to integrate subsidy-fees (from develop) with
revenue and revenue-summary endpoints. Update getSubsidyFees to
use shared validateStartEnd and processBlockData utils.
@mukama mukama requested a review from paragmore February 20, 2026 11:13
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.

2 participants