"use client"; import { RateData } from "@/lib/api"; interface Props { asset: "BTC" | "ETH"; data: RateData | null; } const ASSET_EMOJI: Record = { BTC: "₿", ETH: "Ξ" }; export default function RateCard({ asset, data }: Props) { const rate = data?.lastFundingRate ?? null; const positive = rate !== null && rate >= 0; const rateColor = rate === null ? "text-slate-400" : positive ? "text-emerald-600" : "text-red-500"; const badgeColor = rate === null ? "bg-slate-100 text-slate-500" : positive ? "bg-emerald-50 text-emerald-700 border border-emerald-200" : "bg-red-50 text-red-600 border border-red-200"; const nextTime = (() => { if (!data?.nextFundingTime) return "--"; // 转北京时间(UTC+8) const ts = data.nextFundingTime; const bjt = new Date(ts + 8 * 3600 * 1000); const now = new Date(Date.now() + 8 * 3600 * 1000); const isToday = bjt.getUTCDate() === now.getUTCDate() && bjt.getUTCMonth() === now.getUTCMonth(); const hhmm = `${String(bjt.getUTCHours()).padStart(2,"0")}:${String(bjt.getUTCMinutes()).padStart(2,"0")}`; return isToday ? hhmm : `明天 ${hhmm}`; })(); return (
{ASSET_EMOJI[asset]} {asset}/USDT
{rate === null ? "加载中" : positive ? "正费率 收款" : "负费率 付款"}

当前资金费率

{rate === null ? "--" : `${(rate * 100).toFixed(4)}%`}

标记价格

${data ? Number(data.markPrice).toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 }) : "--"}

下次结算

{nextTime}

); }