Skip to content

fix(stake,treasury): one definition per number across both pages - #284

Merged
sktbrd merged 1 commit into
mainfrom
fix/stake-treasury-consistency
Aug 21, 2026
Merged

fix(stake,treasury): one definition per number across both pages#284
sktbrd merged 1 commit into
mainfrom
fix/stake-treasury-consistency

Conversation

@sktbrd

@sktbrd sktbrd commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Three places where the same question got two different answers. All three shared a root cause: a number was re-derived at the point of display instead of read from the shared source.

Changes

Orbit nodes excluded Morpheus stakessrc/services/stake-graph.ts

OrbitAthlete.total meant "Morpho vault TVL" but was rendered wherever "how much is backing this rider" was meant. The headline above the orbit added morTvl separately, so the two could not agree. A rider backed purely through Morpheus rendered unlit with no figure at all (Will: $31 behind him, empty node), and zooming into him then listed the backers the overview had just denied. The mobile BackerList dropped him outright on the same total > 0 test.

OrbitAthlete now carries vaultTvl (the fee-earning Morpho balance) and morUsd, with total their sum. StakeGraph.total becomes a plain sum of a.total. No component changes were needed — the orbit, the stat line and the backer list all read the corrected field.

Treasury yield disagreed with /stakesrc/components/treasury/SponsorshipYield.tsx

The card re-derived the DAO's take as the vault performance fee alone ($0.0024) while /stake printed treasuryUsd ($0.0112), with nothing marking one as a subset of the other. It now shows the graph's own treasuryUsd — the identical field — and names both halves under it (Vault fee / MOR rewards). The per-rider table stays vault-only and its TVL column moves to vaultTvl, since the fee is the only part attributable per rider and pairing a yield with a MOR-inclusive TVL invites reading a bogus return rate off two unrelated numbers.

Morpheus payouts tagged "Splits"src/services/treasury-inflows.ts

Warehouse credits were classified from the withdrawal's own receipt. A bare withdraw() of balance credited earlier carries no split event at all — just the warehouse burn and the ERC-20 transfer — so four subnet payouts totalling ~$27 sat under the generic tag. The credit that funded them does name its split, and the amounts match exactly, so ledgerSplitForCredit scans the treasury's ERC-6909 ledger credits in the window before the withdrawal and matches on amount. Ambiguity (two mapped splits, same amount) asserts nothing.

Per request, an unattributable warehouse USDC credit then falls back to subnet — see UNATTRIBUTED_USDC_FALLBACK, which documents the cost (it is the same shape of assumption that once ran a swap-fee credit under the Morpheus name) and is one constant to delete to restore strict behaviour. ETH/WETH credits never reach it.

The Subnet Earnings KPI now calls the same warehouseSource as the inflows feed instead of keeping a second copy of the receipt-only rule — the two sit on one screen and were about to report 38.78 against 66.05.

Test plan

  • pnpm test — 159 passed, including 7 new cases for matchLedgerCredit built from the real log shape (exact match, multi-credit windows, no match, ambiguous, unmapped split, malformed log).
  • Attribution replayed against mainnet for all four affected withdrawals, using the exact filter the code builds. Every one resolves to subnet by proof — the fallback is not load-bearing for them:
    • 7.843441 USDC withdrawn at block 50182885, credited by 0xcc7e…3a4e at 50182875
    • 8.575767 @ 49799306, 0.162179 @ 49686165, 10.689136 @ 49683664
  • /api/stake-graph payload: sum(a.total) now equals the headline exactly (75.05 = 75.05); Will total=31.00, vaultTvl=0, morUsd=31.00; treasuryUsd = gnarsAccrued + gnarsMorUsd.
  • Ran pnpm dev and exercised both pages. Orbit: Will lit at $31, Yan corrected $2 → $24. Treasury: headline $0.0114 with both components; Morpheus Subnet tile 38.78 → 66.05 USDC, 4 → 8 entries; KPI card matches at 66.05 / 8 claims; the one remaining generic Splits row is the ETH one, correctly untouched.
  • pnpm exec tsc --noEmit clean; pnpm lint clean apart from one pre-existing warning in BountiesView.tsx; prettier --check passes.

Generated with Claude Code

Three places where the same question got two answers.

Orbit nodes printed vault-only TVL while the headline above them added
Morpheus stakes on top. A rider backed purely through Morpheus therefore
rendered unlit with no figure — Will had $31 behind him and an empty node —
the per-node values could not be summed to the headline, and zooming into
that rider listed the backers the overview had just denied. The mobile
BackerList dropped him entirely on the same `total > 0` test. `OrbitAthlete`
now carries `vaultTvl` and `morUsd`, with `total` their sum.

The treasury's Sponsorship yield re-derived the DAO's take as the vault fee
alone, so it read $0.0024 against /stake's $0.0112 with nothing marking one
as a subset. It now prints the graph's own `treasuryUsd` — the identical
field /stake shows — and names both halves under it. The per-rider table
stays vault-only, since the fee is the only part attributable per rider.

Warehouse credits were classified from the withdrawal's own receipt, and a
bare withdraw() of balance credited earlier carries no split event, so four
Morpheus payouts sat under the generic "Splits" tag. The credit that funded
them does name its split, and the amounts match exactly, so an amount-matched
scan of the treasury's ledger credits recovers all four. The Subnet Earnings
KPI now runs the same classifier as the tile below it rather than a second
copy of the old rule.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
gnars-shadcn Ignored Ignored Aug 21, 2026 2:02am
hackertestdao Ignored Ignored Aug 21, 2026 2:02am

@sktbrd
sktbrd merged commit 861b390 into main Aug 21, 2026
4 checks passed
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