feat: add finance revenue and revenue-summary endpoints#22
Open
mukama wants to merge 10 commits intotetherto:developfrom
Open
feat: add finance revenue and revenue-summary endpoints#22mukama wants to merge 10 commits intotetherto:developfrom
mukama wants to merge 10 commits intotetherto:developfrom
Conversation
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
This was referenced Feb 20, 2026
Resolve conflicts to integrate subsidy-fees (from develop) with revenue and revenue-summary endpoints. Update getSubsidyFees to use shared validateStartEnd and processBlockData utils.
paragmore
reviewed
Feb 20, 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.
Summary
finance.utils.js(validateStartEnd, normalizeTimestampMs, processTransactions, extractCurrentPrice, processBlockData)calculateRevenueSummarySummary→calculateDetailedRevenueSummarySupersedes #15 and #16.