feat(market-chart): overlay crown rate as a stepwise market-rate line - #117
Closed
anderdc wants to merge 4 commits into
Closed
feat(market-chart): overlay crown rate as a stepwise market-rate line#117anderdc wants to merge 4 commits into
anderdc wants to merge 4 commits into
Conversation
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.
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.
What
Replace the flat current-crown
markLineon the dashboardMarketRateChartwith 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
/crown/rate-historyfor both directions viauseCrownRateHistory(fixed hook count; picked per shown direction). Window derived from the shown fills' block span + ~1h forward headroom.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.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)
useCrownRateHistorygains aliveTip?: boolean. Only this informational dashboard passesliveTip:trueto stitch the ~12s-freshcurrent_crown_holderstip onto the end.CrownRateChartis left untouched — it omitsliveTip, 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
liveTipparam. 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+eslintclean.