Skip to content

Feat: add GET /auth/finance/ebitda endpoint#5

Open
mukama wants to merge 2 commits intotetherto:developfrom
mukama:feat/finance-ebitda
Open

Feat: add GET /auth/finance/ebitda endpoint#5
mukama wants to merge 2 commits intotetherto:developfrom
mukama:feat/finance-ebitda

Conversation

@mukama
Copy link
Contributor

@mukama mukama commented Feb 12, 2026

Summary

  • Add GET /auth/finance/ebitda endpoint with daily EBITDA calculations (revenue minus costs)
  • Support period param for daily/monthly/yearly aggregation
  • Support site param for site-specific production costs
  • Aligned with API v2 spec: removed block data, fixed cost processing format

Example Queries

Monthly (default):

/auth/finance/ebitda?start=1735689600000&end=1770898000000

Daily:

/auth/finance/ebitda?start=1735689600000&end=1770898000000&period=daily

Yearly:

/auth/finance/ebitda?start=1735689600000&end=1770898000000&period=yearly

Add EBITDA API endpoint that aggregates pool transactions, power/hashrate
data, BTC prices, production costs, and block data to calculate selling
and HODL EBITDA metrics with period-based aggregation.

Includes shared infrastructure: period.utils, constants, and utility
functions required for finance endpoints.
- Remove block data RPC call and processBlockData (not in spec)
- Remove blockCount, difficulty, ebitdaMarginSelling, ebitdaMarginHodl from log
- Fix processCostsData to handle flat objects from globalDataLib with daily costs
- Replace direct globalDataLib.getGlobalData range query with getProductionCosts helper
- Add site query param to schema, cache key, and handler for site-specific costs
@mukama mukama changed the base branch from main to develop February 13, 2026 10:22
req.query.start,
req.query.end,
req.query.period,
req.query.site
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

site param is not needed as data is being fetched for a single site.

const { testModuleStructure, testHandlerFunctions, testOnRequestFunctions } = require('../helpers/routeTestHelpers')
const { createRoutesForTest } = require('../helpers/mockHelpers')

const ROUTES_PATH = '../../../workers/lib/server/routes/finance.routes.js'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include in integration test as well

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