FilOzone / FilOzone/filecoin-pay-explorer

feat(explorer): add monthly storage spend chart to user console

Closed
#339 0 comments 0 reactions 1 assignee Claimed by @BravoNatalie View on GitHub
Dominant language
TypeScript
Stars
3
Forks
7
Avg merge
5d 14h
Merged PRs (30d)
47

Description

## Description

The console shows what an account holds and how long it will last, but nothing about what it has cost. Users can't answer "what did my storage cost me last month", and there's no way to see whether spend is rising.

Settlement events can't answer it either. A rail settles when someone calls settle, not monthly, a rail running three months and settled once puts all three months in a single bar. That shows when money moved, not what service cost.

## Proposed solution

A stacked bar chart below the funds meters, one bar per calendar month for the last six, for the token selected in the funds overview. Each bar stacks:

- Streaming accrual — rate × epochs integrated across the month from each rail's rate history, for every rail where this account is the payer.
- One-time payments — OneTimePayment.totalAmount, bucketed by createdAt.

Both are gross amounts (inclusive of network fee and operator commission), matching what actually leaves the payer's balance.

**What it shows, precisely**

This is cost incurred at the agreed rate, not cash settled. A rail accrues whether or not anyone has called settle — that is the entire point, and what makes the chart answer "what did storage cost me last month".

The consequence is that accrual is an upper bound: had the payer's balance run dry, the contract would not have settled the full amount. Labelling must therefore say cost or accrued, never paid.

The current month is partial and must be visually distinguishable, or it reads as a collapse in spend.

### Delivery

Split so the reindex is paid once, alongside the services section's own subgraph work:

1. Chart computed client-side, no subgraph change.
2. Subgraph: denormalize RateChangeQueue (+ services changes), one reindex.
3. Swap the chart's data adapter to the flat query.

### Out of scope

- Income (payee-side) — this is a spend chart.
- Per-operator breakdown — a follow-up, unblocked by step 2.

## Acceptance criteria

- [ ] Six bars, oldest to newest, for the token selected in the funds overview; the chart follows `TokenSelect` changes.
- [ ] A rail created mid-month accrues only from its creation.
- [ ] A terminated rail stops accruing at `endEpoch` and still shows its historical months.
- [ ] A rail whose rate changed mid-month bills each segment at its own rate.
- [ ] The current month accrues only to the chain head, not to month end.
- [ ] Zero-spend months render as an empty slot, not a gap.
- [ ] An account with no rails for the token shows an empty state, not an axis with no bars.
- [ ] Accrual math is a pure, unit-tested util, independent of query shape.

## Notes

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.