feat(market): add CoinGecko market data panel with cached /api/market endpoint

This commit is contained in:
2026-03-09 17:55:24 +01:00
parent 3aaa6707c5
commit 1f86a5ead4
10 changed files with 521 additions and 12 deletions

View File

@@ -45,3 +45,47 @@ export function formatTimestamp(value: string): string {
timeStyle: "short"
}).format(date);
}
export function formatUsdPrice(value: number): string {
if (!Number.isFinite(value)) {
return "-";
}
if (Math.abs(value) >= 1) {
return value.toLocaleString("en-US", {
style: "currency",
currency: "USD",
minimumFractionDigits: 2,
maximumFractionDigits: 2,
});
}
return value.toLocaleString("en-US", {
style: "currency",
currency: "USD",
minimumFractionDigits: 2,
maximumFractionDigits: 8,
});
}
export function formatUsdCompact(value: number | null): string {
if (value === null || !Number.isFinite(value)) {
return "-";
}
return value.toLocaleString("en-US", {
style: "currency",
currency: "USD",
notation: "compact",
maximumFractionDigits: 2,
});
}
export function formatSignedPercent(value: number | null): string {
if (value === null || !Number.isFinite(value)) {
return "-";
}
const sign = value > 0 ? "+" : "";
return `${sign}${value.toFixed(2)}%`;
}