import { cn } from "~/lib/utils"; import { Zap, TrendingUp, TrendingDown, RefreshCw, ExternalLink } from "lucide-react"; import { Button } from "@/routes/ui/button"; import { ChainIcon } from "../components/shared/ChainIcon"; export interface LiveTokenPriceData { chain: string; tokenAddress: string; tokenSymbol?: string; tokenName?: string; priceUsd?: string; priceNative?: string; priceChange5m?: number; priceChange1h?: number; priceChange6h?: number; priceChange24h?: number; volume24h?: number; liquidityUsd?: number; marketCap?: number; fdv?: number; dex?: string; pairUrl?: string; error?: string; } export interface LiveTokenPriceWidgetProps { /** Live token price data */ data: LiveTokenPriceData; /** Whether data is loading */ isLoading?: boolean; /** Callback when view on DexScreener is clicked */ onViewDexScreener?: () => void; /** Additional class names */ className?: string; } const formatPrice = (price: string | undefined): string => { if (!price || price === "N/A") return "N/A"; const num = parseFloat(price); if (isNaN(num)) return price; if (num < 0.00001) return `$${num.toExponential(2)}`; if (num < 1) return `$${num.toFixed(6)}`; return `$${num.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`; }; const PriceChange = ({ value, label }: { value: number | undefined; label: string }) => { if (value === undefined || value === null) return null; const isPositive = value >= 0; return (
{label}
{isPositive ? "+" : ""}{value.toFixed(2)}%