Skip to content

feat(market-chart): overlay crown rate as a stepwise market-rate line - #117

Closed
anderdc wants to merge 4 commits into
testfrom
feat/crown-rate-history-overlay
Closed

feat(market-chart): overlay crown rate as a stepwise market-rate line#117
anderdc wants to merge 4 commits into
testfrom
feat/crown-rate-history-overlay

Conversation

@anderdc

@anderdc anderdc commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

What

Replace the flat current-crown markLine on the dashboard MarketRateChart with a piecewise-constant (step:'end') crown rate-history line per direction — the best executable "market rate" moving over time behind the executed-swap scatter + EMA, instead of one horizontal line at the current level.

Why

The only crown representation on this chart was a horizontal line at the current rate, so you couldn't see how the market rate moved. A step line is the natural shape: the crown holds flat between handoffs and jumps when a new miner/rate takes over.

How

  • Fetches /crown/rate-history for both directions via useCrownRateHistory (fixed hook count; picked per shown direction). Window derived from the shown fills' block span + ~1h forward headroom.
  • Renders a step:'end' line per direction (z:2, dashed) under the EMA + scatter as a backdrop. Clipped to the fills' window on the left so older crown history doesn't stretch the axis; right edge extends to the live tip.
  • Crown rates feed the shared robustYRange (soft / must-show) so the line stays on-axis. Single-direction live crown value moves to the count line above the chart.

Live tip is opt-in (keeps the miner dashboard clean)

  • useCrownRateHistory gains a liveTip?: boolean. Only this informational dashboard passes liveTip:true to stitch the ~12s-fresh current_crown_holders tip onto the end.
  • The miner detail CrownRateChart is left untouched — it omits liveTip, so it keeps its clean per-block settled ledger (no diagonal bridge from the last flush out to a live tip) and its query key / caching are unchanged.

Depends on

  • das-allways#39 — adds the liveTip param. Without it the dashboard line just ends at the last flush (~1h stale) but still renders.

Note

For the same direction the live crown (~310τ) sits well below the fill EMA (~501τ) in current data — flagged in das-allways#39 as a likely rate-convention mismatch to investigate separately. The y-range includes the crown line so both stay visible.

Test

tsc -b + vite build + eslint clean.

anderdc and others added 4 commits June 9, 2026 14:23
Replace the flat current-crown markLine on the dashboard MarketRateChart
with a piecewise-constant (step:'end') crown rate-history line per
direction, fed by /crown/rate-history. It shows the best executable rate
(the "market rate") over time instead of only the current level, and
reaches the live tip the backend now stitches onto rate-history.

The line is clipped to the fills' window on the left so older crown
history doesn't stretch the axis and compress the scatter, and extends the
right edge to the live tip when it leads the last fill. Crown rates feed
the shared y-range (soft, must-show) so the line stays on-axis. The
single-direction live crown value moves to the count line above the chart.
Only the informational dashboard MarketRateChart passes liveTip:true to
useCrownRateHistory; the miner CrownRateChart omits it so its per-block
ledger stays clean. The param is dropped from the request and query key
when false, so the miner chart's caching/behavior is unchanged.
The stepwise crown 'market rate' line is too noisy overlaid in the BOTH
view, so restore the old static horizontal crown reference there (dashed
line at each direction's live rate, in its accent). Single direction keeps
the stepwise line.

BOTH disables the crown rate-history fetch (enabled gated to the shown
single direction); crownHist is also zeroed for non-single at the source
so react-query's cached single-view rows can't leak into the BOTH chart's
line, y-range, or x-extent after a toggle.
@anderdc anderdc closed this Jul 8, 2026
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