Skip to content

feat(dashboard): price earnings history from the platform's own figure - #127

Merged
flyworker merged 1 commit into
mainfrom
feat/earnings-from-platform-ledger
Sep 4, 2026
Merged

feat(dashboard): price earnings history from the platform's own figure#127
flyworker merged 1 commit into
mainfrom
feat/earnings-from-platform-ledger

Conversation

@flyworker

Copy link
Copy Markdown
Member

Earnings over time was computed locally — this node's token counts times published per-million rates. Those rates are not the whole of how a provider's earnings are determined, so the chart was an arithmetic exercise denominated in dollars, sitting next to the platform's actual total and inviting the two to be compared.

What the platform actually offers

I probed it before designing anything. There is no earnings time series:

  • /provider/me/earnings, /earnings/history, /stats/history, /stats/daily, /history, /payouts, /settlements, /rewards → all 404
  • /provider/me/stats returns lifetime totals and ignores ?period=, ?from=/to=, ?granularity=, ?days= — every variant returns the identical total

The approach

That lifetime total is cumulative and monotonic. Recording it with each metrics snapshot and differencing consecutive samples gives what the platform says was earned in between — no local rate arithmetic at all. It also sidesteps the restart problem the local counters have, because the platform's figure never resets.

Costs one upstream call every couple of minutes at most; the stats client already caches.

Honest about what is still an estimate

  • Intervals with no recorded figure — stored before this, or sampled while the API was unreachable — keep the local estimate. Each point carries authoritative, the series carries authoritative_points, and the footer states the provenance instead of presenting both as the same number.
  • The split by model stays local. The platform reports no per-model breakdown, so the share is rescaled onto the authoritative total to fill the bar. The bar's height is the platform's number; how it is divided is this node's estimate, and the UI says exactly that.
  • A decrease contributes zero — a lifetime total going down is a correction or a payout on the platform side, not negative earnings.

Verified

9 tests, including: the ledger delta is used even when a deliberately absurd local rate would give a wildly different answer; a bucket with no platform figure does not claim to be authoritative; the rescaled model segments sum to the bar and preserve the local 3:1 ratio; a decreasing total yields zero.

8/8 packages, go vet and gofmt clean, tsc clean, rebuilt bundle, config documented.

Worth flagging

If the platform updates that figure on a settlement cycle rather than continuously, differencing will show flat stretches then jumps. That is truthful, but it changes the chart's shape — and a real time-series endpoint on the platform side would be the better long-term answer than sampling a running total.

Earnings over time was computed locally: this node's token counts multiplied by
published per-million rates. That cannot be right. The rates are not the whole
of how the platform decides what a provider is owed, so the chart was an
arithmetic exercise that happened to be denominated in dollars, sitting next to
the platform's actual total and inviting the two to be compared.

The platform exposes no earnings time series — /provider/me/stats returns
lifetime totals and ignores period, from/to, granularity and days, and the
history, payouts and settlements paths do not exist. But its lifetime total is
cumulative and monotonic, so sampling it with each metrics snapshot and
differencing consecutive samples gives what the platform says was earned in
between, with no local rate arithmetic at all. It also sidesteps the restart
problem the local counters have, since the platform's figure never resets.

Intervals with no recorded figure — stored before this, or sampled while the
API was unreachable — keep the local estimate. Each point reports which it is
and the footer states the provenance, because a bar read off the ledger and a
bar priced locally are different claims and only one reconciles with what is
paid.

The split by model stays local: the platform reports no per-model breakdown, so
the share is rescaled onto the authoritative total to fill the bar. The bar's
height is the platform's number; its division is this node's estimate, and the
UI says so.

A decrease in the lifetime total is a correction or a payout on the platform
side, so it contributes zero rather than subtracting from the window.
@flyworker
flyworker merged commit f41e91d into main Sep 4, 2026
1 check passed
@flyworker
flyworker deleted the feat/earnings-from-platform-ledger branch September 4, 2026 16:45
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