Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/components/live/live-number.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,19 @@ export function LiveNumber({
value,
format,
monotonic = false,
maxValue,
className,
}: {
value: number | undefined;
format: (n: number | undefined) => string;
monotonic?: boolean;
/** Defensive ceiling. A single garbage push from the upstream relay
* (observed: onchain vol24h briefly returning 8e79) would otherwise
* latch into `lastRef` and, under `monotonic`, stick as the
* displayed value forever because every subsequent healthy push is
* smaller and gets rejected as a "down tick". Reject any incoming
* value above the ceiling before it can pollute the snapshot pair. */
maxValue?: number;
className?: string;
}) {
const [display, setDisplay] = useState<number | undefined>(value);
Expand All @@ -42,6 +50,16 @@ export function LiveNumber({

useEffect(() => {
if (value == null || !Number.isFinite(value)) return;
if (maxValue != null && value > maxValue) {
// Also flush a poisoned lastRef so a healthy value can seed the
// pair on the next push instead of being rejected by the
// monotonic guard against the stale garbage.
if (lastRef.current && lastRef.current.value > maxValue) {
lastRef.current = null;
prevRef.current = null;
}
return;
}
const now = performance.now();
// Only advance the snapshot pair on DISTINCT values. Consecutive pushes
// with the same value (relay 1 Hz tick × lighthouse 1-5 min poll) would
Expand All @@ -53,7 +71,7 @@ export function LiveNumber({
if (lastRef.current.value === value) return;
prevRef.current = lastRef.current;
lastRef.current = { value, ts: now };
}, [value]);
}, [value, maxValue]);

useEffect(() => {
let cancelled = false;
Expand Down
11 changes: 11 additions & 0 deletions src/components/live/ticker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,30 @@ export const LiveTicker = memo(function LiveTicker({
</span>
</div>

{/* maxValue: defensive ceilings against upstream corruption. Real
world highs (crypto ATH): vol24h ~$500B, trades24h ~50M,
mcap ~$4T. Ceilings sit 20-100x above those to leave room for
plausible growth while catching the 10^20+ garbage tick that
latched the ticker at 8e79 on the home page on 2026-07-17. */}
<Stat
label="Onchain volume · 24h"
value={stats?.vol24h}
format={fmtMoneyFull}
monotonic
maxValue={1e13}
/>
<Stat
label="Onchain txs · 24h"
value={stats?.trades24h}
format={fmtCountFull}
monotonic
maxValue={1e10}
/>
<Stat
label="Total crypto mcap"
value={stats?.mcap}
format={fmtMoneyFull}
maxValue={1e14}
/>

<button
Expand All @@ -90,11 +98,13 @@ function Stat({
value,
format,
monotonic,
maxValue,
}: {
label: string;
value: number | undefined;
format: (n: number | undefined) => string;
monotonic?: boolean;
maxValue?: number;
}) {
return (
<div className="flex items-baseline gap-2 min-w-0">
Expand All @@ -103,6 +113,7 @@ function Stat({
value={value}
format={format}
monotonic={monotonic}
maxValue={maxValue}
className="font-sans tabular text-[12px] text-ink-soft"
/>
</div>
Expand Down
Loading