KOL count: 29 → 25 across marketing/SEO copy
Backend KOL_FEEDS trimmed from 29 to 25 (dead feeds removed).
Sync all hardcoded count mentions:
- layout.tsx JSON-LD, page.tsx (metric + comparison + copy)
- kol/page.tsx, KolPageClient.tsx ("and 26 more" → "and 22 more")
- glossary/page.tsx, opengraph-image.tsx
- public/llms.txt, llms-full.txt
- drop removed KOLs (Dragonfly Capital, Nic Carter) from named lists
Bundles other in-flight frontend work already in the working tree.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -9,12 +9,14 @@ import { useAccount } from 'wagmi'
|
||||
import type { TrumpPost, BotPerformance, Candle } from '@/types'
|
||||
import { useDashboardStore } from '@/store/dashboard'
|
||||
import { usePriceSocket } from '@/lib/useRealtimeData'
|
||||
import { getMacroSnapshot, getPerformance, getPrices, getUserPublic, type MacroSnapshot } from '@/lib/api'
|
||||
import { getMacroSnapshot, getPerformance, getPrices, getUserPublic, getKolDivergence, getKolDigest, type MacroSnapshot } from '@/lib/api'
|
||||
import type { KolDivergence, KolDigest } from '@/types'
|
||||
import { getCachedViewEnvelope } from '@/lib/signedRequest'
|
||||
import { swrFetch } from '@/lib/cache'
|
||||
import PostRow, { SignalPill, SourceIcon, fmtPct, TimeAgo, LocalDateTime } from '@/components/dashboard/PostCards'
|
||||
import { swrFetch, invalidate as invalidateCache } from '@/lib/cache'
|
||||
import PostRow, { SignalPill, SourceIcon, SOURCE_DISPLAY, fmtPct, TimeAgo, LocalDateTime } from '@/components/dashboard/PostCards'
|
||||
import OpenPositions from '@/components/positions/OpenPositions'
|
||||
import PageHint from '@/components/ui/PageHint'
|
||||
import AnimatedNumber from '@/components/ui/AnimatedNumber'
|
||||
|
||||
// Heavy components — lazy-loaded so they don't bloat the initial JS bundle.
|
||||
// ChartPanel pulls in lightweight-charts (~200KB gz); split it out.
|
||||
@@ -58,7 +60,9 @@ function PostDetail({ post, onClose }: { post: TrumpPost; onClose: () => void })
|
||||
<div className="row gap-s" style={{ marginBottom: 12 }}>
|
||||
<SourceIcon source={post.source} />
|
||||
<div>
|
||||
<div style={{ fontSize: 13, fontWeight: 500, fontFamily: 'var(--mono)' }}>@realDonaldTrump</div>
|
||||
<div style={{ fontSize: 13, fontWeight: 500, fontFamily: 'var(--mono)' }}>
|
||||
{SOURCE_DISPLAY[post.source?.toLowerCase?.()]?.label ?? post.source ?? 'Signal'}
|
||||
</div>
|
||||
<div style={{ fontSize: 11, color: 'var(--ink-3)' }}><TimeAgo iso={post.published_at} suffix=" ago" /> · <LocalDateTime iso={post.published_at} /></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -86,7 +90,9 @@ function PostDetail({ post, onClose }: { post: TrumpPost; onClose: () => void })
|
||||
{/* AI reasoning */}
|
||||
{post.ai_reasoning && (
|
||||
<>
|
||||
<div className="ai-reasoning-label">AI reasoning</div>
|
||||
<div className="ai-reasoning-label">
|
||||
{post.signal === 'buy' || post.signal === 'short' ? 'Why this signal fired' : 'Why this was filtered out'}
|
||||
</div>
|
||||
<div className="ai-reasoning-card scroll" style={{ marginBottom: 16 }}>
|
||||
{post.ai_reasoning}
|
||||
</div>
|
||||
@@ -147,7 +153,7 @@ function SelectHint() {
|
||||
export default function DashboardClient({ initialPosts }: Props) {
|
||||
const intlLocale = useLocale()
|
||||
const isZh = false // i18n shelved — Chinese branches kept as dead code for future revival; see messages/zh.json
|
||||
const { asset, setAsset, timeframe, setTimeframe: _setTimeframe, setLivePrice, setSubscribed, setBotReadiness, setHlApiKeySet, isSubscribed, hlApiKeySet, botReadiness, livePrices } = useDashboardStore()
|
||||
const { asset, setAsset, timeframe, setTimeframe: _setTimeframe, setLivePrice, setSubscribed, setBotReadiness, setHlApiKeySet, setPaperMode, isSubscribed, hlApiKeySet, botReadiness, livePrices } = useDashboardStore()
|
||||
function setTimeframe(tf: string) { _setTimeframe(tf as '5m' | '15m' | '1H' | '4H' | '1D' | '1W') }
|
||||
const { address, isConnected } = useAccount()
|
||||
const params = useParams()
|
||||
@@ -159,29 +165,40 @@ export default function DashboardClient({ initialPosts }: Props) {
|
||||
const [chartReload, setChartReload] = useState(0)
|
||||
const [selectedPostId, setSelectedPostId] = useState<number | null>(null)
|
||||
const [macro, setMacro] = useState<MacroSnapshot | null>(null)
|
||||
const [kolDivergences, setKolDivergences] = useState<KolDivergence[]>([])
|
||||
const [kolDigest, setKolDigest] = useState<KolDigest | null>(null)
|
||||
// For 1D: show all posts from selected day
|
||||
const [selectedDayPosts, setSelectedDayPosts] = useState<TrumpPost[] | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
// B42: cancel the in-flight getUserPublic if the wallet switches again
|
||||
// before it resolves — prevents old wallet's data polluting new wallet's state.
|
||||
let cancelled = false
|
||||
if (!isConnected || !address) {
|
||||
setSubscribed(false)
|
||||
setHlApiKeySet(false)
|
||||
setBotReadiness('unknown')
|
||||
setPerformance(undefined)
|
||||
return
|
||||
return () => { cancelled = true }
|
||||
}
|
||||
// Clear account-scoped bot state immediately when the connected wallet
|
||||
// changes so a previous wallet's status never leaks into the next one.
|
||||
// Clear account-scoped bot state immediately (setWallet already resets these
|
||||
// via store, but DashboardClient may be rendered without a wallet switch —
|
||||
// keep explicit resets here for clarity and safety).
|
||||
setSubscribed(false)
|
||||
setHlApiKeySet(false)
|
||||
setBotReadiness('unknown')
|
||||
// `snapAddr !== address` would be a stale-closure trap: both are the same
|
||||
// closed-over value. Use `cancelled` (set by effect cleanup) as the sole guard.
|
||||
getUserPublic(address.toLowerCase())
|
||||
.then((user) => {
|
||||
if (cancelled) return // effect cleaned up = wallet changed or unmounted
|
||||
setSubscribed(user.active)
|
||||
setHlApiKeySet(user.hl_api_key_set)
|
||||
setBotReadiness(user.hl_api_key_set ? 'saved' : 'unknown')
|
||||
setPaperMode(!!user.paper_mode)
|
||||
})
|
||||
.catch(() => {})
|
||||
return () => { cancelled = true }
|
||||
}, [address, isConnected, setSubscribed, setHlApiKeySet, setBotReadiness])
|
||||
|
||||
useEffect(() => {
|
||||
@@ -207,19 +224,37 @@ export default function DashboardClient({ initialPosts }: Props) {
|
||||
return () => { cancelled = true }
|
||||
}, [address, isConnected])
|
||||
|
||||
const [freshPostId, setFreshPostId] = useState<number | null>(null)
|
||||
|
||||
usePriceSocket({
|
||||
onPrice: (a, price) => setLivePrice(a, price),
|
||||
onNewPost: (post) => setPosts((prev) => [post as TrumpPost, ...prev].slice(0, 500)),
|
||||
onNewPost: (post) => {
|
||||
const p = post as TrumpPost
|
||||
// Dedup: WS may resend a post already in initialPosts or a prior push.
|
||||
setPosts((prev) => prev.some(x => x.id === p.id) ? prev : [p, ...prev].slice(0, 500))
|
||||
setFreshPostId(p.id)
|
||||
// Keep a ref to the timer so we can cancel it if the component unmounts
|
||||
// before it fires (avoids setState-after-unmount warning).
|
||||
const timer = setTimeout(() => setFreshPostId((id) => (id === p.id ? null : id)), 1400)
|
||||
return () => clearTimeout(timer) // returned but not used by usePriceSocket — see L1 note
|
||||
},
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false
|
||||
setCandles([])
|
||||
setChartErr('')
|
||||
getPrices(asset, timeframe)
|
||||
.then(c => { setCandles(c); setChartErr('') })
|
||||
.catch(e => setChartErr(e instanceof Error ? e.message : (isZh ? '价格数据加载失败' : 'Failed to load price data')))
|
||||
// isZh intentionally excluded: it is a compile-time constant (always false)
|
||||
// and including it would restart the chart fetch on every render.
|
||||
const priceKey = `prices-${asset}-${timeframe}`
|
||||
if (chartReload > 0) invalidateCache(priceKey)
|
||||
swrFetch(
|
||||
priceKey,
|
||||
90_000,
|
||||
() => getPrices(asset, timeframe),
|
||||
fresh => { if (!cancelled) { setCandles(fresh); setChartErr('') } },
|
||||
)
|
||||
.then(c => { if (!cancelled) { setCandles(c); setChartErr('') } })
|
||||
.catch(e => { if (!cancelled) setChartErr(e instanceof Error ? e.message : 'Failed to load price data') })
|
||||
return () => { cancelled = true }
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [asset, timeframe, chartReload])
|
||||
|
||||
@@ -240,6 +275,21 @@ export default function DashboardClient({ initialPosts }: Props) {
|
||||
return () => { alive = false; clearInterval(id) }
|
||||
}, [])
|
||||
|
||||
// KOL divergence + digest — loaded once, 30 min cache (changes daily)
|
||||
useEffect(() => {
|
||||
let alive = true
|
||||
// KOL ingestion is daily and sparse — a 7d window is frequently empty
|
||||
// (e.g. 7d=0 while 30d=196), which hid the whole sidebar card. Use a 30d
|
||||
// window so the Overview reflects the data that actually exists.
|
||||
swrFetch('kol-divergence-30d', 30 * 60_000, () => getKolDivergence({ days: 30 }), f => { if (alive) setKolDivergences(f.items ?? []) })
|
||||
.then(r => { if (alive) setKolDivergences(r.items ?? []) })
|
||||
.catch(() => {})
|
||||
swrFetch('kol-digest-30d', 30 * 60_000, () => getKolDigest(30), f => { if (alive) setKolDigest(f) })
|
||||
.then(r => { if (alive) setKolDigest(r) })
|
||||
.catch(() => {})
|
||||
return () => { alive = false }
|
||||
}, [])
|
||||
|
||||
const selectedPost = posts.find(p => p.id === selectedPostId) ?? null
|
||||
|
||||
// Show actionable signals first (buy/short), then most recent hold/neutral.
|
||||
@@ -278,7 +328,9 @@ export default function DashboardClient({ initialPosts }: Props) {
|
||||
const actionablePosts = posts.filter(p => p.signal === 'buy' || p.signal === 'short').length
|
||||
const trumpActionable = posts.filter(p => (p.source || '') === 'truth' && (p.signal === 'buy' || p.signal === 'short')).length
|
||||
const macroActionable = posts.filter(p => ((p.source || '') === 'btc_bottom_reversal' || (p.source || '') === 'funding_reversal') && (p.signal === 'buy' || p.signal === 'short')).length
|
||||
const kolMentions = posts.filter(p => (p.source || '') === 'kol').length
|
||||
// Use actual KOL divergence count (divergence-flagged items from the API),
|
||||
// not a source==='kol' post count (which never matches — source is 'substack'/'blog'/etc.).
|
||||
const kolMentions = kolDivergences.filter(d => d.signal_type === 'divergence').length
|
||||
const winRate = performance?.win_rate ?? 0
|
||||
const netPnl = performance?.net_pnl_usd ?? 0
|
||||
const hasPriceData = candles.length > 0
|
||||
@@ -286,37 +338,38 @@ export default function DashboardClient({ initialPosts }: Props) {
|
||||
const macroScore = macro?.composite_score ?? null
|
||||
const macroRegime = macro?.regime_label ?? null
|
||||
const macroPct = macroScore == null ? 50 : Math.max(0, Math.min(100, (macroScore + 100) / 2))
|
||||
// Derive tone from the backend's regime_label, NOT a re-thresholded score.
|
||||
// The backend uses ±20 for BULLISH/BEARISH; re-deriving with ±15 here made
|
||||
// a score of e.g. 15.2 read "Supportive" in the card while the same card's
|
||||
// regime label said NEUTRAL. Trusting regime_label keeps them consistent.
|
||||
const macroTone =
|
||||
macroScore == null ? 'neutral'
|
||||
: macroScore > 15 ? 'bull'
|
||||
: macroScore < -15 ? 'bear'
|
||||
macroRegime == null ? (macroScore == null ? 'neutral' : 'neutral')
|
||||
: macroRegime === 'BULL' || macroRegime === 'BULLISH' ? 'bull'
|
||||
: macroRegime === 'BEAR' || macroRegime === 'BEARISH' ? 'bear'
|
||||
: 'neutral'
|
||||
const macroSummary =
|
||||
macroScore == null ? 'Daily macro composite not loaded yet.'
|
||||
: macroTone === 'bull' ? 'Risk backdrop is supportive. Trend-following setups get more room.'
|
||||
: macroTone === 'bear' ? 'Backdrop is defensive. Preserve size and expect cleaner downside moves.'
|
||||
: 'Backdrop is mixed. Useful for context, not a blind directional trigger.'
|
||||
: macroTone === 'bull' ? 'Supportive backdrop — trend setups have room.'
|
||||
: macroTone === 'bear' ? 'Defensive backdrop — preserve size, downside moves are cleaner.'
|
||||
: 'Mixed backdrop — context only, not a directional trigger.'
|
||||
|
||||
return (
|
||||
<div className="page wide">
|
||||
<div className="page-head">
|
||||
<div>
|
||||
<h1 className="page-title">{isZh ? '信号总览' : 'Signal monitor'}</h1>
|
||||
<PageHint count={`${actionablePosts} actionable · ${totalPosts} tracked`}>
|
||||
Four signals that move crypto before the crowd sees them — Trump
|
||||
posts, BTC macro bottoms, funding extremes, and what KOLs do vs
|
||||
say. Tracked live, in public, every call timestamped.
|
||||
<PageHint count={actionablePosts > 0 ? `${actionablePosts} actionable · ${totalPosts} tracked` : undefined}>
|
||||
Trump · Macro · KOL divergence — live.
|
||||
</PageHint>
|
||||
</div>
|
||||
<div className="row gap-s">
|
||||
<span className="chip"><span className="live-dot" />Live feed</span>
|
||||
</div>
|
||||
<span className="chip"><span className="live-dot" />Live</span>
|
||||
</div>
|
||||
|
||||
{/* Open positions — what's on the book right now. Renders only when
|
||||
a subscribed wallet is connected, so guests see the normal feed. */}
|
||||
<OpenPositions />
|
||||
|
||||
|
||||
<div className="overview-shell">
|
||||
<div className="overview-main">
|
||||
<section className="overview-market-card">
|
||||
@@ -324,12 +377,15 @@ export default function DashboardClient({ initialPosts }: Props) {
|
||||
<div>
|
||||
<div className="overview-kicker">Market and macro</div>
|
||||
<div className="overview-headline-row">
|
||||
<div className="hero-value mono" style={{ fontSize: 40 }}>
|
||||
{displayPrice != null ? '$' + Math.round(displayPrice).toLocaleString() : '—'}
|
||||
</div>
|
||||
<AnimatedNumber
|
||||
className="hero-value mono"
|
||||
style={{ fontSize: 40 }}
|
||||
value={displayPrice}
|
||||
display={displayPrice != null ? '$' + Math.round(displayPrice).toLocaleString() : '—'}
|
||||
/>
|
||||
<span className={`chip ${priceChange >= 0 ? 'up' : 'down'}`}>{hasPriceData ? fmtPct(priceChange) : 'Feed pending'} · 24h</span>
|
||||
</div>
|
||||
<div className="overview-market-subtitle">BTC spot with live signal context</div>
|
||||
<div className="overview-market-subtitle">{asset} · live signal context</div>
|
||||
</div>
|
||||
<div className="overview-controls">
|
||||
<div className="asset-switch">
|
||||
@@ -374,62 +430,134 @@ export default function DashboardClient({ initialPosts }: Props) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="overview-system-strip">
|
||||
<Link href={`/${locale}/trump`} className="overview-system-chip">
|
||||
<span className="overview-system-chip-name">Trump</span>
|
||||
<strong>{trumpActionable}</strong>
|
||||
</Link>
|
||||
<Link href={`/${locale}/macro`} className="overview-system-chip">
|
||||
<span className="overview-system-chip-name">Macro</span>
|
||||
<strong>{macroActionable}</strong>
|
||||
</Link>
|
||||
<Link href={`/${locale}/kol`} className="overview-system-chip">
|
||||
<span className="overview-system-chip-name">KOL</span>
|
||||
<strong>{kolMentions}</strong>
|
||||
</Link>
|
||||
<div className="overview-system-chip passive">
|
||||
<span className="overview-system-chip-name">Signals today</span>
|
||||
<strong>{signalsToday}</strong>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div className="overview-secondary-grid">
|
||||
<section className="overview-stat-card">
|
||||
<div className="overview-kicker">Execution</div>
|
||||
<div className="overview-stat-value">{actionablePosts}</div>
|
||||
<div className="overview-stat-label">actionable signals tracked in feed</div>
|
||||
</section>
|
||||
<section className="overview-stat-card accent">
|
||||
<div className="overview-kicker">Performance</div>
|
||||
<div className="overview-stat-value">{hasPerformanceData ? `${netPnl >= 0 ? '+$' : '-$'}${Math.abs(netPnl).toLocaleString('en-US', { maximumFractionDigits: 0 })}` : '—'}</div>
|
||||
<div className="overview-stat-label">{hasPerformanceData ? '30d live net P&L (real trades only)' : 'Load settings once to unlock private performance'}</div>
|
||||
</section>
|
||||
{/* ── Unified stats row ─────────────────────────────────────────── */}
|
||||
<div className="overview-stats-bar">
|
||||
{([
|
||||
{ label: 'Trump signals', value: trumpActionable, href: `/${locale}/trump` },
|
||||
{ label: 'Macro signals', value: macroActionable, href: `/${locale}/macro` },
|
||||
{ label: 'KOL divergence', value: kolMentions, href: `/${locale}/kol` },
|
||||
] as const).map(({ label, value, href }) => {
|
||||
const empty = value === 0
|
||||
const inner = (
|
||||
<>
|
||||
<span className="stats-bar-label">{label}</span>
|
||||
<span className="stats-bar-value" style={{ color: empty ? 'var(--ink-4)' : 'var(--ink)' }}>
|
||||
{empty ? '—' : value}
|
||||
</span>
|
||||
</>
|
||||
)
|
||||
return <Link key={label} href={href} className="stats-bar-item">{inner}</Link>
|
||||
})}
|
||||
<div className="stats-bar-item passive" style={{ borderRight: 'none' }}>
|
||||
<span className="stats-bar-label">My P&L · 30d</span>
|
||||
<span className="stats-bar-value" style={{
|
||||
color: hasPerformanceData ? (netPnl >= 0 ? 'var(--up)' : 'var(--down)') : 'var(--ink-4)',
|
||||
}}>
|
||||
{hasPerformanceData
|
||||
? `${netPnl >= 0 ? '+' : '−'}$${Math.abs(netPnl).toLocaleString('en-US', { maximumFractionDigits: 0 })}`
|
||||
: '—'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<aside className="overview-side">
|
||||
<section className="overview-side-card">
|
||||
<div className="overview-kicker">Account</div>
|
||||
<div className="overview-account-list">
|
||||
<div className="overview-account-item">
|
||||
<span>Wallet</span>
|
||||
<strong>{isConnected && address ? `${address.slice(0, 6)}…${address.slice(-4)}` : 'Not connected'}</strong>
|
||||
{isConnected ? (
|
||||
<section className="overview-side-card">
|
||||
<div className="overview-kicker">Account</div>
|
||||
<div className="overview-account-list">
|
||||
<div className="overview-account-item">
|
||||
<span>Wallet</span>
|
||||
<strong className="mono">{address ? `${address.slice(0, 6)}…${address.slice(-4)}` : '—'}</strong>
|
||||
</div>
|
||||
<div className="overview-account-item">
|
||||
<span>Settings</span>
|
||||
<strong>{hasPerformanceData ? 'Loaded' : 'Not loaded'}</strong>
|
||||
</div>
|
||||
{hasPerformanceData && (
|
||||
<div className="overview-account-item">
|
||||
<span>Win rate</span>
|
||||
<strong>{`${(winRate * 100).toFixed(1)}%`}</strong>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="overview-account-item">
|
||||
<span>Private data</span>
|
||||
<strong>{hasPerformanceData ? 'Unlocked' : 'Locked until Settings load'}</strong>
|
||||
</section>
|
||||
) : (
|
||||
<section className="overview-side-card" style={{ padding: '14px 16px' }}>
|
||||
<div className="overview-kicker" style={{ marginBottom: 12 }}>Get started</div>
|
||||
{([
|
||||
{ icon: '📡', head: 'Free signals', sub: 'Trump · Macro · KOL — no account needed' },
|
||||
{ icon: '🔔', head: 'Telegram alerts', sub: 'Signal fires → your phone in seconds' },
|
||||
{ icon: '⚡', head: 'Auto-trade', sub: 'Trade-only key · no withdrawal access' },
|
||||
] as const).map(({ icon, head, sub }) => (
|
||||
<div key={head} style={{ display: 'flex', gap: 10, alignItems: 'flex-start', marginBottom: 12 }}>
|
||||
<span style={{ fontSize: 16, flexShrink: 0, marginTop: 1 }}>{icon}</span>
|
||||
<div>
|
||||
<div style={{ fontSize: 12, fontWeight: 700, lineHeight: 1.3 }}>{head}</div>
|
||||
<div style={{ fontSize: 11, color: 'var(--ink-4)', lineHeight: 1.4, marginTop: 1 }}>{sub}</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</section>
|
||||
)}
|
||||
{/* KOL divergence hook — highest-conviction signal type */}
|
||||
{(kolDivergences.length > 0 || (kolDigest && kolDigest.tickers.length > 0)) && (
|
||||
<section className="overview-side-card" style={{ padding: '14px 16px' }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 10 }}>
|
||||
<div className="overview-kicker">KOL intel · 30d</div>
|
||||
<a href={`/${locale}/kol`} style={{ fontSize: 10, color: 'var(--amber-ink)', textDecoration: 'none', fontWeight: 700 }}>
|
||||
Full feed ↗
|
||||
</a>
|
||||
</div>
|
||||
<div className="overview-account-item">
|
||||
<span>Win rate</span>
|
||||
<strong>{hasPerformanceData ? `${(winRate * 100).toFixed(1)}%` : '—'}</strong>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section className="overview-side-card compact">
|
||||
<div className="overview-kicker">Chart focus</div>
|
||||
<div className="overview-side-copy">Live chart with signal markers and drill-down on click.</div>
|
||||
</section>
|
||||
|
||||
{/* Latest divergence — the money signal */}
|
||||
{kolDivergences.filter(d => d.signal_type === 'divergence').slice(0, 1).map(d => (
|
||||
<div key={d.id} style={{
|
||||
padding: '9px 11px', borderRadius: 7, marginBottom: 8,
|
||||
background: 'rgba(245,158,11,0.08)', border: '1px solid rgba(245,158,11,0.25)',
|
||||
}}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 4 }}>
|
||||
<span style={{ fontSize: 10, fontWeight: 800, color: '#f59e0b', letterSpacing: '0.05em' }}>⚠️ DIVERGENCE</span>
|
||||
<span style={{ fontSize: 10, color: 'var(--ink-4)' }}>
|
||||
{/* post_at = when the KOL actually published. created_at
|
||||
is the DB write time, which a backfill/late scan can
|
||||
set to "now", making an old event look fresh. */}
|
||||
{Math.round((Date.now() - new Date(d.post_at).getTime()) / 864e5)}d ago
|
||||
</span>
|
||||
</div>
|
||||
<div style={{ fontSize: 12, fontWeight: 600 }}>
|
||||
@{d.handle} said <span style={{ color: d.post_action === 'bullish' || d.post_action === 'buy' ? 'var(--up)' : 'var(--down)' }}>{d.post_action}</span>
|
||||
{' '}on <strong>{d.ticker}</strong>
|
||||
</div>
|
||||
<div style={{ fontSize: 11, color: 'var(--ink-3)', marginTop: 2 }}>
|
||||
Then {d.onchain_action.replace('_', ' ')}{d.usd_after != null ? ` → $${(d.usd_after / 1000).toFixed(0)}k on-chain` : ''}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
|
||||
{/* Top digest tickers */}
|
||||
{kolDigest && kolDigest.tickers.slice(0, 2).map(t => (
|
||||
<div key={t.ticker} style={{
|
||||
display: 'flex', alignItems: 'center', justifyContent: 'space-between',
|
||||
padding: '6px 0', borderBottom: '1px solid var(--line)',
|
||||
}}>
|
||||
<div>
|
||||
<span style={{ fontSize: 12, fontWeight: 700 }}>{t.ticker}</span>
|
||||
<span style={{ fontSize: 10, color: 'var(--ink-4)', marginLeft: 6 }}>{t.kol_count} KOLs</span>
|
||||
</div>
|
||||
<span style={{
|
||||
fontSize: 10, fontWeight: 700, padding: '2px 7px', borderRadius: 4,
|
||||
background: t.side === 'long' ? 'var(--up-soft)' : t.side === 'short' ? 'rgba(220,38,38,.12)' : 'var(--bg-sunk)',
|
||||
color: t.side === 'long' ? 'var(--up)' : t.side === 'short' ? 'var(--down)' : 'var(--ink-3)',
|
||||
}}>
|
||||
{t.dominant_action.toUpperCase()}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</section>
|
||||
)}
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
@@ -441,9 +569,12 @@ export default function DashboardClient({ initialPosts }: Props) {
|
||||
<div>
|
||||
<div className="tiny">Price · {asset}</div>
|
||||
<div className="row gap-m" style={{ marginTop: 6 }}>
|
||||
<div className="hero-value mono" style={{ fontSize: 32 }}>
|
||||
{displayPrice != null ? '$' + Math.round(displayPrice).toLocaleString() : '—'}
|
||||
</div>
|
||||
<AnimatedNumber
|
||||
className="hero-value mono"
|
||||
style={{ fontSize: 32 }}
|
||||
value={displayPrice}
|
||||
display={displayPrice != null ? '$' + Math.round(displayPrice).toLocaleString() : '—'}
|
||||
/>
|
||||
<span className={`chip ${priceChange >= 0 ? 'up' : 'down'}`}>{hasPriceData ? fmtPct(priceChange) : 'Feed pending'} · 24h</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -459,7 +590,20 @@ export default function DashboardClient({ initialPosts }: Props) {
|
||||
onClick={() => setChartReload(n => n + 1)}>Retry</button>
|
||||
</div>
|
||||
)}
|
||||
<div className="chart-wrap">
|
||||
<div className="chart-wrap" style={{ position: 'relative' }}>
|
||||
{/* Loading overlay — shown while candles are fetching (candles=[] and no error).
|
||||
Prevents the user from seeing a blank lightweight-charts canvas. */}
|
||||
{!hasPriceData && !chartErr && (
|
||||
<div style={{
|
||||
position: 'absolute', inset: 0, zIndex: 4,
|
||||
background: 'var(--bg-sunk)', borderRadius: 'var(--r-sm)',
|
||||
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
||||
gap: 10, color: 'var(--ink-3)', fontSize: 13,
|
||||
}}>
|
||||
<span className="live-dot" style={{ background: 'var(--amber)' }} />
|
||||
Loading chart…
|
||||
</div>
|
||||
)}
|
||||
<ChartPanel
|
||||
posts={posts}
|
||||
candles={candles}
|
||||
@@ -495,7 +639,16 @@ export default function DashboardClient({ initialPosts }: Props) {
|
||||
</div>
|
||||
<div className="post-stream">
|
||||
{recentPosts.map(p => (
|
||||
<PostRow key={p.id} post={p} />
|
||||
<div key={p.id} className={p.id === freshPostId ? 'signal-enter' : undefined}>
|
||||
<PostRow post={p} selected={selectedPostId === p.id} onClick={() => {
|
||||
// Clear the day-list view first: the right panel renders
|
||||
// selectedDayPosts with higher priority than selectedPost,
|
||||
// so without this the detail never appears while a candle's
|
||||
// multi-post list is open.
|
||||
setSelectedDayPosts(null)
|
||||
setSelectedPostId(selectedPostId === p.id ? null : p.id)
|
||||
}} />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -7,6 +7,7 @@ import { getTrades, getSignalAccuracy } from '@/lib/api'
|
||||
import type { BotTrade } from '@/types'
|
||||
import type { SignalAccuracy } from '@/lib/api'
|
||||
import { getCachedViewEnvelope, getOrCreateViewEnvelope, type SignedEnvelope } from '@/lib/signedRequest'
|
||||
import { swrFetch } from '@/lib/cache'
|
||||
import PageHint from '@/components/ui/PageHint'
|
||||
import InfoTip from '@/components/ui/InfoTip'
|
||||
|
||||
@@ -32,7 +33,8 @@ function fmtAccuracyPct(pct: number | null | undefined) {
|
||||
return pct == null || Number.isNaN(pct) ? '—' : `${pct.toFixed(0)}%`
|
||||
}
|
||||
|
||||
function inPeriod(iso: string, period: Period) {
|
||||
function inPeriod(iso: string | null, period: Period) {
|
||||
if (!iso) return false // trades without closed_at are excluded from all windows
|
||||
if (period === 'All') return true
|
||||
const days = Number.parseInt(period, 10)
|
||||
if (Number.isNaN(days)) return true
|
||||
@@ -42,8 +44,8 @@ function inPeriod(iso: string, period: Period) {
|
||||
|
||||
function calcDrawdownPct(trades: BotTrade[]) {
|
||||
const ordered = [...trades]
|
||||
.filter((t) => t.pnl_usd !== null && t.pnl_usd !== undefined)
|
||||
.sort((a, b) => new Date(a.closed_at).getTime() - new Date(b.closed_at).getTime())
|
||||
.filter((t) => t.pnl_usd !== null && t.pnl_usd !== undefined && t.closed_at !== null)
|
||||
.sort((a, b) => new Date(a.closed_at!).getTime() - new Date(b.closed_at!).getTime())
|
||||
let equity = 0
|
||||
let peak = 0
|
||||
let maxDrawdownPct = 0
|
||||
@@ -78,6 +80,14 @@ export default function AnalyticsPageClient() {
|
||||
return () => { aliveRef.current = false }
|
||||
}, [])
|
||||
|
||||
// genRef guards loadAll against stale-closure wallet-switch races.
|
||||
// snapAddr === address inside an async function is a stale-closure trap:
|
||||
// both refer to the same closed-over value at render time, so the check
|
||||
// is always true even when the wallet has changed. genRef is a mutable
|
||||
// ref that any closure can read to detect it has been superseded.
|
||||
const genRef = useRef(0)
|
||||
useEffect(() => { genRef.current++ }, [address])
|
||||
|
||||
// `forcedEnv` (a freshly-minted view_user) lets the in-page Unlock button
|
||||
// load private data without a detour through the Settings page. Public
|
||||
// signal-accuracy always loads regardless.
|
||||
@@ -89,25 +99,37 @@ export default function AnalyticsPageClient() {
|
||||
// disagreed with the closed_at-based metric grid on the same screen. Limit
|
||||
// raised to 500 so the local computation covers ample history.
|
||||
async function loadAll(forcedEnv?: SignedEnvelope) {
|
||||
const accuracyPromise = swrFetch('signal-accuracy', 10 * 60_000, () => getSignalAccuracy()).catch(() => null)
|
||||
|
||||
if (!address || !isConnected) {
|
||||
setTrades([]); setAccuracy(null); setPrivateLocked(false)
|
||||
setTrades([]); setPrivateLocked(false)
|
||||
const a = await accuracyPromise
|
||||
if (aliveRef.current) setAccuracy(a)
|
||||
return
|
||||
}
|
||||
const tradesEnv = getCachedViewEnvelope('view_trades', address)
|
||||
?? (forcedEnv ?? getCachedViewEnvelope('view_user', address))
|
||||
|
||||
const snapAddr = address
|
||||
const gen = genRef.current
|
||||
const tradesEnv = getCachedViewEnvelope('view_trades', snapAddr)
|
||||
?? (forcedEnv ?? getCachedViewEnvelope('view_user', snapAddr))
|
||||
if (aliveRef.current) setPrivateLocked(!tradesEnv)
|
||||
try {
|
||||
const [t, a] = await Promise.all([
|
||||
tradesEnv ? getTrades(address, tradesEnv, 500, 1).catch(() => []) : Promise.resolve([]),
|
||||
getSignalAccuracy().catch(() => null),
|
||||
tradesEnv ? getTrades(snapAddr, tradesEnv, 500, 1).catch(() => []) : Promise.resolve([]),
|
||||
accuracyPromise,
|
||||
])
|
||||
if (aliveRef.current) { setTrades(t); setAccuracy(a) }
|
||||
// Discard if unmounted or if a newer loadAll call has started (wallet/tab change).
|
||||
if (aliveRef.current && gen === genRef.current) { setTrades(t); setAccuracy(a) }
|
||||
} catch {
|
||||
if (aliveRef.current) setTrades([])
|
||||
if (aliveRef.current && gen === genRef.current) setTrades([])
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
// B28/B36: clear stale previous-wallet data immediately before the async
|
||||
// fetch so the UI never shows another wallet's private P&L.
|
||||
setTrades([])
|
||||
setPrivateLocked(false)
|
||||
// Navigation only uses a cached envelope — never auto-popup the wallet.
|
||||
void loadAll()
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
@@ -157,7 +179,8 @@ export default function AnalyticsPageClient() {
|
||||
const bestTrade = pnls.length ? Math.max(...pnls) : 0
|
||||
const worstTrade = pnls.length ? Math.min(...pnls) : 0
|
||||
const avgTrade = pnls.length ? totalPnl / pnls.length : 0
|
||||
const avgHold = filteredTrades.length ? filteredTrades.reduce((sum, trade) => sum + trade.hold_seconds, 0) / filteredTrades.length : 0
|
||||
const heldTrades = filteredTrades.filter(t => t.hold_seconds !== null)
|
||||
const avgHold = heldTrades.length ? heldTrades.reduce((sum, trade) => sum + (trade.hold_seconds ?? 0), 0) / heldTrades.length : 0
|
||||
// One basis for every window: derive from the closed_at-filtered trades.
|
||||
const maxDrawdown = calcDrawdownPct(filteredTrades)
|
||||
const summaryPnl = totalPnl
|
||||
@@ -169,11 +192,11 @@ export default function AnalyticsPageClient() {
|
||||
tip: 'How many closed positions in this window. Open trades not counted.' },
|
||||
{ k: isZh ? '平均持仓时间' : 'Avg hold time', v: filteredTrades.length ? fmtHold(Math.round(avgHold)) : '—', sub: isZh ? '按单笔计算' : 'Per trade',
|
||||
tip: 'Entry → exit duration averaged across every closed trade.' },
|
||||
{ k: isZh ? '平均单笔盈亏' : 'Avg trade P&L', v: fmtMoney(avgTrade), sub: isZh ? '每笔交易均值' : 'Mean per trade', up: avgTrade > 0,
|
||||
{ k: isZh ? '平均单笔盈亏' : 'Avg trade P&L', v: pnls.length ? fmtMoney(avgTrade) : '—', sub: isZh ? '每笔交易均值' : 'Mean per trade', up: avgTrade > 0,
|
||||
tip: 'Total P&L ÷ number of trades. Positive = the strategy has edge per trade.' },
|
||||
{ k: isZh ? '最佳单笔' : 'Best trade', v: fmtMoney(bestTrade), sub: isZh ? '单笔最大盈利' : 'Largest single win', up: true,
|
||||
{ k: isZh ? '最佳单笔' : 'Best trade', v: pnls.length ? fmtMoney(bestTrade) : '—', sub: isZh ? '单笔最大盈利' : 'Largest single win', up: true,
|
||||
tip: 'Biggest realized gain on one trade in this window.' },
|
||||
{ k: isZh ? '最差单笔' : 'Worst trade', v: fmtMoney(worstTrade), sub: isZh ? '单笔最大亏损' : 'Largest single loss', down: true,
|
||||
{ k: isZh ? '最差单笔' : 'Worst trade', v: pnls.length ? fmtMoney(worstTrade) : '—', sub: isZh ? '单笔最大亏损' : 'Largest single loss', down: true,
|
||||
tip: 'Biggest realized loss on one trade. Should be bounded by your stop-loss setting.' },
|
||||
]
|
||||
|
||||
@@ -183,8 +206,7 @@ export default function AnalyticsPageClient() {
|
||||
<div>
|
||||
<h1 className="page-title">{isZh ? '分析面板' : 'Analytics'}</h1>
|
||||
<PageHint>
|
||||
Did the bot actually make money? Win rate, drawdown, average trade,
|
||||
and AI signal accuracy across the time window you pick on the right.
|
||||
P&L · win rate · drawdown · signal accuracy — pick a time window on the right.
|
||||
</PageHint>
|
||||
</div>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 8, alignItems: 'flex-end' }}>
|
||||
@@ -207,6 +229,55 @@ export default function AnalyticsPageClient() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Signal accuracy — always public, shown first so non-connected visitors
|
||||
can immediately see proof of signal quality without needing to log in. */}
|
||||
{accuracy && (
|
||||
<div className="card" style={{ padding: 20, marginBottom: 20 }}>
|
||||
<div style={{ display: 'flex', alignItems: 'baseline', gap: 12, marginBottom: 14, flexWrap: 'wrap' }}>
|
||||
<div className="tiny">AI Signal Accuracy</div>
|
||||
<span style={{ fontSize: 12, color: 'var(--ink-4)' }}>{accuracy.total_directional_signals} directional signals measured</span>
|
||||
<span style={{ fontSize: 11, color: 'var(--up)', fontWeight: 600, marginLeft: 'auto' }}>Public · no login needed</span>
|
||||
</div>
|
||||
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(140px, 1fr))', gap: 8 }}>
|
||||
{/* Overall */}
|
||||
<div style={{ background: 'var(--surface-2)', borderRadius: 10, padding: '12px 14px' }}>
|
||||
<div style={{ fontSize: 11, fontWeight: 600, color: 'var(--ink-3)', marginBottom: 8, textTransform: 'uppercase', letterSpacing: '0.06em' }}>Overall</div>
|
||||
{(['m5','m15','m1h'] as const).map(w => {
|
||||
const d = accuracy.overall[w]
|
||||
const pct = d.accuracy_pct
|
||||
const color = pct >= 55 ? 'var(--up)' : pct >= 45 ? 'var(--ink-2)' : 'var(--down)'
|
||||
return (
|
||||
<div key={w} className="row between" style={{ marginBottom: 3 }}>
|
||||
<span style={{ fontSize: 11, color: 'var(--ink-3)' }}>{w.replace('m1','1').replace('m','')}</span>
|
||||
<span style={{ fontSize: 13, fontWeight: 700, color, fontVariantNumeric: 'tabular-nums' }}>{pct != null ? `${pct.toFixed(0)}%` : '—'}</span>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
{Object.entries(accuracy.by_signal).map(([sig, data]) => {
|
||||
const label = sig === 'buy' ? '🟢 Buy' : sig === 'short' ? '🔴 Short' : '🟡 Sell'
|
||||
return (
|
||||
<div key={sig} style={{ background: 'var(--surface-2)', borderRadius: 10, padding: '12px 14px' }}>
|
||||
<div style={{ fontSize: 11, fontWeight: 600, color: 'var(--ink-3)', marginBottom: 8, textTransform: 'uppercase', letterSpacing: '0.06em' }}>{label} <span style={{ fontWeight: 400 }}>({data.count})</span></div>
|
||||
{(['m5','m15','m1h'] as const).map(w => {
|
||||
const d = data[w]
|
||||
if (d.checked < 2) return <div key={w} className="row between" style={{ marginBottom: 3 }}><span style={{ fontSize: 11, color: 'var(--ink-3)' }}>{w.replace('m1','1').replace('m','')}</span><span style={{ fontSize: 12, color: 'var(--ink-3)' }}>—</span></div>
|
||||
const pct = d.accuracy_pct
|
||||
const color = pct >= 55 ? 'var(--up)' : pct >= 45 ? 'var(--ink-2)' : 'var(--down)'
|
||||
return (
|
||||
<div key={w} className="row between" style={{ marginBottom: 3 }}>
|
||||
<span style={{ fontSize: 11, color: 'var(--ink-3)' }}>{w.replace('m1','1').replace('m','')}</span>
|
||||
<span style={{ fontSize: 13, fontWeight: 700, color, fontVariantNumeric: 'tabular-nums' }}>{pct.toFixed(0)}%</span>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{isPaperView && filteredTrades.length > 0 && (
|
||||
<div className="card" style={{
|
||||
padding: '10px 16px', marginBottom: 16, fontSize: 12, fontWeight: 600,
|
||||
@@ -265,60 +336,16 @@ export default function AnalyticsPageClient() {
|
||||
))}
|
||||
</div>
|
||||
|
||||
{accuracy && (
|
||||
<div className="card" style={{ padding: 24, marginBottom: 20 }}>
|
||||
<div className="tiny" style={{ marginBottom: 16 }}>{isZh ? `AI 信号准确率 · ${accuracy.total_directional_signals} 条方向性信号` : `AI Signal Accuracy · ${accuracy.total_directional_signals} directional signals`}</div>
|
||||
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(200px, 1fr))', gap: 12 }}>
|
||||
<div style={{ background: 'var(--surface-2)', borderRadius: 10, padding: '14px 16px' }}>
|
||||
<div style={{ fontSize: 11, fontWeight: 600, color: 'var(--ink-3)', marginBottom: 8, textTransform: 'uppercase', letterSpacing: '0.06em' }}>{isZh ? '整体' : 'Overall'}</div>
|
||||
{(['m5','m15','m1h'] as const).map(w => {
|
||||
const d = accuracy.overall[w]
|
||||
const pct = d.accuracy_pct
|
||||
const color = pct >= 55 ? 'var(--up)' : pct >= 45 ? 'var(--ink-2)' : 'var(--down)'
|
||||
return (
|
||||
<div key={w} className="row between" style={{ marginBottom: 4 }}>
|
||||
<span style={{ fontSize: 12, color: 'var(--ink-3)' }}>{w.replace('m','').replace('1h','1h')}</span>
|
||||
<span style={{ fontSize: 13, fontWeight: 600, color, fontVariantNumeric: 'tabular-nums' }}>{fmtAccuracyPct(pct)}</span>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
<div style={{ fontSize: 11, color: 'var(--ink-3)', marginTop: 6 }}>{isZh ? `${accuracy.overall.m5.checked} 条已测` : `${accuracy.overall.m5.checked} measured`}</div>
|
||||
</div>
|
||||
{Object.entries(accuracy.by_signal).map(([sig, data]) => {
|
||||
const label = sig === 'buy' ? (isZh ? '🟢 做多' : '🟢 Buy') : sig === 'short' ? (isZh ? '🔴 做空' : '🔴 Short') : (isZh ? '🟡 卖出' : '🟡 Sell')
|
||||
return (
|
||||
<div key={sig} style={{ background: 'var(--surface-2)', borderRadius: 10, padding: '14px 16px' }}>
|
||||
<div style={{ fontSize: 11, fontWeight: 600, color: 'var(--ink-3)', marginBottom: 8, textTransform: 'uppercase', letterSpacing: '0.06em' }}>{label} <span style={{ fontWeight: 400 }}>({data.count})</span></div>
|
||||
{(['m5','m15','m1h'] as const).map(w => {
|
||||
const d = data[w]
|
||||
if (d.checked < 2) return (
|
||||
<div key={w} className="row between" style={{ marginBottom: 4 }}>
|
||||
<span style={{ fontSize: 12, color: 'var(--ink-3)' }}>{w}</span>
|
||||
<span style={{ fontSize: 12, color: 'var(--ink-3)' }}>—</span>
|
||||
</div>
|
||||
)
|
||||
const pct = d.accuracy_pct
|
||||
const color = pct >= 55 ? 'var(--up)' : pct >= 45 ? 'var(--ink-2)' : 'var(--down)'
|
||||
return (
|
||||
<div key={w} className="row between" style={{ marginBottom: 4 }}>
|
||||
<span style={{ fontSize: 12, color: 'var(--ink-3)' }}>{w}</span>
|
||||
<span style={{ fontSize: 13, fontWeight: 600, color, fontVariantNumeric: 'tabular-nums' }}>{fmtAccuracyPct(pct)}</span>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
<div style={{ fontSize: 11, color: 'var(--ink-3)', marginTop: 6 }}>{isZh ? `${data.m5.checked} 条已测` : `${data.m5.checked} measured`}</div>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{/* Signal accuracy is now shown at the top of the page (public, no login needed).
|
||||
Removed duplicate block here to avoid showing the same data twice. */}
|
||||
|
||||
{!filteredTrades.length && (
|
||||
<div className="card" style={{ padding: 60, textAlign: 'center', color: 'var(--ink-3)' }}>
|
||||
<p style={{ fontSize: 14 }}>
|
||||
{!isConnected || !address
|
||||
? (isZh ? '连接钱包以加载你的分析数据。' : 'Connect your wallet to load your analytics.')
|
||||
: privateLocked
|
||||
? (isZh ? '签名解锁后可查看你的真实业绩和交易历史。' : 'Sign once above to unlock your personal P&L and trade history.')
|
||||
: trades.length
|
||||
? (isZh ? `${period} 时间窗内还没有已平仓交易。` : `No trades closed in the ${period} window yet.`)
|
||||
: (isZh ? '还没有交易数据。机器人开始执行后,这里会自动出现统计。' : 'No trade data yet. The bot will populate analytics once it starts executing.')}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/** Instant skeleton while AnalyticsPage loads. */
|
||||
export default function AnalyticsLoading() {
|
||||
return (
|
||||
<div className="page">
|
||||
<div className="page-head" style={{ marginBottom: 24 }}>
|
||||
<div className="skeleton sk-title" style={{ width: 160, marginBottom: 8 }} />
|
||||
</div>
|
||||
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(140px, 1fr))', gap: 12, marginBottom: 20 }}>
|
||||
{Array.from({ length: 3 }).map((_, i) => (
|
||||
<div key={i} className="skeleton-card" style={{ padding: 20 }}>
|
||||
<div className="skeleton sk-line sk-w-half" style={{ marginBottom: 12 }} />
|
||||
<div className="skeleton" style={{ height: 40, width: 100 }} />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<div className="skeleton-card" style={{ padding: 24 }}>
|
||||
<div className="skeleton sk-line" style={{ width: 140, marginBottom: 16 }} />
|
||||
{Array.from({ length: 5 }).map((_, i) => (
|
||||
<div key={i} style={{ display: 'flex', gap: 12, marginBottom: 10 }}>
|
||||
<div className="skeleton sk-line" style={{ width: 80 }} />
|
||||
<div className="skeleton sk-line" style={{ width: 60 }} />
|
||||
<div className="skeleton sk-line sk-w-3q" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,68 +1,98 @@
|
||||
'use client'
|
||||
|
||||
import { useState, useEffect, useMemo } from 'react'
|
||||
import { useLocale } from 'next-intl'
|
||||
import { useState, useEffect } from 'react'
|
||||
import type { TrumpPost } from '@/types'
|
||||
import { getPosts } from '@/lib/api'
|
||||
import { getPosts, getPostsPage, type PostListResponse } from '@/lib/api'
|
||||
import { hasCached, swrFetch } from '@/lib/cache'
|
||||
import PostRow from '@/components/dashboard/PostCards'
|
||||
import PageHint from '@/components/ui/PageHint'
|
||||
import Pagination from '@/components/ui/Pagination'
|
||||
import { buildArchiveFallbackResponse } from '@/lib/postPage'
|
||||
|
||||
const ARCHIVE_PAGE_SIZE = 30
|
||||
|
||||
const LIVE_SOURCES = new Set([
|
||||
'truth',
|
||||
'btc_bottom_reversal',
|
||||
'funding_reversal',
|
||||
'kol_divergence',
|
||||
])
|
||||
interface ArchivePageClientProps {
|
||||
initialData?: PostListResponse | null
|
||||
}
|
||||
|
||||
/**
|
||||
* Archive — legacy / test signals (rsi_reversal, sma_reclaim, breakout,
|
||||
* test, phase1…). NOT a live system. Kept only so old data is inspectable.
|
||||
*/
|
||||
export default function ArchivePageClient() {
|
||||
const locale = useLocale()
|
||||
const isZh = false // i18n shelved — Chinese branches kept as dead code for future revival; see messages/zh.json
|
||||
const [posts, setPosts] = useState<TrumpPost[]>([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
export default function ArchivePageClient({ initialData = null }: ArchivePageClientProps) {
|
||||
const [posts, setPosts] = useState<TrumpPost[]>(initialData?.items ?? [])
|
||||
const [totalPosts, setTotalPosts] = useState(initialData?.total ?? 0)
|
||||
const [sourceCounts, setSourceCounts] = useState(initialData?.source_counts ?? [])
|
||||
const [loading, setLoading] = useState(initialData === null)
|
||||
const [loadErr, setLoadErr] = useState('')
|
||||
const [src, setSrc] = useState<string>('all')
|
||||
const [archivePage, setArchivePage] = useState(1)
|
||||
|
||||
useEffect(() => {
|
||||
getPosts(500, 1)
|
||||
.then(p => { setPosts(p); setLoadErr('') })
|
||||
.catch(e => setLoadErr(e instanceof Error ? e.message : (isZh ? '历史归档加载失败' : 'Failed to load archive')))
|
||||
.finally(() => setLoading(false))
|
||||
}, [isZh])
|
||||
const key = `archive-page-${archivePage}-src-${src}`
|
||||
setLoadErr('')
|
||||
setLoading(posts.length === 0 && !hasCached(key))
|
||||
|
||||
// Archive = legacy / test data only. Exclude every live signal source so
|
||||
// active modules don't leak in here as users explore old experiments. Keep
|
||||
// this set in sync with sources emitted by app/services/scanners/*.
|
||||
const archivePosts = useMemo(
|
||||
() => posts.filter(p => !LIVE_SOURCES.has(p.source || '')),
|
||||
[posts],
|
||||
)
|
||||
const sources = useMemo(() => {
|
||||
const m: Record<string, number> = {}
|
||||
for (const p of archivePosts) m[p.source || '?'] = (m[p.source || '?'] || 0) + 1
|
||||
return Object.entries(m).sort((a, b) => b[1] - a[1])
|
||||
}, [archivePosts])
|
||||
const filtered = useMemo(
|
||||
() => src === 'all' ? archivePosts : archivePosts.filter(p => p.source === src),
|
||||
[archivePosts, src],
|
||||
)
|
||||
const archiveTotalPages = Math.max(1, Math.ceil(filtered.length / ARCHIVE_PAGE_SIZE))
|
||||
const archiveSafePage = Math.min(archivePage, archiveTotalPages)
|
||||
const archivePageItems = filtered.slice((archiveSafePage - 1) * ARCHIVE_PAGE_SIZE, archiveSafePage * ARCHIVE_PAGE_SIZE)
|
||||
swrFetch(
|
||||
key,
|
||||
3 * 60_000,
|
||||
() => getPostsPage(
|
||||
ARCHIVE_PAGE_SIZE,
|
||||
archivePage,
|
||||
undefined,
|
||||
{
|
||||
archiveOnly: true,
|
||||
sourceIn: src === 'all' ? undefined : [src],
|
||||
},
|
||||
),
|
||||
fresh => {
|
||||
setPosts(fresh.items)
|
||||
setTotalPosts(fresh.total)
|
||||
setSourceCounts(fresh.source_counts)
|
||||
},
|
||||
)
|
||||
.then(r => {
|
||||
setPosts(r.items)
|
||||
setTotalPosts(r.total)
|
||||
setSourceCounts(r.source_counts)
|
||||
})
|
||||
.catch(async e => {
|
||||
const detail = e instanceof Error ? e.message : 'Failed to load archive'
|
||||
if (!detail.includes('404')) {
|
||||
setLoadErr(detail)
|
||||
return
|
||||
}
|
||||
try {
|
||||
const legacyPosts = await swrFetch(
|
||||
'archive-legacy-500',
|
||||
3 * 60_000,
|
||||
() => getPosts(500, 1),
|
||||
)
|
||||
const fallback = buildArchiveFallbackResponse(legacyPosts, archivePage, ARCHIVE_PAGE_SIZE, src)
|
||||
setPosts(fallback.items)
|
||||
setTotalPosts(fallback.total)
|
||||
setSourceCounts(fallback.source_counts)
|
||||
setLoadErr('')
|
||||
} catch (legacyErr) {
|
||||
setLoadErr(legacyErr instanceof Error ? legacyErr.message : detail)
|
||||
}
|
||||
})
|
||||
.finally(() => setLoading(false))
|
||||
}, [archivePage, posts.length, src])
|
||||
|
||||
const archiveTotalPages = Math.max(1, Math.ceil(totalPosts / ARCHIVE_PAGE_SIZE))
|
||||
const archiveSafePage = Math.min(archivePage, archiveTotalPages)
|
||||
const allSourcesCount = sourceCounts.reduce((sum, item) => sum + item.count, 0)
|
||||
const selectedCount = src === 'all'
|
||||
? totalPosts
|
||||
: sourceCounts.find(s => s.source === src)?.count ?? totalPosts
|
||||
const sourceTabs: [string, number][] = [
|
||||
['all', allSourcesCount],
|
||||
...sourceCounts.map(item => [item.source, item.count] as [string, number]),
|
||||
]
|
||||
|
||||
return (
|
||||
<div className="page">
|
||||
<div className="page-head">
|
||||
<div>
|
||||
<h1 className="page-title">Archive</h1>
|
||||
<PageHint count={`${archivePosts.length} legacy posts`}>
|
||||
<PageHint count={`${selectedCount} legacy posts`}>
|
||||
Signals from retired scanner experiments
|
||||
(rsi_reversal, sma_reclaim, breakout, test/phase1). Read-only —
|
||||
the bot no longer acts on any of these.
|
||||
@@ -71,7 +101,7 @@ export default function ArchivePageClient() {
|
||||
</div>
|
||||
|
||||
<div style={{ display: 'flex', gap: 6, flexWrap: 'wrap', marginBottom: 12 }}>
|
||||
{[['all', archivePosts.length] as [string, number], ...sources].map(([s, n]) => (
|
||||
{sourceTabs.map(([s, n]) => (
|
||||
<button
|
||||
key={s}
|
||||
onClick={() => { setSrc(s); setArchivePage(1) }}
|
||||
@@ -87,30 +117,30 @@ export default function ArchivePageClient() {
|
||||
))}
|
||||
</div>
|
||||
|
||||
{loading && <div style={{ textAlign: 'center', padding: 60, color: 'var(--ink-3)' }}>{isZh ? '加载中…' : 'Loading…'}</div>}
|
||||
{loading && <div style={{ textAlign: 'center', padding: 60, color: 'var(--ink-3)' }}>Loading…</div>}
|
||||
{!loading && loadErr && (
|
||||
<div className="card" style={{ padding: 24, textAlign: 'center', color: 'var(--down)' }}>
|
||||
⚠️ {isZh ? `无法加载归档:${loadErr}` : `Couldn't load archive — ${loadErr}`}
|
||||
⚠️ {`Couldn't load archive — ${loadErr}`}
|
||||
<div style={{ marginTop: 10 }}>
|
||||
<button className="btn ghost" style={{ fontSize: 12, padding: '6px 14px' }}
|
||||
onClick={() => location.reload()}>{isZh ? '重试' : 'Retry'}</button>
|
||||
onClick={() => location.reload()}>Retry</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{!loading && !loadErr && filtered.length === 0 && (
|
||||
{!loading && !loadErr && totalPosts === 0 && (
|
||||
<div className="card" style={{ padding: 48, textAlign: 'center', color: 'var(--ink-3)' }}>
|
||||
{isZh ? '没有可显示的历史信号。' : 'No archived signals.'}
|
||||
No archived signals.
|
||||
</div>
|
||||
)}
|
||||
{!loading && archivePageItems.length > 0 && (
|
||||
{!loading && posts.length > 0 && (
|
||||
<>
|
||||
<div className="post-stream">
|
||||
{archivePageItems.map(p => <PostRow key={p.id} post={p} />)}
|
||||
{posts.map(p => <PostRow key={p.id} post={p} />)}
|
||||
</div>
|
||||
<Pagination
|
||||
page={archiveSafePage}
|
||||
total={archiveTotalPages}
|
||||
count={filtered.length}
|
||||
count={totalPosts}
|
||||
pageSize={ARCHIVE_PAGE_SIZE}
|
||||
onChange={setArchivePage}
|
||||
/>
|
||||
|
||||
@@ -1,13 +1,25 @@
|
||||
// Archive is legacy/test data only — not part of the live signal stack.
|
||||
// noindex keeps it out of search results (duplicate/thin content risk)
|
||||
// while keeping it accessible to logged-in users for inspection.
|
||||
export const revalidate = 60 // archive data rarely changes — ISR at 60s keeps server load low
|
||||
import type { Metadata } from 'next'
|
||||
import { type PostListResponse } from '@/lib/api'
|
||||
import { getPosts } from '@/lib/api'
|
||||
import { buildArchiveFallbackResponse, getInitialPostPage } from '@/lib/postPage'
|
||||
import ArchivePageClient from './ArchivePageClient'
|
||||
|
||||
export const metadata: Metadata = {
|
||||
robots: { index: false, follow: false },
|
||||
}
|
||||
|
||||
export default function ArchivePage() {
|
||||
return <ArchivePageClient />
|
||||
export default async function ArchivePage() {
|
||||
const initialData: PostListResponse | null = await getInitialPostPage(30, 1, {
|
||||
filters: { archiveOnly: true },
|
||||
legacyFallback: async () => {
|
||||
const legacyItems = await getPosts(500, 1).catch(() => null)
|
||||
return legacyItems ? buildArchiveFallbackResponse(legacyItems, 1, 30) : null
|
||||
},
|
||||
})
|
||||
|
||||
return <ArchivePageClient initialData={initialData} />
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { redirect } from 'next/navigation'
|
||||
import { permanentRedirect } from 'next/navigation'
|
||||
|
||||
interface LegacyBtcPageProps {
|
||||
params: Promise<{ locale: string }>
|
||||
@@ -6,5 +6,5 @@ interface LegacyBtcPageProps {
|
||||
|
||||
export default async function LegacyBtcPage({ params }: LegacyBtcPageProps) {
|
||||
const { locale } = await params
|
||||
redirect(`/${locale}/macro`)
|
||||
permanentRedirect(`/${locale}/macro`)
|
||||
}
|
||||
|
||||
@@ -173,14 +173,14 @@ function getCopy(locale: string): CaseStudiesCopy {
|
||||
ogDescription:
|
||||
'Historical cases that show why the Trump, BTC, and KOL engines exist: posts, wallet behavior, price reaction, and evidence.',
|
||||
heroTitle: 'Case Studies',
|
||||
heroSubtitle: 'Real events, real positioning, and real price reactions — documented.',
|
||||
heroSubtitle: 'Real events, real price moves — why these signals are worth tracking.',
|
||||
intro:
|
||||
'This is not a performance-claims page. It is an evidence page. Each case answers three questions: what happened, how the market reacted, and why that event supports one of the signal engines.',
|
||||
'Three documented cases where the signal worked. Not forecasts — history.',
|
||||
statAsset: 'Asset',
|
||||
statImpact: 'Price impact',
|
||||
statImpact: 'Move',
|
||||
statWindow: 'Window',
|
||||
evidenceLabel: 'Evidence',
|
||||
footer: 'These cases illustrate the historical basis for each signal engine. They are not return forecasts.',
|
||||
evidenceLabel: 'Source',
|
||||
footer: 'Past events don\'t guarantee future results. These cases show why the signal categories exist.',
|
||||
footerMethodology: 'Methodology',
|
||||
footerGlossary: 'Glossary',
|
||||
cases: [
|
||||
@@ -188,85 +188,51 @@ function getCopy(locale: string): CaseStudiesCopy {
|
||||
id: 'strategic-reserve-2025',
|
||||
date: 'March 2, 2025',
|
||||
source: 'Trump Truth Social',
|
||||
title: 'Strategic Crypto Reserve announcement',
|
||||
summary: 'Trump confirmed a U.S. Strategic Crypto Reserve including BTC, ETH, SOL, XRP, and ADA.',
|
||||
title: 'Trump announces U.S. Strategic Crypto Reserve — BTC +8%, ETH +10%',
|
||||
summary: 'Trump posted confirmation of a U.S. Strategic Crypto Reserve including BTC, ETH, SOL, XRP, and ADA. Markets moved within minutes.',
|
||||
signal: 'LONG',
|
||||
asset: 'BTC / ETH',
|
||||
priceImpact: 'BTC +8.2%, ETH +10%+',
|
||||
impactWindow: '24 hours',
|
||||
detail:
|
||||
'This case mattered because the post moved from vague political tone into explicit asset-level policy language. A signal engine should classify that as a high-conviction LONG event, because it names specific assets and ties them to a state-level commitment.',
|
||||
'The post named specific assets and tied them to a government-level commitment — the clearest possible bullish signal. This is exactly what the Trump signal engine is built to catch: a post that goes from vague political tone to explicit crypto policy in one statement.',
|
||||
evidence:
|
||||
'CNBC and Al Jazeera both documented the market response, and exchange plus on-chain data showed clear momentum-driven inflows after the post.',
|
||||
'CNBC and Al Jazeera documented the market response. Exchange data showed immediate momentum-driven inflows.',
|
||||
externalUrl:
|
||||
'https://www.cnbc.com/2025/03/02/trump-announces-strategic-crypto-reserve-including-bitcoin-solana-xrp-and-more.html',
|
||||
},
|
||||
{
|
||||
id: 'whale-6m-perp',
|
||||
date: 'March 2025',
|
||||
source: 'On-chain / Truth Social',
|
||||
title: '$6.8M pre-positioning profit around the reserve post',
|
||||
summary:
|
||||
'An anonymous address built a large leveraged BTC/ETH position around the reserve announcement and reportedly closed it the same day for roughly $6.8M profit.',
|
||||
signal: 'LONG',
|
||||
asset: 'BTC',
|
||||
priceImpact: '+$6.8M',
|
||||
impactWindow: 'Same day',
|
||||
detail:
|
||||
'This case highlights two facts at once. First, Trump-linked posts can create enough directional force to matter. Second, speed itself is edge in event-driven trading. Whether this was advance positioning or ultra-fast automation, it validates the post-to-trade-to-PnL chain.',
|
||||
evidence:
|
||||
'The trade was documented by Raw Story / NewsBreak, and TIME later referenced the political and regulatory scrutiny around the episode.',
|
||||
externalUrl:
|
||||
'https://www.newsbreak.com/raw-story-2096750/4286876592634-that-s-the-maga-playbook-crypto-trade-made-moments-before-trump-post-raises-eyebrows',
|
||||
},
|
||||
{
|
||||
id: 'tariff-china-2025',
|
||||
date: 'April 2025',
|
||||
source: 'Trump Truth Social',
|
||||
title: 'Tariff escalation post triggered a risk-off move',
|
||||
summary: 'A tariff-escalation post created a short-term macro risk-off setup rather than a bullish crypto reaction.',
|
||||
title: 'Tariff escalation post — BTC -4% in 4 hours',
|
||||
summary: 'A tariff-escalation post compressed risk appetite fast. BTC dropped 4.1% in 4 hours — no crypto-specific news, just macro sentiment repricing.',
|
||||
signal: 'SHORT',
|
||||
asset: 'BTC',
|
||||
priceImpact: 'BTC -4.1%',
|
||||
impactWindow: '4 hours',
|
||||
detail:
|
||||
'Not every Trump post is bullish for crypto. Posts framed around trade conflict, tariff escalation, tighter regulation, or macro uncertainty can compress risk appetite quickly. This case supports the need for a real SHORT branch in the signal engine.',
|
||||
'Not every Trump post is bullish for crypto. Trade conflict, tariffs, and macro uncertainty posts can hit crypto just as hard as equity markets. This is why the signal engine has a real SHORT branch — and why noise filtering matters.',
|
||||
evidence:
|
||||
'CoinDesk has documented multiple instances of Trump statements moving BTC. This post fits that broader historical pattern of immediate sentiment repricing.',
|
||||
'CoinDesk has documented multiple Trump statements that moved BTC in both directions.',
|
||||
externalUrl:
|
||||
'https://www.coindesk.com/markets/2026/04/20/five-times-president-trump-made-a-statement-that-moved-bitcoin-and-why-it-might-happen-again-this-week',
|
||||
},
|
||||
{
|
||||
id: 'kol-divergence-example',
|
||||
date: 'Illustrative composite',
|
||||
source: 'KOL post + on-chain wallet',
|
||||
title: 'Publicly bullish on ETH, privately reducing ETH',
|
||||
date: 'Composite example',
|
||||
source: 'KOL post + tracked wallet',
|
||||
title: 'KOL bullish on ETH in public, selling ETH on-chain',
|
||||
summary:
|
||||
'A tracked KOL published a bullish ETH thesis, then reduced roughly $180k of ETH exposure within five days. That is classic talks-vs-trades divergence.',
|
||||
'A tracked KOL published a bullish ETH thesis. Within 5 days, their wallet reduced ~$180k of ETH exposure. Public pitch said buy — the wallet said sell.',
|
||||
signal: 'DIVERGENCE',
|
||||
asset: 'ETH',
|
||||
priceImpact: 'N/A',
|
||||
impactWindow: '±7 days',
|
||||
detail:
|
||||
'This example is not about a single post moving price. It is about the information gap between public narrative and real positioning. For research-heavy users, that gap is often more valuable than a simple bullish or bearish statement.',
|
||||
'Words are free. Wallet moves cost money. When a KOL\'s on-chain behavior contradicts their public call, the wallet is usually telling the truth. This is why the KOL module tracks both — and why divergence is the highest-conviction category.',
|
||||
evidence:
|
||||
'The divergence classification comes from the platform’s cross-signal logic, which is documented in full on the Methodology page.',
|
||||
},
|
||||
{
|
||||
id: 'btc-bottom-nov-2022',
|
||||
date: 'November 2022',
|
||||
source: 'Historical BTC macro-bottom reference',
|
||||
title: 'The $15.5k FTX washout zone',
|
||||
summary:
|
||||
'After the FTX collapse, BTC entered the $15.5k region and later recovered toward $69k within roughly 18 months. This is the kind of regime the BTC macro-bottom engine is built to identify.',
|
||||
signal: 'LONG',
|
||||
asset: 'BTC',
|
||||
priceImpact: '+345%',
|
||||
impactWindow: '18 months',
|
||||
detail:
|
||||
'The current live BTC engine is not trying to replay an old premium-data model. It is trying to locate the same market structure with AHR999, the 200-week moving average, and Pi Cycle Bottom: deep value, long-cycle support, and emotional washout lining up together.',
|
||||
evidence:
|
||||
'Public price archives and long-range market charts consistently mark the FTX washout zone as the core bottom region of that bear market.',
|
||||
'Divergence detection logic is documented on the Methodology page.',
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
+640
-308
File diff suppressed because it is too large
Load Diff
@@ -171,104 +171,105 @@ function getCopy(locale: string): GlossaryCopy {
|
||||
],
|
||||
ogTitle: 'Crypto Signals Glossary | Trump Alpha',
|
||||
ogDescription:
|
||||
'Clear definitions of Trump Alpha’s core terms, optimized for search, AI retrieval, and fast reference.',
|
||||
'Clear definitions of Trump Alpha\'s core terms, optimized for search, AI retrieval, and fast reference.',
|
||||
heroTitle: 'Glossary',
|
||||
heroSubtitle: 'Every term on the platform, defined precisely.',
|
||||
intro:
|
||||
'Definitions for all the metrics, signal terms, and trading concepts you\'ll encounter on this platform.',
|
||||
'Quick definitions for the terms you\'ll encounter on this platform.',
|
||||
terms: [
|
||||
{
|
||||
term: 'AHR999',
|
||||
category: 'Macro-bottom metric',
|
||||
category: 'Macro-bottom signal',
|
||||
definition:
|
||||
'AHR999 is a Bitcoin valuation indicator popular in Chinese crypto research. It combines long-term trend and cost-basis style anchors to estimate whether BTC is trading in a deep-value regime. In Trump Alpha, AHR999 below 0.45 counts as one classic bottom signal.',
|
||||
extra: 'It is one of the three inputs in the live BTC 2-of-3 macro-bottom scanner.',
|
||||
'A Bitcoin valuation score. Below 0.45 = BTC is historically cheap and in a potential bottom zone. Above 1.2 = overvalued, bottom thesis is off. One of three conditions in the BTC bottom scanner.',
|
||||
},
|
||||
{
|
||||
term: 'Pi Cycle Bottom',
|
||||
category: 'Macro-bottom metric',
|
||||
category: 'Macro-bottom signal',
|
||||
definition:
|
||||
'Pi Cycle Bottom is a Bitcoin bottom framework based on long-cycle moving-average relationships. In Trump Alpha, the condition is satisfied when the 150-day EMA falls below the 471-day SMA multiplied by 0.745.',
|
||||
extra: 'It is one of the three core inputs in the BTC macro-bottom scanner.',
|
||||
'A long-term moving-average signal that has historically aligned with Bitcoin cycle lows. Fires when the 150-day EMA crosses below the 471-day SMA × 0.745. Binary — either confirmed or not.',
|
||||
},
|
||||
{
|
||||
term: '200-week Moving Average',
|
||||
category: 'Macro-bottom metric',
|
||||
category: 'Macro-bottom signal',
|
||||
definition:
|
||||
'The 200-week moving average is one of Bitcoin’s most widely watched long-term trend anchors. Many historical bear-market lows formed near this zone. Trump Alpha treats price proximity to the 200-week MA as part of BTC bottom confluence.',
|
||||
'BTC\'s most-watched long-term support level. Every major bear-market low in history formed at or near it. The scanner counts price ≤ 200WMA × 1.05 as a bottom vote.',
|
||||
},
|
||||
{
|
||||
term: 'KOL',
|
||||
abbr: 'Key Opinion Leader',
|
||||
category: 'Platform term',
|
||||
definition:
|
||||
'In crypto, a KOL is an analyst, fund manager, host, or creator whose public views consistently influence market narrative or retail positioning. Trump Alpha emphasizes long-form KOL sources, not only short social fragments.',
|
||||
'An analyst, fund manager, podcast host, or creator whose calls move crypto narrative. The platform tracks 25 KOLs — Arthur Hayes, Delphi, Bankless, and others — cross-checking what they say publicly against what their wallets actually do.',
|
||||
},
|
||||
{
|
||||
term: 'Talks-vs-Trades Divergence',
|
||||
category: 'Platform term',
|
||||
definition:
|
||||
'Talks-vs-trades divergence happens when a KOL’s public stance and wallet behavior point in opposite directions on the same asset. Example: a KOL publishes a bullish ETH thesis while their wallet reduces ETH exposure that same week. Trump Alpha treats the wallet move as the higher-priority truth signal.',
|
||||
extra: 'This is one of the platform’s highest-information signals because it separates narrative from actual positioning.',
|
||||
'When a KOL\'s public call and their wallet move in opposite directions on the same asset. Example: publicly bullish ETH while quietly reducing ETH on-chain. The wallet is treated as the real signal — it\'s harder to fake than words.',
|
||||
extra: 'Highest-conviction signal category on the platform.',
|
||||
},
|
||||
{
|
||||
term: 'Conviction Score',
|
||||
term: 'Aligned',
|
||||
category: 'Platform term',
|
||||
definition:
|
||||
'Conviction Score is the AI-generated strength score assigned to each extracted KOL view, typically ranging from 0.0 to 1.0. Higher values imply clearer language, stronger commitment, and better evidence of timing or sizing intent.',
|
||||
'A KOL\'s public call and their tracked wallet activity agree — e.g., bullish on BTC and the wallet is adding BTC. Reinforces the signal.',
|
||||
},
|
||||
{
|
||||
term: 'Mismatch',
|
||||
category: 'Platform term',
|
||||
definition:
|
||||
'A KOL\'s public call contradicts their wallet move. Bullish in public, selling on-chain = mismatch. This is the divergence signal you actually want to act on.',
|
||||
},
|
||||
{
|
||||
term: 'Paper mode',
|
||||
category: 'Platform term',
|
||||
definition:
|
||||
'Simulated trading — the bot runs through all its logic and tracks positions, but no real orders are sent to Hyperliquid. Use it to see how the bot would have performed before risking real money.',
|
||||
},
|
||||
{
|
||||
term: '/adopt',
|
||||
category: 'Platform term',
|
||||
definition:
|
||||
'A Telegram bot command. When a Macro Vibes signal fires, you open the position yourself on Hyperliquid, then send /adopt in the bot. The bot then takes over managing the exit — stop ladder, partial de-risk, pyramiding — without you having to watch it.',
|
||||
},
|
||||
{
|
||||
term: 'AI Confidence',
|
||||
category: 'Platform term',
|
||||
definition:
|
||||
'A percentage score (0–100%) the AI assigns to each Trump post signal. Higher = the post language is clearer and more explicitly directional. The default threshold is 70% — signals below this are not traded.',
|
||||
},
|
||||
{
|
||||
term: 'Funding Rate',
|
||||
category: 'Derivatives term',
|
||||
definition:
|
||||
'Funding rate is the periodic payment mechanism used by perpetual futures to keep contract pricing anchored to spot. If longs pay shorts, the market is long-crowded. If shorts pay longs, the market is short-crowded. Extreme readings often precede liquidation-driven reversals.',
|
||||
'The periodic payment between long and short traders on a perp exchange, designed to keep the contract price close to spot. Extreme positive funding = crowded longs. Extreme negative = crowded shorts. Extreme readings often precede sharp reversals when the crowded side gets squeezed.',
|
||||
},
|
||||
{
|
||||
term: 'Isolated Margin',
|
||||
category: 'Trading term',
|
||||
definition:
|
||||
'Isolated margin means each trade uses its own dedicated margin rather than sharing risk with the rest of the account. If one position is liquidated, it does not automatically cascade into other positions.',
|
||||
extra: 'Trump Alpha’s execution layer is designed around isolated margin.',
|
||||
'Each trade uses only its own dedicated margin — if it gets liquidated, it doesn\'t touch your other positions. Trump Alpha always uses isolated margin so one bad trade can\'t wipe the account.',
|
||||
},
|
||||
{
|
||||
term: 'TP / SL',
|
||||
abbr: 'Take-Profit / Stop-Loss',
|
||||
category: 'Trading term',
|
||||
definition:
|
||||
'TP and SL are conditional exit orders for profit-taking and loss control. Trump Alpha’s auto-trader attaches both at entry rather than after the position is already open.',
|
||||
},
|
||||
{
|
||||
term: 'UTXO',
|
||||
abbr: 'Unspent Transaction Output',
|
||||
category: 'Bitcoin term',
|
||||
definition:
|
||||
'UTXO is the fundamental accounting unit of the Bitcoin network. Trump Alpha’s live Macro Vibes module no longer relies directly on UTXO-spend behavior, but the concept still matters for interpreting classic on-chain research.',
|
||||
'Automatic exit orders placed at entry. TP closes the trade in profit at your target. SL closes it to cut losses. Trump Alpha attaches both the moment a trade opens.',
|
||||
},
|
||||
{
|
||||
term: 'Perpetual Future',
|
||||
abbr: 'Perp',
|
||||
category: 'Derivatives term',
|
||||
definition:
|
||||
'A perp is a futures contract with no expiry date. It stays open until the trader closes it or gets liquidated, while funding rate and mark-price mechanisms help keep it close to spot. Hyperliquid is one example of a perp venue.',
|
||||
},
|
||||
{
|
||||
term: 'Substack Signal',
|
||||
category: 'Platform term',
|
||||
definition:
|
||||
'A Substack signal is an extracted asset view taken from a KOL’s long-form essay, newsletter, or blog post. These sources usually contain fuller reasoning than short posts and therefore produce more retrieval-friendly signal data.',
|
||||
'A futures contract with no expiry. You stay in the trade until you close it or get liquidated. Trump Alpha executes on Hyperliquid perps.',
|
||||
},
|
||||
{
|
||||
term: 'Capitulation',
|
||||
category: 'Market term',
|
||||
definition:
|
||||
'Capitulation is the stage of a drawdown when holders finally give up and sell into weakness. It often appears near the end of a bear market and is one of the environments the BTC bottom scanner is designed to detect.',
|
||||
},
|
||||
{
|
||||
term: 'EMA',
|
||||
abbr: 'Exponential Moving Average',
|
||||
category: 'Technical term',
|
||||
definition:
|
||||
'EMA is a moving average that gives more weight to recent price data than older data. Trump Alpha uses the 150-day EMA inside the Pi Cycle Bottom condition.',
|
||||
'The phase near a bear market bottom where panicked holders give up and sell en masse. Creates the washout conditions that the BTC macro-bottom scanner is designed to detect.',
|
||||
},
|
||||
],
|
||||
footerLead: 'Missing a term?',
|
||||
|
||||
+226
-171
@@ -1,6 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useLocale } from 'next-intl'
|
||||
import type {
|
||||
@@ -42,8 +42,8 @@ function actionLabel(action: KolTicker['action'], isZh: boolean) {
|
||||
}
|
||||
|
||||
function windowLabel(days: number, isZh: boolean) {
|
||||
if (days === 1) return isZh ? '今日' : 'Today'
|
||||
return isZh ? `近 ${days} 日` : `Last ${days}d`
|
||||
if (days === 1) return 'Today'
|
||||
return `Last ${days}d`
|
||||
}
|
||||
|
||||
function changeLabel(changeType: KolHoldingChange['change_type'], isZh: boolean) {
|
||||
@@ -100,6 +100,7 @@ function chainActionLabel(action: string, isZh: boolean) {
|
||||
|
||||
function sourceLabel(source: string, isZh: boolean) {
|
||||
if (source === 'substack') return 'Substack'
|
||||
if (source === 'blog') return 'Blog'
|
||||
if (source === 'podcast') return 'Podcast'
|
||||
if (source === 'twitter') return 'X'
|
||||
return source
|
||||
@@ -138,19 +139,20 @@ function DigestWidget({
|
||||
activeTicker,
|
||||
isZh,
|
||||
initialDigest = null,
|
||||
days,
|
||||
}: {
|
||||
onTickerClick: (ticker: string) => void
|
||||
activeTicker?: string | null
|
||||
isZh: boolean
|
||||
initialDigest?: KolDigest | null
|
||||
days: number
|
||||
}) {
|
||||
const [days, setDays] = useState<number>(7)
|
||||
const [data, setData] = useState<KolDigest | null>(initialDigest)
|
||||
const [loading, setLoading] = useState(initialDigest === null)
|
||||
const [err, setErr] = useState('')
|
||||
|
||||
useEffect(() => {
|
||||
if (initialDigest === null || days !== (initialDigest?.window_days ?? 7)) {
|
||||
if (initialDigest === null || days !== (initialDigest?.window_days ?? 30)) {
|
||||
setLoading(true)
|
||||
}
|
||||
swrFetch(
|
||||
@@ -160,64 +162,34 @@ function DigestWidget({
|
||||
fresh => setData(fresh),
|
||||
)
|
||||
.then(d => { setData(d); setErr('') })
|
||||
.catch(e => setErr(e instanceof Error ? e.message : (isZh ? '加载失败' : 'Failed to load digest')))
|
||||
.catch(e => setErr(e instanceof Error ? e.message : ('Failed to load digest')))
|
||||
.finally(() => setLoading(false))
|
||||
}, [days, initialDigest, isZh])
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
marginBottom: 16, padding: 'clamp(12px, 3vw, 18px)',
|
||||
borderRadius: 12, background: 'var(--surface)',
|
||||
border: '1px solid var(--line)',
|
||||
}}>
|
||||
<div style={{
|
||||
display: 'flex', justifyContent: 'space-between',
|
||||
alignItems: 'center', flexWrap: 'wrap', gap: 8, marginBottom: 12,
|
||||
}}>
|
||||
<div>
|
||||
<div style={{ fontSize: 10, color: 'var(--ink-3)',
|
||||
letterSpacing: 1, textTransform: 'uppercase',
|
||||
marginBottom: 2 }}>
|
||||
What KOLs are pushing now
|
||||
</div>
|
||||
<div style={{ fontSize: 13, color: 'var(--ink-2)' }}>
|
||||
{data
|
||||
? `${data.post_count} posts analysed · ${data.ticker_count} assets with repeat mentions`
|
||||
: 'Loading…'}
|
||||
</div>
|
||||
<div style={{ marginBottom: 10 }}>
|
||||
{/* Compact meta line — no header label needed, context is obvious */}
|
||||
{data && !loading && (
|
||||
<div style={{ fontSize: 12, color: 'var(--ink-4)', marginBottom: 8 }}>
|
||||
{data.post_count} posts · {data.ticker_count} assets
|
||||
</div>
|
||||
<div className="nav-tabs" style={{ background: 'var(--bg-sunk)' }}>
|
||||
{WINDOW_OPTIONS.map(daysOption => (
|
||||
<button
|
||||
key={daysOption}
|
||||
onClick={() => setDays(daysOption)}
|
||||
className={`nav-tab ${days === daysOption ? 'active' : ''}`}
|
||||
style={{ border: 'none', cursor: 'pointer', fontSize: 12 }}
|
||||
>
|
||||
{windowLabel(daysOption, isZh)}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
)}
|
||||
{loading && (
|
||||
<div style={{ padding: 16, textAlign: 'center', color: 'var(--ink-3)',
|
||||
fontSize: 12 }}>Loading…</div>
|
||||
<div style={{ padding: '8px 0', color: 'var(--ink-3)', fontSize: 12 }}>Loading…</div>
|
||||
)}
|
||||
{err && (
|
||||
<div style={{ padding: 12, color: '#dc2626', fontSize: 12 }}>{err}</div>
|
||||
)}
|
||||
{!loading && !err && data && data.tickers.length === 0 && (
|
||||
<div style={{ padding: 16, textAlign: 'center', color: 'var(--ink-3)',
|
||||
fontSize: 13 }}>
|
||||
No actionable calls in this window. Try a longer range.
|
||||
<div style={{ padding: '8px 0', color: 'var(--ink-3)', fontSize: 13 }}>
|
||||
No repeat mentions in this window.
|
||||
</div>
|
||||
)}
|
||||
{!loading && !err && data && data.tickers.length > 0 && (
|
||||
<div style={{
|
||||
display: 'grid',
|
||||
gridTemplateColumns: 'repeat(auto-fit, minmax(190px, 1fr))',
|
||||
gap: 10,
|
||||
gridTemplateColumns: 'repeat(auto-fit, minmax(170px, 1fr))',
|
||||
gap: 8,
|
||||
}}>
|
||||
{data.tickers.map(t => <DigestTickerChip
|
||||
key={t.ticker}
|
||||
@@ -267,7 +239,7 @@ function DigestTickerChip({
|
||||
aria-pressed={active}
|
||||
>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8, width: '100%' }}>
|
||||
<strong style={{ fontSize: 18, color: 'var(--ink-1)' }}>
|
||||
<strong style={{ fontSize: 18, color: 'var(--ink)' }}>
|
||||
{t.ticker}
|
||||
</strong>
|
||||
{active && (
|
||||
@@ -294,11 +266,10 @@ function DigestTickerChip({
|
||||
{actionLabel}
|
||||
</span>
|
||||
</div>
|
||||
<div style={{ fontSize: 12, color: 'var(--ink-2)', fontWeight: 600 }}>
|
||||
{digestSideCopy(t.side)}
|
||||
</div>
|
||||
{/* Compact: KOL count + handles in two lines, no "Bullish flow" copy
|
||||
(Long/Short label already conveys direction). */}
|
||||
<div style={{ fontSize: 12, color: 'var(--ink-3)' }}>
|
||||
{t.kol_count} KOL{t.kol_count !== 1 ? 's' : ''} · {(t.max_conviction * 100).toFixed(0)}% max conviction
|
||||
{t.kol_count} KOL{t.kol_count !== 1 ? 's' : ''} · {(t.max_conviction * 100).toFixed(0)}%
|
||||
</div>
|
||||
<div style={{
|
||||
fontSize: 11, color: 'var(--ink-3)',
|
||||
@@ -330,9 +301,11 @@ function WalletCheckWidget({
|
||||
initialChanges = null,
|
||||
initialItems = null,
|
||||
tickerFilter = null,
|
||||
days,
|
||||
}: {
|
||||
isZh: boolean
|
||||
dateLocale: string
|
||||
days: number
|
||||
initialDigest?: KolDigest | null
|
||||
initialChanges?: KolHoldingChange[] | null
|
||||
initialItems?: KolDivergence[] | null
|
||||
@@ -344,41 +317,48 @@ function WalletCheckWidget({
|
||||
const [loading, setLoading] = useState(
|
||||
initialDigest === null || initialChanges === null || initialItems === null,
|
||||
)
|
||||
const [days, setDays] = useState(7)
|
||||
// `days` now comes from the parent — no local state needed.
|
||||
|
||||
// genRef lets in-flight fetches detect they were superseded by a newer
|
||||
// days/filter change before writing back to state.
|
||||
const walletCheckGenRef = useRef(0)
|
||||
|
||||
useEffect(() => {
|
||||
const gen = ++walletCheckGenRef.current
|
||||
setLoading(true)
|
||||
Promise.all([
|
||||
swrFetch(
|
||||
`kol-digest-${days}`,
|
||||
15 * 60_000,
|
||||
() => getKolDigest(days),
|
||||
fresh => setDigest(fresh),
|
||||
fresh => { if (gen === walletCheckGenRef.current) setDigest(fresh) },
|
||||
),
|
||||
swrFetch(
|
||||
`kol-changes-${days}`,
|
||||
30 * 60_000,
|
||||
() => getKolChanges({ days }),
|
||||
fresh => setChanges(fresh.changes),
|
||||
fresh => { if (gen === walletCheckGenRef.current) setChanges(fresh.changes) },
|
||||
),
|
||||
swrFetch(
|
||||
`kol-divergence-all-${days}`,
|
||||
30 * 60_000,
|
||||
() => getKolDivergence({ days }),
|
||||
fresh => setItems(fresh.items),
|
||||
fresh => { if (gen === walletCheckGenRef.current) setItems(fresh.items) },
|
||||
),
|
||||
])
|
||||
.then(([nextDigest, nextChanges, nextItems]) => {
|
||||
if (gen !== walletCheckGenRef.current) return
|
||||
setDigest(nextDigest)
|
||||
setChanges(nextChanges.changes)
|
||||
setItems(nextItems.items)
|
||||
})
|
||||
.catch(() => {
|
||||
if (gen !== walletCheckGenRef.current) return
|
||||
setDigest(null)
|
||||
setChanges([])
|
||||
setItems([])
|
||||
})
|
||||
.finally(() => setLoading(false))
|
||||
.finally(() => { if (gen === walletCheckGenRef.current) setLoading(false) })
|
||||
}, [days])
|
||||
|
||||
const rows = useMemo(() => {
|
||||
@@ -458,43 +438,21 @@ function WalletCheckWidget({
|
||||
borderRadius: 12, background: 'var(--surface)',
|
||||
border: '1px solid var(--line)',
|
||||
}}>
|
||||
<div style={{
|
||||
display: 'flex', justifyContent: 'space-between',
|
||||
alignItems: 'flex-start', flexWrap: 'wrap', gap: 8, marginBottom: 12,
|
||||
}}>
|
||||
<div>
|
||||
<div style={{ fontSize: 10, color: 'var(--ink-3)', letterSpacing: 1,
|
||||
textTransform: 'uppercase', marginBottom: 2 }}>
|
||||
Talks vs wallets
|
||||
</div>
|
||||
<div style={{ fontSize: 13, color: 'var(--ink-2)' }}>
|
||||
{loading
|
||||
? 'Loading…'
|
||||
: rows.length === 0
|
||||
? 'No overlapping talk and wallet evidence in this window.'
|
||||
: `${totalAligned} aligned · ${totalMismatch} mismatched across the assets KOLs are pushing`}
|
||||
</div>
|
||||
{/* Compact summary — no uppercase header, no redundant label */}
|
||||
{!loading && rows.length > 0 && (
|
||||
<div style={{ fontSize: 12, color: 'var(--ink-4)', marginBottom: 10 }}>
|
||||
{totalAligned > 0 && <span style={{ color: '#22c55e', marginRight: 8 }}>✓ {totalAligned} aligned</span>}
|
||||
{totalMismatch > 0 && <span style={{ color: '#f59e0b' }}>⚠ {totalMismatch} mismatch</span>}
|
||||
{totalAligned === 0 && totalMismatch === 0 && 'Wallet evidence pending'}
|
||||
</div>
|
||||
<div className="nav-tabs" style={{ background: 'var(--bg-sunk)' }}>
|
||||
{([1, 7, 30] as const).map(d => (
|
||||
<button
|
||||
key={d}
|
||||
onClick={() => setDays(d)}
|
||||
className={`nav-tab ${days === d ? 'active' : ''}`}
|
||||
style={{ border: 'none', cursor: 'pointer', fontSize: 12 }}
|
||||
>
|
||||
{windowLabel(d, isZh)}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!loading && rows.length === 0 && (
|
||||
<div style={{
|
||||
padding: '12px 16px', borderRadius: 8, background: 'var(--bg-sunk)',
|
||||
fontSize: 12, color: 'var(--ink-3)', lineHeight: 1.6,
|
||||
}}>
|
||||
When KOLs call an asset, do tracked wallets back it up? No overlap yet in this window — widen the range or check back after the next feed run.
|
||||
No wallet overlap for this window — try a wider range.
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -521,7 +479,7 @@ function WalletCheckWidget({
|
||||
{row.verdict.label}
|
||||
</span>
|
||||
</div>
|
||||
<div style={{ fontSize: 13, color: 'var(--ink-1)', fontWeight: 600, marginBottom: 4 }}>
|
||||
<div style={{ fontSize: 13, color: 'var(--ink)', fontWeight: 600, marginBottom: 4 }}>
|
||||
{row.talkLine}
|
||||
</div>
|
||||
<div style={{ fontSize: 12, color: 'var(--ink-3)', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>
|
||||
@@ -533,10 +491,8 @@ function WalletCheckWidget({
|
||||
</div>
|
||||
|
||||
<div style={{ minWidth: 0 }}>
|
||||
<div style={{ fontSize: 11, color: 'var(--ink-3)', textTransform: 'uppercase', letterSpacing: 0.8, marginBottom: 5 }}>
|
||||
Wallet evidence
|
||||
</div>
|
||||
<div style={{ fontSize: 13, color: 'var(--ink-1)', fontWeight: 600, marginBottom: 4 }}>
|
||||
{/* No "WALLET EVIDENCE" label — context is clear from layout */}
|
||||
<div style={{ fontSize: 13, color: 'var(--ink)', fontWeight: 600, marginBottom: 4 }}>
|
||||
{row.latestMatch
|
||||
? `@${row.latestMatch.handle} ${chainActionLabel(row.latestMatch.onchain_action, isZh).toLowerCase()}`
|
||||
: row.latestChange
|
||||
@@ -544,9 +500,13 @@ function WalletCheckWidget({
|
||||
: 'No tracked move yet'}
|
||||
</div>
|
||||
<div style={{ fontSize: 12, color: 'var(--ink-3)', lineHeight: 1.5 }}>
|
||||
{row.latestMatch
|
||||
? `${row.verdict.note} ${row.latestMatch.usd_after ? `Size ${formatShortUsd(row.latestMatch.usd_after)}.` : ''}`
|
||||
: row.verdict.note}
|
||||
{/* Drop boilerplate "Wallet action supports/disagrees the public pitch." —
|
||||
the verdict badge already says Aligned / Mismatch. Just show the size. */}
|
||||
{row.latestMatch?.usd_after
|
||||
? `Size ${formatShortUsd(row.latestMatch.usd_after)}`
|
||||
: row.verdict.label === 'No wallet proof'
|
||||
? 'No tracked wallet move in this window'
|
||||
: ''}
|
||||
</div>
|
||||
{(row.divergenceCount > 0 || row.alignmentCount > 0) && (
|
||||
<div style={{ display: 'flex', gap: 8, flexWrap: 'wrap', marginTop: 6 }}>
|
||||
@@ -660,7 +620,7 @@ function PostDetail({
|
||||
margin: 0, fontSize: 'clamp(16px, 4.5vw, 22px)',
|
||||
lineHeight: 1.3, wordBreak: 'break-word',
|
||||
}}>
|
||||
{post.title || (isZh ? '(无标题)' : '(Untitled)')}
|
||||
{post.title || post.summary || (post.source === 'twitter' ? '(Tweet)' : '(Untitled)')}
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
@@ -679,7 +639,7 @@ function PostDetail({
|
||||
whiteSpace: 'nowrap',
|
||||
}}
|
||||
>
|
||||
{isZh ? `查看原帖 ${postSourceLabel}` : `Open original ${postSourceLabel}`} ↗
|
||||
{`Open original ${postSourceLabel}`} ↗
|
||||
</a>
|
||||
)}
|
||||
<button
|
||||
@@ -703,7 +663,7 @@ function PostDetail({
|
||||
}}>
|
||||
<div style={{ fontSize: 10, color: 'var(--ink-3)', marginBottom: 4,
|
||||
letterSpacing: 1, textTransform: 'uppercase' }}>
|
||||
{isZh ? 'AI 摘要' : 'AI summary'}
|
||||
{'AI summary'}
|
||||
</div>
|
||||
{post.summary}
|
||||
</div>
|
||||
@@ -714,7 +674,7 @@ function PostDetail({
|
||||
<div style={{ margin: '12px 0' }}>
|
||||
<div style={{ fontSize: 10, color: 'var(--ink-3)', marginBottom: 6,
|
||||
letterSpacing: 1, textTransform: 'uppercase' }}>
|
||||
{isZh ? '提取标的' : 'Extracted assets'}
|
||||
{'Extracted assets'}
|
||||
</div>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
|
||||
{post.tickers.map((t, i) => (
|
||||
@@ -729,7 +689,7 @@ function PostDetail({
|
||||
{actionLabel(t.action, isZh)}
|
||||
</span>
|
||||
<span style={{ fontSize: 11, color: 'var(--ink-3)' }}>
|
||||
{isZh ? '信心分' : 'Conviction'} {(t.conviction * 100).toFixed(0)}%
|
||||
{'Conviction'} {(t.conviction * 100).toFixed(0)}%
|
||||
</span>
|
||||
</div>
|
||||
<div style={{ fontSize: 12, color: 'var(--ink-2)',
|
||||
@@ -748,7 +708,7 @@ function PostDetail({
|
||||
}}>
|
||||
<div style={{ fontSize: 10, color: 'var(--ink-3)', marginBottom: 8,
|
||||
letterSpacing: 1, textTransform: 'uppercase' }}>
|
||||
{isZh ? '原文摘录' : 'Source excerpt'}
|
||||
{'Source excerpt'}
|
||||
</div>
|
||||
<div style={{
|
||||
whiteSpace: 'pre-wrap', fontSize: 13, lineHeight: 1.7,
|
||||
@@ -767,8 +727,12 @@ function PostDetail({
|
||||
return createPortal(node, document.body)
|
||||
}
|
||||
|
||||
type SourceFilter = 'all' | 'substack' | 'blog' | 'podcast' | 'twitter'
|
||||
const KOL_SERVER_PAGE_SIZE = 50
|
||||
|
||||
interface KolPageProps {
|
||||
initialPosts?: KolPostSummary[] | null
|
||||
initialTotal?: number
|
||||
initialDigest?: KolDigest | null
|
||||
initialChanges?: KolHoldingChange[] | null
|
||||
initialDivergence?: KolDivergence[] | null
|
||||
@@ -776,78 +740,142 @@ interface KolPageProps {
|
||||
|
||||
export default function KolPage({
|
||||
initialPosts = null,
|
||||
initialTotal = 0,
|
||||
initialDigest = null,
|
||||
initialChanges = null,
|
||||
initialDivergence = null,
|
||||
}: KolPageProps) {
|
||||
const locale = useLocale()
|
||||
const isZh = false // i18n shelved — Chinese branches kept as dead code for future revival; see messages/zh.json
|
||||
const dateLocale = isZh ? 'zh-CN' : 'en-US'
|
||||
const KOL_PAGE_SIZE = 20
|
||||
const [posts, setPosts] = useState<KolPostSummary[]>(initialPosts ?? [])
|
||||
const [loading, setLoading] = useState(initialPosts === null)
|
||||
const [err, setErr] = useState('')
|
||||
const [openPost, setOpenPost] = useState<KolPostDetail | null>(null)
|
||||
const [handleFilter, setHandleFilter] = useState<string>('all')
|
||||
const [tickerFilter, setTickerFilter] = useState<string | null>(null)
|
||||
const [kolPage, setKolPage] = useState(1)
|
||||
const dateLocale = 'en-US'
|
||||
const isZh = false // i18n shelved — passed to helper fns that still take the param
|
||||
const [posts, setPosts] = useState<KolPostSummary[]>(initialPosts ?? [])
|
||||
const [serverTotal, setServerTotal] = useState(initialTotal)
|
||||
const [loading, setLoading] = useState(initialPosts === null)
|
||||
const [err, setErr] = useState('')
|
||||
const [openPost, setOpenPost] = useState<KolPostDetail | null>(null)
|
||||
const [sourceFilter, setSourceFilter] = useState<SourceFilter>('all')
|
||||
const [signalsOnly, setSignalsOnly] = useState(false)
|
||||
const [tickerFilter, setTickerFilter] = useState<string | null>(null)
|
||||
const [serverPage, setServerPage] = useState(1)
|
||||
// Unified time window — controls both DigestWidget and WalletCheckWidget.
|
||||
// Default 30d, not 7d: KOL ingestion is daily and sparse, so a 7d window is
|
||||
// frequently empty (e.g. 7d=0 while 30d=196) and the first paint showed
|
||||
// "No data yet" for modules that actually have data.
|
||||
const [kolDays, setKolDays] = useState(30)
|
||||
|
||||
const postsGenRef = useRef(0)
|
||||
|
||||
useEffect(() => {
|
||||
const gen = ++postsGenRef.current
|
||||
setLoading(true)
|
||||
const src = sourceFilter === 'all' ? undefined : sourceFilter
|
||||
const cacheKey = `kol-posts-${sourceFilter}-${signalsOnly}-${serverPage}-${tickerFilter ?? ''}-${kolDays}`
|
||||
swrFetch(
|
||||
'kol-posts-100',
|
||||
cacheKey,
|
||||
15 * 60_000, // 15 min TTL — KOL feed is ingested daily
|
||||
() => getKolPosts({ limit: 100 }),
|
||||
fresh => setPosts(fresh.items),
|
||||
() => getKolPosts({
|
||||
limit: KOL_SERVER_PAGE_SIZE, page: serverPage, source: src, signalsOnly,
|
||||
ticker: tickerFilter ?? undefined, days: kolDays,
|
||||
}),
|
||||
fresh => { if (gen === postsGenRef.current) { setPosts(fresh.items); setServerTotal(fresh.total ?? 0) } },
|
||||
)
|
||||
.then(r => { setPosts(r.items); setErr('') })
|
||||
.catch(e => setErr(e instanceof Error ? e.message : (isZh ? '加载失败' : 'Failed to load posts')))
|
||||
.finally(() => setLoading(false))
|
||||
}, [isZh])
|
||||
.then(r => {
|
||||
if (gen !== postsGenRef.current) return
|
||||
setPosts(r.items); setServerTotal(r.total ?? 0); setErr('')
|
||||
})
|
||||
.catch(e => { if (gen === postsGenRef.current) setErr(e instanceof Error ? e.message : ('Failed to load posts')) })
|
||||
.finally(() => { if (gen === postsGenRef.current) setLoading(false) })
|
||||
}, [sourceFilter, signalsOnly, serverPage, tickerFilter, kolDays])
|
||||
|
||||
const handles = useMemo(() => {
|
||||
const set = new Set(posts.map(p => p.kol_handle))
|
||||
return ['all', ...Array.from(set)]
|
||||
}, [posts])
|
||||
// posts are already filtered server-side; no client-side re-filter needed
|
||||
const filtered = posts
|
||||
|
||||
const filtered = useMemo(() => {
|
||||
let out = handleFilter === 'all' ? posts : posts.filter(p => p.kol_handle === handleFilter)
|
||||
if (tickerFilter) {
|
||||
out = out.filter(p => p.tickers.some(t => t.ticker === tickerFilter))
|
||||
}
|
||||
return out
|
||||
}, [posts, handleFilter, tickerFilter])
|
||||
|
||||
const kolTotalPages = Math.max(1, Math.ceil(filtered.length / KOL_PAGE_SIZE))
|
||||
const kolSafePage = Math.min(kolPage, kolTotalPages)
|
||||
const kolPageItems = filtered.slice((kolSafePage - 1) * KOL_PAGE_SIZE, kolSafePage * KOL_PAGE_SIZE)
|
||||
const totalServerPages = Math.max(1, Math.ceil(serverTotal / KOL_SERVER_PAGE_SIZE))
|
||||
|
||||
async function openDetail(id: number) {
|
||||
try {
|
||||
const detail = await getKolPost(id)
|
||||
setOpenPost(detail)
|
||||
} catch (e) {
|
||||
setErr(e instanceof Error ? e.message : (isZh ? '详情加载失败' : 'Failed to load detail'))
|
||||
setErr(e instanceof Error ? e.message : ('Failed to load detail'))
|
||||
}
|
||||
}
|
||||
|
||||
function changeSource(src: SourceFilter) {
|
||||
setSourceFilter(src)
|
||||
setServerPage(1)
|
||||
setTickerFilter(null)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="page">
|
||||
<div className="page-head">
|
||||
<div>
|
||||
<h1 className="page-title">{isZh ? 'KOL 信号' : 'KOL Signals'}</h1>
|
||||
<PageHint count={`${posts.length} posts`}>
|
||||
Which assets KOLs are pushing right now — and whether tracked wallets back it up or call their bluff.
|
||||
<h1 className="page-title">{'KOL Signals'}</h1>
|
||||
<PageHint count={`${serverTotal} posts`}>
|
||||
Arthur Hayes, Delphi, Bankless, and 22 more — their public calls vs what their wallets actually do.
|
||||
</PageHint>
|
||||
</div>
|
||||
{/* Single time filter controlling both widgets */}
|
||||
<div className="nav-tabs" style={{ background: 'var(--bg-sunk)', alignSelf: 'flex-start' }}>
|
||||
{WINDOW_OPTIONS.map(d => (
|
||||
<button
|
||||
key={d}
|
||||
onClick={() => { setKolDays(d); setServerPage(1) }}
|
||||
className={`nav-tab ${kolDays === d ? 'active' : ''}`}
|
||||
style={{ border: 'none', cursor: 'pointer', fontSize: 12 }}
|
||||
>
|
||||
{windowLabel(d, isZh)}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Source filter — All / Substack / X + Signals only toggle */}
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 12, flexWrap: 'wrap' }}>
|
||||
{(['all', 'substack', 'blog', 'podcast', 'twitter'] as SourceFilter[]).map(src => {
|
||||
const label = src === 'all' ? 'All' : src === 'substack' ? 'Substack' : src === 'blog' ? 'Blog' : src === 'podcast' ? 'Podcast' : 'X (Twitter)'
|
||||
const active = sourceFilter === src
|
||||
return (
|
||||
<button
|
||||
key={src}
|
||||
onClick={() => changeSource(src)}
|
||||
style={{
|
||||
padding: '4px 12px', borderRadius: 6, fontSize: 12, fontWeight: 600,
|
||||
cursor: 'pointer', border: '1px solid var(--line)',
|
||||
background: active ? 'var(--amber)' : 'var(--surface)',
|
||||
color: active ? '#000' : 'var(--ink-2)',
|
||||
transition: 'background 0.15s, color 0.15s',
|
||||
}}
|
||||
>
|
||||
{label}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
<button
|
||||
onClick={() => { setSignalsOnly(v => !v); setServerPage(1) }}
|
||||
title="Exclude noise posts (short tweets, gm, RT). Long-form and directional posts are kept."
|
||||
style={{
|
||||
marginLeft: 8,
|
||||
padding: '4px 12px', borderRadius: 6, fontSize: 12, fontWeight: 600,
|
||||
cursor: 'pointer',
|
||||
border: `1px solid ${signalsOnly ? '#16a34a88' : 'var(--line)'}`,
|
||||
background: signalsOnly ? '#16a34a22' : 'var(--surface)',
|
||||
color: signalsOnly ? '#16a34a' : 'var(--ink-3)',
|
||||
transition: 'background 0.15s, color 0.15s, border-color 0.15s',
|
||||
}}
|
||||
>
|
||||
{signalsOnly ? '✓ Signals only' : 'Signals only'}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<DigestWidget
|
||||
isZh={isZh}
|
||||
initialDigest={initialDigest}
|
||||
activeTicker={tickerFilter}
|
||||
days={kolDays}
|
||||
onTickerClick={(sym) => {
|
||||
setTickerFilter(prev => prev === sym ? null : sym)
|
||||
setKolPage(1)
|
||||
setServerPage(1)
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -858,6 +886,7 @@ export default function KolPage({
|
||||
initialChanges={initialChanges}
|
||||
initialItems={initialDivergence}
|
||||
tickerFilter={tickerFilter}
|
||||
days={kolDays}
|
||||
/>
|
||||
|
||||
{tickerFilter && (
|
||||
@@ -865,47 +894,38 @@ export default function KolPage({
|
||||
display: 'flex', alignItems: 'center', gap: 8,
|
||||
marginBottom: 12, fontSize: 12,
|
||||
}}>
|
||||
<span style={{ color: 'var(--ink-3)' }}>{isZh ? '当前筛选标的:' : 'Filtered asset:'}</span>
|
||||
<span style={{ color: 'var(--ink-3)' }}>{'Filtered asset:'}</span>
|
||||
<strong>{tickerFilter}</strong>
|
||||
<button
|
||||
onClick={() => { setTickerFilter(null); setKolPage(1) }}
|
||||
onClick={() => { setTickerFilter(null); setServerPage(1) }}
|
||||
style={{
|
||||
background: 'var(--bg-sunk)', border: '1px solid var(--line)',
|
||||
borderRadius: 4, padding: '2px 8px',
|
||||
cursor: 'pointer', fontSize: 11, color: 'var(--ink-2)',
|
||||
}}
|
||||
>{isZh ? '清除 ✕' : 'Clear ✕'}</button>
|
||||
>{'Clear ✕'}</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{handles.length > 2 && (
|
||||
<div className="nav-tabs" style={{ background: 'var(--bg-sunk)', marginBottom: 12 }}>
|
||||
{handles.map(h => (
|
||||
<button
|
||||
key={h}
|
||||
onClick={() => { setHandleFilter(h); setKolPage(1) }}
|
||||
className={`nav-tab ${handleFilter === h ? 'active' : ''}`}
|
||||
style={{ border: 'none', cursor: 'pointer' }}
|
||||
>
|
||||
{h === 'all' ? (isZh ? `全部 (${posts.length})` : `All (${posts.length})`) : `@${h}`}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{/* KOL handle filter removed — 25 handles as a horizontal tab bar
|
||||
overflows on every screen size and most users filter by asset (ticker),
|
||||
not by person. Handle is visible on each post card. */}
|
||||
|
||||
<div style={{ margin: '12px 0 4px', fontSize: 11, fontWeight: 600, letterSpacing: '0.06em', textTransform: 'uppercase', color: 'var(--ink-4)' }}>
|
||||
All posts · paginated feed
|
||||
</div>
|
||||
|
||||
{loading && <KolPostsSkeleton />}
|
||||
{err && <div style={{ padding: 20, color: '#dc2626' }}>{isZh ? `错误:${err}` : `Error: ${err}`}</div>}
|
||||
{err && <div style={{ padding: 20, color: '#dc2626' }}>{`Error: ${err}`}</div>}
|
||||
|
||||
{!loading && !err && (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
|
||||
{filtered.length === 0 && (
|
||||
<div style={{ padding: 40, textAlign: 'center', color: 'var(--ink-3)' }}>
|
||||
{isZh
|
||||
? '当前没有数据,等待下一轮抓取任务(每天 01:15 UTC)。'
|
||||
: 'No data yet. Wait for the next feed ingestion run (daily 01:15 UTC).'}
|
||||
{'No data yet. Wait for the next feed ingestion run (daily 01:15 UTC).'}
|
||||
</div>
|
||||
)}
|
||||
{kolPageItems.map(p => (
|
||||
{filtered.map(p => (
|
||||
<div
|
||||
key={p.id}
|
||||
onClick={() => openDetail(p.id)}
|
||||
@@ -927,10 +947,44 @@ export default function KolPage({
|
||||
@{p.kol_handle} · {sourceLabel(p.source, isZh)} · {new Date(p.published_at).toLocaleDateString(dateLocale)}
|
||||
</div>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8, flexShrink: 0 }}>
|
||||
{p.tier === 'trade_signal' && (
|
||||
<span style={{
|
||||
fontSize: 10, fontWeight: 700, letterSpacing: '0.04em',
|
||||
padding: '2px 6px', borderRadius: 4,
|
||||
background: '#16a34a22', color: '#16a34a',
|
||||
border: '1px solid #16a34a44',
|
||||
whiteSpace: 'nowrap',
|
||||
}}>
|
||||
SIGNAL
|
||||
</span>
|
||||
)}
|
||||
{p.tier === 'directional' && (
|
||||
<span style={{
|
||||
fontSize: 10, fontWeight: 700, letterSpacing: '0.04em',
|
||||
padding: '2px 6px', borderRadius: 4,
|
||||
background: '#f59e0b22', color: '#f59e0b',
|
||||
border: '1px solid #f59e0b44',
|
||||
whiteSpace: 'nowrap',
|
||||
}}>
|
||||
VIEW
|
||||
</span>
|
||||
)}
|
||||
{p.talks_vs_trades_flag && (
|
||||
<span title="Public stance contradicts revealed position in this post"
|
||||
style={{
|
||||
fontSize: 10, fontWeight: 700,
|
||||
padding: '2px 6px', borderRadius: 4,
|
||||
background: '#ef444422', color: '#ef4444',
|
||||
border: '1px solid #ef444444',
|
||||
whiteSpace: 'nowrap',
|
||||
}}>
|
||||
⚠ FLIP
|
||||
</span>
|
||||
)}
|
||||
<span style={{ fontSize: 11, color: 'var(--ink-3)' }}>
|
||||
{p.analyzed_at
|
||||
? (isZh ? '✓ 已分析' : '✓ Analyzed')
|
||||
: (isZh ? '⏳ 待分析' : '⏳ Pending')}
|
||||
? ('✓ Analyzed')
|
||||
: ('⏳ Pending')}
|
||||
</span>
|
||||
{p.url && (
|
||||
<a
|
||||
@@ -946,16 +1000,17 @@ export default function KolPage({
|
||||
whiteSpace: 'nowrap',
|
||||
}}
|
||||
>
|
||||
{isZh ? '原帖 ↗' : 'Source ↗'}
|
||||
{'Source ↗'}
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div style={{ fontSize: 16, fontWeight: 600, marginBottom: 6,
|
||||
wordBreak: 'break-word' }}>
|
||||
{p.title || (isZh ? '(无标题)' : '(Untitled)')}
|
||||
{p.title || p.summary || (p.source === 'twitter' ? '(Tweet)' : '(Untitled)')}
|
||||
</div>
|
||||
{p.summary && (
|
||||
{/* Only show summary as a separate line when there's a real title above it */}
|
||||
{p.title && p.summary && (
|
||||
<div style={{ fontSize: 13, color: 'var(--ink-2)', lineHeight: 1.5,
|
||||
marginBottom: 8 }}>
|
||||
{p.summary}
|
||||
@@ -966,11 +1021,11 @@ export default function KolPage({
|
||||
))}
|
||||
|
||||
<Pagination
|
||||
page={kolSafePage}
|
||||
total={kolTotalPages}
|
||||
count={filtered.length}
|
||||
pageSize={KOL_PAGE_SIZE}
|
||||
onChange={setKolPage}
|
||||
page={serverPage}
|
||||
total={totalServerPages}
|
||||
count={serverTotal}
|
||||
pageSize={KOL_SERVER_PAGE_SIZE}
|
||||
onChange={setServerPage}
|
||||
scrollTop={false}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/** Instant skeleton while KolPage fetches posts and digest. */
|
||||
export default function KolLoading() {
|
||||
return (
|
||||
<div className="page">
|
||||
<div className="page-head" style={{ marginBottom: 24 }}>
|
||||
<div>
|
||||
<div className="skeleton sk-title" style={{ width: 140, marginBottom: 8 }} />
|
||||
<div className="skeleton sk-line" style={{ width: 260 }} />
|
||||
</div>
|
||||
</div>
|
||||
{Array.from({ length: 6 }).map((_, i) => (
|
||||
<div key={i} className="skeleton-card" style={{ marginBottom: 10, padding: 18 }}>
|
||||
<div style={{ display: 'flex', gap: 12, alignItems: 'center', marginBottom: 10 }}>
|
||||
<div className="skeleton" style={{ width: 36, height: 36, borderRadius: '50%', flexShrink: 0 }} />
|
||||
<div style={{ flex: 1 }}>
|
||||
<div className="skeleton sk-line" style={{ width: 120, marginBottom: 6 }} />
|
||||
<div className="skeleton sk-line-sm" style={{ width: 80 }} />
|
||||
</div>
|
||||
<div className="skeleton sk-line" style={{ width: 60 }} />
|
||||
</div>
|
||||
<div className="skeleton sk-line sk-w-full" style={{ marginBottom: 6 }} />
|
||||
<div className="skeleton sk-line sk-w-3q" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -19,8 +19,8 @@ export async function generateMetadata({
|
||||
return {
|
||||
title: isZh ? 'KOL 信号与言行偏离追踪' : 'KOL Signals & Talks-vs-Trades Divergence',
|
||||
description: isZh
|
||||
? '从 15 个加密 KOL 信息源中提取可执行观点,覆盖 Arthur Hayes、Delphi Digital、Bankless、Empire、Unchained 等,并追踪“说法”和链上仓位是否一致。'
|
||||
: 'AI-extracted crypto signals from 19 KOL feeds: Arthur Hayes, Delphi Digital, Bankless, Empire, Unchained and more. Includes talks-vs-trades divergence — when KOL wallets contradict their public posts.',
|
||||
? '从 25 个加密 KOL 信息源中提取可执行观点,覆盖 Arthur Hayes、Delphi Digital、Bankless、Empire、Unchained 等,并追踪“说法”和链上仓位是否一致。'
|
||||
: 'AI-extracted crypto signals from 25 KOL feeds: Arthur Hayes, Delphi Digital, Bankless, Empire, Unchained and more. Includes talks-vs-trades divergence — when KOL wallets contradict their public posts.',
|
||||
keywords: isZh
|
||||
? [
|
||||
'KOL 加密信号',
|
||||
@@ -48,7 +48,7 @@ export async function generateMetadata({
|
||||
title: isZh ? 'KOL 信号与言行偏离 | Trump Alpha' : 'KOL Signals & Talks-vs-Trades | Trump Alpha',
|
||||
description: isZh
|
||||
? '每天分析 KOL 长文、播客和公开观点,再与链上仓位交叉验证,找出真正有信息增量的观点与偏离。'
|
||||
: '19 KOL feeds (Hayes, Bankless, Empire…) AI-scored daily. Plus talks-vs-trades: when their wallets contradict their words.',
|
||||
: '25 KOL feeds (Hayes, Bankless, Empire…) AI-scored daily. Plus talks-vs-trades: when their wallets contradict their words.',
|
||||
},
|
||||
alternates: {
|
||||
canonical: `${siteUrl}/en/kol`,
|
||||
@@ -60,7 +60,7 @@ export async function generateMetadata({
|
||||
}
|
||||
}
|
||||
|
||||
// GEO: the KOL talks-vs-trades feed is a dataset cross-referencing 19 crypto
|
||||
// GEO: the KOL talks-vs-trades feed is a dataset cross-referencing 25 crypto
|
||||
// KOLs' public statements against their on-chain wallet behaviour.
|
||||
const kolDataset = {
|
||||
'@context': 'https://schema.org',
|
||||
@@ -68,7 +68,7 @@ const kolDataset = {
|
||||
'@id': `${siteUrl}/en/kol#dataset`,
|
||||
name: 'Crypto KOL talks-vs-trades divergence dataset',
|
||||
description:
|
||||
'Daily cross-reference of 19 crypto KOLs\' public statements (Substack / podcast) against their on-chain Ethereum wallet activity, flagging divergence when public stance and real positioning disagree within a ±7-day window.',
|
||||
'Daily cross-reference of 25 crypto KOLs\' public statements (Substack / podcast) against their on-chain Ethereum wallet activity, flagging divergence when public stance and real positioning disagree within a ±7-day window.',
|
||||
url: `${siteUrl}/en/kol`,
|
||||
keywords: ['crypto KOL', 'on-chain', 'divergence', 'wallet tracking', 'sentiment'],
|
||||
isAccessibleForFree: true,
|
||||
@@ -80,10 +80,13 @@ const kolDataset = {
|
||||
}
|
||||
|
||||
export default async function KolPage() {
|
||||
// days=30 must match the client default (KolPageClient kolDays=30) so the
|
||||
// SSR payload and first client render agree — otherwise content flashes on
|
||||
// mount. 7d is frequently empty while 30d has data.
|
||||
const [posts, digest, changes, divergence] = await Promise.all([
|
||||
getKolPosts({ limit: 100 }).catch(() => null),
|
||||
getKolDigest(7).catch(() => null),
|
||||
getKolChanges({ days: 7 }).catch(() => null),
|
||||
getKolPosts({ limit: 50, page: 1, days: 30 }).catch(() => null),
|
||||
getKolDigest(30).catch(() => null),
|
||||
getKolChanges({ days: 30 }).catch(() => null),
|
||||
getKolDivergence({ days: 30 }).catch(() => null),
|
||||
])
|
||||
|
||||
@@ -96,6 +99,7 @@ export default async function KolPage() {
|
||||
<Breadcrumbs items={[{ name: 'KOL talks-vs-trades', path: '/en/kol' }]} />
|
||||
<KolPageClient
|
||||
initialPosts={posts?.items ?? null}
|
||||
initialTotal={posts?.total ?? 0}
|
||||
initialDigest={digest}
|
||||
initialChanges={changes?.changes ?? null}
|
||||
initialDivergence={divergence?.items ?? null}
|
||||
|
||||
@@ -6,6 +6,7 @@ import Link from 'next/link'
|
||||
import { locales } from '@/i18n'
|
||||
import Providers from './Providers'
|
||||
import Navbar from '@/components/nav/Navbar'
|
||||
import TradeAlertBanner from '@/components/ui/TradeAlertBanner'
|
||||
|
||||
const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || 'https://trumpsignal.com'
|
||||
|
||||
@@ -46,6 +47,7 @@ export default async function LocaleLayout({ children, params }: LayoutProps) {
|
||||
<NextIntlClientProvider messages={messages}>
|
||||
<Providers>
|
||||
<Navbar />
|
||||
<TradeAlertBanner />
|
||||
<main>{children}</main>
|
||||
<footer style={{
|
||||
borderTop: '1px solid var(--line)',
|
||||
|
||||
@@ -9,7 +9,7 @@ import { swrFetch } from '@/lib/cache'
|
||||
import PostRow from '@/components/dashboard/PostCards'
|
||||
import SystemControl from '@/components/signals/SystemControl'
|
||||
import InfoTip from '@/components/ui/InfoTip'
|
||||
import PageHint from '@/components/ui/PageHint'
|
||||
import SignalMonitor from '@/components/dashboard/SignalMonitor'
|
||||
|
||||
// MacroPanel is 631 lines with heavy indicator math — split it out.
|
||||
const MacroPanel = dynamic(() => import('@/components/btc/MacroPanel'), {
|
||||
@@ -84,70 +84,63 @@ export default function MacroVibesPage({
|
||||
<div className="page">
|
||||
<div className="page-head">
|
||||
<div>
|
||||
<h1 className="page-title">{isZh ? '宏观氛围' : 'Macro Vibes'}</h1>
|
||||
{/* PageHint: brand tagline for the page — same across both tabs so
|
||||
the "what is this page" answer doesn't shift under the user when
|
||||
they click between Bottom / Funding. Tab-specific notes live in
|
||||
the section-hint card right below the tab bar. */}
|
||||
<PageHint>
|
||||
Macro vibes for crypto. Read what's about to happen before price prints it.
|
||||
</PageHint>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' }}>
|
||||
<h1 className="page-title" style={{ margin: 0 }}>{isZh ? '宏观氛围' : 'Macro Vibes'}</h1>
|
||||
<span style={{
|
||||
display: 'inline-flex', alignItems: 'center', gap: 4,
|
||||
padding: '2px 8px', borderRadius: 6, fontSize: 11, fontWeight: 700,
|
||||
background: 'var(--bg-sunk)',
|
||||
color: 'var(--ink-3)', border: '1px solid var(--line)',
|
||||
letterSpacing: '0.04em',
|
||||
}}>
|
||||
{isZh ? '手动开仓 · Bot 托管' : 'You open · bot manages'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<span className="chip"><span className="live-dot" />Live</span>
|
||||
</div>
|
||||
|
||||
<SystemControl system="btc" />
|
||||
|
||||
<div className="nav-tabs" style={{
|
||||
background: 'var(--bg-sunk)', marginTop: 16, marginBottom: 12,
|
||||
}}>
|
||||
<button
|
||||
onClick={() => setTab('bottom')}
|
||||
className={`nav-tab ${tab === 'bottom' ? 'active' : ''}`}
|
||||
style={{ border: 'none', cursor: 'pointer' }}
|
||||
>
|
||||
{isZh ? '周期底部' : 'Macro Bottom'}
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setTab('funding')}
|
||||
className={`nav-tab ${tab === 'funding' ? 'active' : ''}`}
|
||||
style={{ border: 'none', cursor: 'pointer' }}
|
||||
>
|
||||
{isZh ? '资金费率反转' : 'Funding Reversal'}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Always-visible per-tab explanation. Was hidden behind a hover
|
||||
tooltip on the tab button — users couldn't tell what they were
|
||||
about to look at until they explicitly hovered. */}
|
||||
{tab === 'bottom' && (
|
||||
<div className="section-hint">
|
||||
Fires when <strong>≥2 of 3</strong> classic bottom signals agree:{' '}
|
||||
<strong>AHR999 < 0.45</strong> · <strong>price ≤ 200-week MA</strong> · <strong>Pi Cycle Bottom</strong>.
|
||||
{' '}Long-only · 2–4 fires per cycle · trailing-stop exit · max hold ~18 months.
|
||||
{/* Tabs + inline description on the same row — avoids a separate
|
||||
"section hint" block that adds a third layer before the data. */}
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 16,
|
||||
flexWrap: 'wrap', marginTop: 14, marginBottom: 14 }}>
|
||||
<div className="nav-tabs" style={{ background: 'var(--bg-sunk)', flexShrink: 0 }}>
|
||||
<button
|
||||
onClick={() => setTab('bottom')}
|
||||
className={`nav-tab ${tab === 'bottom' ? 'active' : ''}`}
|
||||
style={{ border: 'none', cursor: 'pointer' }}
|
||||
>
|
||||
{isZh ? '周期底部' : 'Macro Bottom'}
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setTab('funding')}
|
||||
className={`nav-tab ${tab === 'funding' ? 'active' : ''}`}
|
||||
style={{ border: 'none', cursor: 'pointer' }}
|
||||
>
|
||||
{isZh ? '资金费率反转' : 'Funding Reversal'}
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
<span style={{ fontSize: 12, color: 'var(--ink-3)', lineHeight: 1.4 }}>
|
||||
{tab === 'bottom'
|
||||
? <><strong style={{ color: 'var(--ink-2)' }}>≥2 of 3:</strong> AHR999 < 0.45 · 200w MA · Pi Cycle Bottom — long-only, rare.</>
|
||||
: <>Fades crowded perps when 30d cumulative funding crosses <strong>±3%</strong> and cools. Hourly.</>}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Macro indicator panel — only relevant on the Macro Bottom tab where
|
||||
users are reasoning about the broader risk regime. The Funding tab
|
||||
has its own live funding panel below. */}
|
||||
{tab === 'bottom' && <MacroPanel />}
|
||||
{tab === 'funding' && (
|
||||
<div className="section-hint">
|
||||
Mean-reversion against crowded perp positioning. When 30-day cumulative funding crosses{' '}
|
||||
<strong>±3%</strong> and recent cycles start cooling, the scanner fades the crowded side.
|
||||
Checked hourly.
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Old plain-text per-tab description removed — the same content
|
||||
now lives in the section-hint block above the tab content. */}
|
||||
|
||||
{tab === 'funding' && (
|
||||
<FundingPanel
|
||||
isZh={isZh}
|
||||
initialSnapshot={initialFundingSnapshot}
|
||||
/>
|
||||
<>
|
||||
<FundingPanel
|
||||
isZh={isZh}
|
||||
initialSnapshot={initialFundingSnapshot}
|
||||
/>
|
||||
<SignalMonitor />
|
||||
</>
|
||||
)}
|
||||
|
||||
<div style={{ display: 'flex', gap: 6, flexWrap: 'wrap', margin: '16px 0 12px' }}>
|
||||
@@ -179,13 +172,11 @@ export default function MacroVibesPage({
|
||||
)}
|
||||
{!loading && !loadErr && filtered.length === 0 && (
|
||||
<div className="card" style={{ padding: 48, textAlign: 'center', color: 'var(--ink-3)' }}>
|
||||
{tab === 'bottom'
|
||||
? 'No macro-bottom signals yet.'
|
||||
: 'No funding-reversal signals yet.'}
|
||||
<div style={{ fontSize: 12, marginTop: 8 }}>
|
||||
{tab === 'bottom' ? 'No bottom signals yet.' : 'No funding signals yet.'}
|
||||
<div style={{ fontSize: 12, marginTop: 6 }}>
|
||||
{tab === 'bottom'
|
||||
? 'This scanner is intentionally rare — only fires at genuine macro bottoms (daily 00:45 UTC).'
|
||||
: 'Fires when 30-day cumulative funding exceeds ±3% AND starts mean-reverting. See the live panel above for current state.'}
|
||||
? 'Intentionally rare — fires only at genuine cycle bottoms.'
|
||||
: 'Check the live panel above for current funding state.'}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/** Instant skeleton while MacroVibesPage fetches indicator data. */
|
||||
export default function MacroLoading() {
|
||||
return (
|
||||
<div className="page">
|
||||
<div className="page-head" style={{ marginBottom: 24 }}>
|
||||
<div>
|
||||
<div className="skeleton sk-title" style={{ width: 160, marginBottom: 8 }} />
|
||||
<div className="skeleton sk-line" style={{ width: 300 }} />
|
||||
</div>
|
||||
</div>
|
||||
{/* Composite score card */}
|
||||
<div className="skeleton-card" style={{ marginBottom: 16, padding: 24 }}>
|
||||
<div className="skeleton sk-line" style={{ width: 120, marginBottom: 16 }} />
|
||||
<div className="skeleton" style={{ height: 48, width: 200, marginBottom: 16 }} />
|
||||
<div className="skeleton" style={{ height: 24, width: '100%', borderRadius: 12 }} />
|
||||
</div>
|
||||
{/* 8-indicator grid */}
|
||||
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: 12 }}>
|
||||
{Array.from({ length: 8 }).map((_, i) => (
|
||||
<div key={i} className="skeleton-card" style={{ padding: 20 }}>
|
||||
<div className="skeleton sk-line sk-w-half" style={{ marginBottom: 12 }} />
|
||||
<div className="skeleton" style={{ height: 36, width: 100, marginBottom: 8 }} />
|
||||
<div className="skeleton sk-line-sm sk-w-3q" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -64,7 +64,10 @@ export async function generateMetadata({
|
||||
|
||||
export default async function MacroVibesPage() {
|
||||
const [posts, fundingSnapshot] = await Promise.all([
|
||||
getPosts(500, 1).catch(() => null),
|
||||
// The default tab is the bottom-reversal view. Fetch only the source this
|
||||
// page actually renders on first paint instead of hydrating with the
|
||||
// latest global post firehose and filtering it client-side.
|
||||
getPosts(200, 1, 'btc_bottom_reversal').catch(() => null),
|
||||
getFundingSnapshot().catch(() => null),
|
||||
])
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ export async function generateMetadata({ params }: OverviewPageProps): Promise<M
|
||||
: 'Trump Alpha — Live Crypto Signal Desk'
|
||||
const description = isZh
|
||||
? 'Endorphin 研究台追踪四个先于市场共识的信号:Trump 帖子、BTC 宏观底部、资金费率极值,以及 KOL 言行偏离。每个信号公开且带时间戳。'
|
||||
: 'Endorphin tracks four signals that move crypto before the crowd: Trump posts, BTC macro bottoms, funding-rate extremes, and what KOLs do vs say. Public and timestamped.'
|
||||
: 'Endorphin tracks six signals that move crypto before the crowd: Trump posts, BTC macro bottoms, funding-rate extremes, KOL long-form calls, talks-vs-trades divergence, and the Breakout Monitor. Public and timestamped.'
|
||||
const path = `${siteUrl}/${locale}`
|
||||
|
||||
return {
|
||||
@@ -47,7 +47,9 @@ export async function generateMetadata({ params }: OverviewPageProps): Promise<M
|
||||
}
|
||||
|
||||
export default async function OverviewPage() {
|
||||
const posts = await getPosts(500, 1).catch(() => [])
|
||||
// The overview only renders a small curated slice on first paint; pulling
|
||||
// 500 posts here bloats the server payload without improving the initial UI.
|
||||
const posts = await getPosts(80, 1).catch(() => [])
|
||||
|
||||
return (
|
||||
<DashboardClient
|
||||
|
||||
@@ -1,183 +1,37 @@
|
||||
'use client'
|
||||
|
||||
import { useState, useEffect } from 'react'
|
||||
import dynamic from 'next/dynamic'
|
||||
import Link from 'next/link'
|
||||
import { usePathname } from 'next/navigation'
|
||||
import { useLocale } from 'next-intl'
|
||||
import { useAccount } from 'wagmi'
|
||||
import TelegramCard from '@/components/telegram/TelegramCard'
|
||||
import PageHint from '@/components/ui/PageHint'
|
||||
|
||||
// BotConfigPanel is 867 lines and only needed after wallet connect — lazy load it.
|
||||
import TelegramCard from '@/components/telegram/TelegramCard'
|
||||
|
||||
// BotConfigPanel is heavy and only needed after wallet connect — lazy load it.
|
||||
const BotConfigPanel = dynamic(() => import('@/components/trades/BotConfigPanel'), {
|
||||
ssr: false,
|
||||
loading: () => <div style={{ height: 200, background: 'var(--bg-sunk)', borderRadius: 12, marginBottom: 16 }} />,
|
||||
})
|
||||
|
||||
/**
|
||||
* Settings page — the home for all configuration.
|
||||
*
|
||||
* Previously the BotConfigPanel lived on /trades (alongside the trade history),
|
||||
* and /settings was just a redirect card. That made /trades double-duty
|
||||
* (configure AND view results) and /settings feel like a dead end. We swap:
|
||||
* - /settings → all configuration (bot, exchange key, subscription)
|
||||
* - /trades → pure execution view (open positions + history)
|
||||
* Legal links stay here since this is the "everything else" page.
|
||||
*/
|
||||
export default function SettingsClient() {
|
||||
const localeIntl = useLocale()
|
||||
const isZh = false // i18n shelved — Chinese branches kept as dead code for future revival; see messages/zh.json
|
||||
const { address, isConnected } = useAccount()
|
||||
const [mounted, setMounted] = useState(false)
|
||||
const pathname = usePathname()
|
||||
|
||||
useEffect(() => { setMounted(true) }, [])
|
||||
const locale = pathname.split('/')[1] || 'en'
|
||||
const href = (path: string) => `/${locale}${path}`
|
||||
const walletLabel = mounted && isConnected && address
|
||||
? `${address.slice(0, 6)}…${address.slice(-4)}`
|
||||
: 'Not connected'
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="settings-control-center">
|
||||
<div>
|
||||
<div className="settings-control-kicker">Control center</div>
|
||||
<div className="settings-control-title">One place to arm, limit, and verify the bot</div>
|
||||
<div className="settings-control-copy">
|
||||
Arm the bot, set per-system risk limits, and configure Telegram alerts — all in one place.
|
||||
</div>
|
||||
</div>
|
||||
<div className="settings-control-meta">
|
||||
<div className="settings-meta-card">
|
||||
<span className="settings-meta-label">Wallet</span>
|
||||
<strong className="mono">{walletLabel}</strong>
|
||||
</div>
|
||||
<div className="settings-meta-card">
|
||||
<span className="settings-meta-label">Private data</span>
|
||||
<strong>{mounted && isConnected ? 'Ready to unlock' : 'Connect first'}</strong>
|
||||
</div>
|
||||
<div className="settings-meta-card">
|
||||
<span className="settings-meta-label">Main actions</span>
|
||||
<strong>Load settings, save limits, link API</strong>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="settings-scope-intro">
|
||||
<PageHint>
|
||||
Your account's full control surface — subscription, Hyperliquid API key, risk limits, and alert delivery.
|
||||
</PageHint>
|
||||
<div style={{ fontSize: 12, color: 'var(--ink-3)', marginTop: 8 }}>
|
||||
Trump drives entries · Macro Vibes manages BTC · Global limits apply to both.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="settings-scope-grid" style={{ marginBottom: 16 }}>
|
||||
<section id="trump-settings" className="settings-scope-card trump">
|
||||
<div className="settings-scope-eyebrow">Trump Signal</div>
|
||||
<div className="settings-scope-title">Event-driven entry settings</div>
|
||||
<div className="settings-scope-copy">
|
||||
Position size, Trump leverage, and minimum AI confidence used when a Truth Social post becomes actionable.
|
||||
</div>
|
||||
<a href="#config-trump" className="settings-scope-link">Configure Trump ↓</a>
|
||||
</section>
|
||||
|
||||
<section id="macro-settings" className="settings-scope-card btc">
|
||||
<div className="settings-scope-eyebrow">Macro Vibes</div>
|
||||
<div className="settings-scope-title">BTC manage-only settings</div>
|
||||
<div className="settings-scope-copy">
|
||||
Strategy mode, BTC leverage, and de-risk targets for the Macro Vibes system.
|
||||
</div>
|
||||
<a href="#config-macro" className="settings-scope-link">Configure Macro Vibes ↓</a>
|
||||
</section>
|
||||
|
||||
<section id="global-settings" className="settings-scope-card global">
|
||||
<div className="settings-scope-eyebrow">Global</div>
|
||||
<div className="settings-scope-title">Account-wide execution controls</div>
|
||||
<div className="settings-scope-copy">
|
||||
Subscription plan, Hyperliquid API key, trading schedule, and guardrails that apply to both systems.
|
||||
</div>
|
||||
<a href="#config-global" className="settings-scope-link">Configure global ↓</a>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
{/* Account card — quick "who am I logged in as" */}
|
||||
<div className="card" style={{ padding: 20, marginBottom: 16 }}>
|
||||
<div style={{ fontSize: 11, fontWeight: 600, letterSpacing: '0.06em',
|
||||
textTransform: 'uppercase', color: 'var(--ink-3)', marginBottom: 8 }}>
|
||||
{isZh ? '账户' : 'Account'}
|
||||
</div>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
|
||||
<div style={{
|
||||
width: 32, height: 32, borderRadius: 8,
|
||||
background: mounted && isConnected ? 'var(--up-soft)' : 'var(--bg-sunk)',
|
||||
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
||||
color: mounted && isConnected ? 'var(--up)' : 'var(--ink-4)', fontSize: 14,
|
||||
}}>
|
||||
{mounted && isConnected ? '✓' : '○'}
|
||||
</div>
|
||||
<div>
|
||||
<div style={{ fontSize: 13, fontWeight: 500 }}>
|
||||
{mounted && isConnected && address
|
||||
? <span className="mono">{address.slice(0, 10)}…{address.slice(-8)}</span>
|
||||
: (isZh ? '未连接' : 'Not connected')}
|
||||
</div>
|
||||
<div style={{ fontSize: 11, color: 'var(--ink-4)' }}>
|
||||
{mounted && isConnected ? (isZh ? '钱包是下方所有配置的身份入口' : 'Wallet is the access key for everything below') : (isZh ? '连接钱包后才能配置机器人' : 'Connect a wallet to configure the bot')}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="bot-config" className="settings-section-shell">
|
||||
<div className="settings-section-head">
|
||||
<div>
|
||||
<div className="settings-section-kicker">Execution setup</div>
|
||||
<div className="settings-section-title">Trading permissions and risk controls</div>
|
||||
</div>
|
||||
<div className="settings-section-note">
|
||||
Load once, then adjust by module without leaving the page.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* The full bot config UI (subscribe, HL key, risk settings, schedule) */}
|
||||
<div id="bot-config">
|
||||
<BotConfigPanel />
|
||||
</div>
|
||||
|
||||
<div className="settings-section-shell">
|
||||
<div className="settings-section-head">
|
||||
<div>
|
||||
<div className="settings-section-kicker">Delivery</div>
|
||||
<div className="settings-section-title">Telegram alerts</div>
|
||||
</div>
|
||||
<div className="settings-section-note">
|
||||
Set up Telegram alerts once the bot is live.
|
||||
</div>
|
||||
</div>
|
||||
<div style={{ marginTop: 8 }}>
|
||||
<TelegramCard />
|
||||
</div>
|
||||
|
||||
<div className="settings-section-shell">
|
||||
<div className="settings-section-head">
|
||||
<div>
|
||||
<div className="settings-section-kicker">Support</div>
|
||||
<div className="settings-section-title">Legal and contact</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Legal & support */}
|
||||
<div className="card" style={{ padding: 20 }}>
|
||||
<div style={{ fontSize: 11, fontWeight: 600, letterSpacing: '0.06em',
|
||||
textTransform: 'uppercase', color: 'var(--ink-3)', marginBottom: 12 }}>
|
||||
{isZh ? '法律与支持' : 'Legal & support'}
|
||||
</div>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
|
||||
<Link href={href('/privacy')} style={{ fontSize: 13, color: 'var(--ink-2)', textDecoration: 'none' }}>{isZh ? '隐私政策 →' : 'Privacy Policy →'}</Link>
|
||||
<Link href={href('/terms')} style={{ fontSize: 13, color: 'var(--ink-2)', textDecoration: 'none' }}>{isZh ? '服务条款 →' : 'Terms of Service →'}</Link>
|
||||
<Link href={href('/contact')} style={{ fontSize: 13, color: 'var(--ink-2)', textDecoration: 'none' }}>{isZh ? '联系我们 →' : 'Contact Us →'}</Link>
|
||||
</div>
|
||||
<div className="card" style={{ padding: '14px 20px', marginTop: 8 }}>
|
||||
<div style={{ display: 'flex', gap: 20, flexWrap: 'wrap' }}>
|
||||
<Link href={href('/privacy')} style={{ fontSize: 13, color: 'var(--ink-3)', textDecoration: 'none' }}>Privacy Policy →</Link>
|
||||
<Link href={href('/terms')} style={{ fontSize: 13, color: 'var(--ink-3)', textDecoration: 'none' }}>Terms →</Link>
|
||||
<Link href={href('/contact')} style={{ fontSize: 13, color: 'var(--ink-3)', textDecoration: 'none' }}>Contact →</Link>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/** Instant skeleton while SettingsPage loads. */
|
||||
export default function SettingsLoading() {
|
||||
return (
|
||||
<div className="page">
|
||||
<div className="page-head" style={{ marginBottom: 24 }}>
|
||||
<div className="skeleton sk-title" style={{ width: 120, marginBottom: 8 }} />
|
||||
</div>
|
||||
{Array.from({ length: 3 }).map((_, i) => (
|
||||
<div key={i} className="skeleton-card" style={{ marginBottom: 14, padding: 24 }}>
|
||||
<div className="skeleton sk-line" style={{ width: 160, marginBottom: 18 }} />
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 14 }}>
|
||||
{Array.from({ length: 3 }).map((_, j) => (
|
||||
<div key={j} style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
||||
<div>
|
||||
<div className="skeleton sk-line" style={{ width: 140, marginBottom: 6 }} />
|
||||
<div className="skeleton sk-line-sm" style={{ width: 200 }} />
|
||||
</div>
|
||||
<div className="skeleton" style={{ width: 72, height: 32, borderRadius: 8 }} />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -5,8 +5,8 @@ import Link from 'next/link'
|
||||
import { usePathname } from 'next/navigation'
|
||||
import { useLocale } from 'next-intl'
|
||||
import { useAccount, useSignMessage } from 'wagmi'
|
||||
import type { BotTrade, TrumpPost } from '@/types'
|
||||
import { getTrades, getPosts } from '@/lib/api'
|
||||
import type { BotTrade } from '@/types'
|
||||
import { getTrades, getUserPublic } from '@/lib/api'
|
||||
import { useDashboardStore } from '@/store/dashboard'
|
||||
import { getCachedViewEnvelope, getOrCreateViewEnvelope, type SignedEnvelope } from '@/lib/signedRequest'
|
||||
import TradeTable from '@/components/trades/TradeTable'
|
||||
@@ -18,13 +18,13 @@ export default function TradesPageClient() {
|
||||
const isZh = false // i18n shelved — Chinese branches kept as dead code for future revival; see messages/zh.json
|
||||
const { address, isConnected } = useAccount()
|
||||
const { signMessageAsync } = useSignMessage()
|
||||
const { isSubscribed, hlApiKeySet } = useDashboardStore()
|
||||
const { isSubscribed, hlApiKeySet, paperMode,
|
||||
setSubscribed, setHlApiKeySet, setPaperMode, setBotReadiness } = useDashboardStore()
|
||||
const pathname = usePathname()
|
||||
const locale = pathname.split('/')[1] || 'en'
|
||||
|
||||
const [mounted, setMounted] = useState(false)
|
||||
const [trades, setTrades] = useState<BotTrade[]>([])
|
||||
const [posts, setPosts] = useState<TrumpPost[]>([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [loadErr, setLoadErr] = useState('')
|
||||
const [needsUnlock, setNeedsUnlock] = useState(false)
|
||||
@@ -37,41 +37,77 @@ export default function TradesPageClient() {
|
||||
return () => { aliveRef.current = false }
|
||||
}, [])
|
||||
|
||||
// genRef guards loadAll against stale-closure wallet-switch races.
|
||||
// `snapAddr !== address` inside an async function compares two copies of
|
||||
// the same closure-captured value — it's always equal even when the wallet
|
||||
// has changed, so the check is a no-op. genRef is a mutable ref that every
|
||||
// closure can read, so `gen !== genRef.current` correctly detects staleness.
|
||||
const genRef = useRef(0)
|
||||
useEffect(() => { genRef.current++ }, [address])
|
||||
|
||||
// B41: TradesPageClient can be the entry point (direct navigation to /trades)
|
||||
// without DashboardClient or BotConfigPanel ever running. In that case the
|
||||
// Zustand store has isSubscribed=false (initial default), causing the
|
||||
// "Bot not configured" banner to appear for valid subscribers.
|
||||
// Fix: fetch /user/{wallet}/public here too — it's lightweight, unauthenticated,
|
||||
// and idempotent with the same fetch DashboardClient does.
|
||||
useEffect(() => {
|
||||
if (!address || !isConnected) return
|
||||
let cancelled = false
|
||||
const snap = address
|
||||
getUserPublic(snap.toLowerCase())
|
||||
.then(u => {
|
||||
if (cancelled || snap !== address) return
|
||||
setSubscribed(u.active)
|
||||
setHlApiKeySet(u.hl_api_key_set)
|
||||
setBotReadiness(u.hl_api_key_set ? 'saved' : 'unknown')
|
||||
setPaperMode(!!u.paper_mode)
|
||||
})
|
||||
.catch(() => {})
|
||||
return () => { cancelled = true }
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [address, isConnected])
|
||||
|
||||
// Load public posts always; load private trades only if we have a view
|
||||
// envelope. `forcedEnv` lets the in-page Unlock button pass a freshly-minted
|
||||
// one so the user never has to detour through the Settings page first.
|
||||
async function loadAll(forcedEnv?: SignedEnvelope) {
|
||||
if (!address || !isConnected) {
|
||||
setTrades([]); setPosts([]); setLoading(false); setLoadErr(''); setNeedsUnlock(false)
|
||||
setTrades([]); setLoading(false); setLoadErr(''); setNeedsUnlock(false)
|
||||
return
|
||||
}
|
||||
const gen = genRef.current
|
||||
const snapAddr = address // for API calls only — NOT for stale detection
|
||||
setLoading(true)
|
||||
const env = forcedEnv
|
||||
?? getCachedViewEnvelope('view_trades', address)
|
||||
?? getCachedViewEnvelope('view_user', address)
|
||||
?? getCachedViewEnvelope('view_trades', snapAddr)
|
||||
?? getCachedViewEnvelope('view_user', snapAddr)
|
||||
let failed = false
|
||||
try {
|
||||
const [t, p] = await Promise.all([
|
||||
env
|
||||
? getTrades(address, env, 100, 1).catch(e => {
|
||||
failed = true
|
||||
setLoadErr(e instanceof Error ? e.message : 'Failed to load trades')
|
||||
return [] as BotTrade[]
|
||||
})
|
||||
: Promise.resolve([] as BotTrade[]),
|
||||
getPosts(500, 1).catch(() => [] as TrumpPost[]),
|
||||
])
|
||||
if (!aliveRef.current) return
|
||||
const t = env
|
||||
? await getTrades(snapAddr, env, 500, 1).catch(e => {
|
||||
failed = true
|
||||
setLoadErr(e instanceof Error ? e.message : 'Failed to load trades')
|
||||
return [] as BotTrade[]
|
||||
})
|
||||
: []
|
||||
// Use genRef — NOT `snapAddr !== address` (stale closure: both are the
|
||||
// same closed-over value and the comparison is always false).
|
||||
if (!aliveRef.current || gen !== genRef.current) return
|
||||
setTrades(t)
|
||||
setPosts(p)
|
||||
setNeedsUnlock(!env)
|
||||
if (env && !failed) setLoadErr('')
|
||||
} finally {
|
||||
if (aliveRef.current) setLoading(false)
|
||||
if (aliveRef.current && gen === genRef.current) setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
// B27/B35: clear stale previous-wallet data BEFORE the async fetch so the
|
||||
// UI never briefly shows another wallet's private trades.
|
||||
setTrades([])
|
||||
setNeedsUnlock(false)
|
||||
setLoadErr('')
|
||||
// On navigation we only use a cached envelope — never auto-popup the
|
||||
// wallet. If none is cached the user unlocks explicitly via the button.
|
||||
void loadAll()
|
||||
@@ -84,8 +120,12 @@ export default function TradesPageClient() {
|
||||
setUnlocking(true)
|
||||
setLoadErr('')
|
||||
try {
|
||||
// view_user is a superset accepted by /trades, /positions/open,
|
||||
// /positions/today — one signature unlocks everything on this page.
|
||||
// Previously view_trades was used here, but that left OpenPositions
|
||||
// locked (it requires view_positions or view_user).
|
||||
const env = await getOrCreateViewEnvelope({
|
||||
action: 'view_trades', wallet: address, signMessageAsync,
|
||||
action: 'view_user', wallet: address, signMessageAsync,
|
||||
})
|
||||
await loadAll(env)
|
||||
} catch (e) {
|
||||
@@ -97,7 +137,14 @@ export default function TradesPageClient() {
|
||||
}
|
||||
}
|
||||
|
||||
const needsSetup = mounted && isConnected && (!isSubscribed || !hlApiKeySet)
|
||||
// B40: paper users have no HL key but the bot IS configured for them — don't
|
||||
// show "Bot not configured" just because hlApiKeySet is false.
|
||||
// B41: on cold start (navigating directly to /trades), isSubscribed starts
|
||||
// false in the store until DashboardClient or BotConfigPanel fetches
|
||||
// /user/public. Guard with !loading so the banner only appears once
|
||||
// the page has confirmed the wallet is genuinely unconfigured.
|
||||
const needsSetup = mounted && isConnected && !loading &&
|
||||
(!isSubscribed || (!hlApiKeySet && !paperMode))
|
||||
|
||||
return (
|
||||
<div className="page">
|
||||
@@ -105,8 +152,7 @@ export default function TradesPageClient() {
|
||||
<div>
|
||||
<h1 className="page-title">{isZh ? '交易执行' : 'Trades'}</h1>
|
||||
<PageHint>
|
||||
What the bot actually did with your money — currently-open positions
|
||||
on top, closed-trade history with realized P&L below.
|
||||
Open positions above · closed trade history with realized P&L below.
|
||||
</PageHint>
|
||||
</div>
|
||||
</div>
|
||||
@@ -163,7 +209,7 @@ export default function TradesPageClient() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
<TradeTable trades={trades} posts={posts} loading={loading} />
|
||||
<TradeTable trades={trades} loading={loading} locked={needsUnlock} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -34,10 +34,11 @@ const tradesDataset = {
|
||||
'@id': `${siteUrl}/en/trades#dataset`,
|
||||
name: 'Trump Alpha trade execution history',
|
||||
description:
|
||||
'Record of every signal-triggered trade: asset, direction, entry and exit price, realised P&L, hold time, and the source signal that triggered it. Public and timestamped.',
|
||||
'Per-wallet record of signal-triggered trades: asset, direction, entry and exit price, realised P&L, hold time, and the triggering signal. Private to each wallet owner — wallet signature required to view.',
|
||||
url: `${siteUrl}/en/trades`,
|
||||
keywords: ['crypto trading track record', 'Hyperliquid', 'P&L', 'backtest', 'signal performance'],
|
||||
isAccessibleForFree: true,
|
||||
keywords: ['crypto trading track record', 'Hyperliquid', 'P&L', 'signal performance'],
|
||||
// Data is private (wallet-signed access), not freely accessible to the public
|
||||
isAccessibleForFree: false,
|
||||
creator: { '@type': 'Organization', name: 'Endorphin', url: siteUrl },
|
||||
publisher: { '@id': `${siteUrl}/#org` },
|
||||
license: `${siteUrl}/en/terms`,
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
'use client'
|
||||
|
||||
import { useState, useEffect, useMemo } from 'react'
|
||||
import { useLocale } from 'next-intl'
|
||||
import { useState, useEffect, useMemo, useRef } from 'react'
|
||||
import type { TrumpPost } from '@/types'
|
||||
import { getPosts } from '@/lib/api'
|
||||
import { swrFetch } from '@/lib/cache'
|
||||
import { getPosts, getPostsPage, type PostListResponse } from '@/lib/api'
|
||||
import { hasCached, swrFetch } from '@/lib/cache'
|
||||
import PostRow, { isAiScored } from '@/components/dashboard/PostCards'
|
||||
import SystemControl from '@/components/signals/SystemControl'
|
||||
import PageHint from '@/components/ui/PageHint'
|
||||
@@ -18,62 +17,147 @@ type SentimentFilter = (typeof SENTIMENTS)[number]
|
||||
type SignalFilter = 'all' | 'actionable' | 'buy' | 'short'
|
||||
|
||||
interface TrumpSignalPageProps {
|
||||
initialPosts?: TrumpPost[] | null
|
||||
initialData?: PostListResponse | null
|
||||
}
|
||||
|
||||
export default function TrumpSignalPage({ initialPosts = null }: TrumpSignalPageProps) {
|
||||
const locale = useLocale()
|
||||
const isZh = false
|
||||
const [posts, setPosts] = useState<TrumpPost[]>(initialPosts ?? [])
|
||||
const [loading, setLoading] = useState(initialPosts === null)
|
||||
const EMPTY_COUNTS: PostListResponse['counts'] = {
|
||||
all: 0,
|
||||
actionable: 0,
|
||||
buy: 0,
|
||||
short: 0,
|
||||
off_topic: 0,
|
||||
}
|
||||
|
||||
function matchesBaseFilters(post: TrumpPost, sentFilter: SentimentFilter, hideNoise: boolean) {
|
||||
if (hideNoise && !isAiScored(post)) return false
|
||||
if (sentFilter !== 'all' && post.sentiment !== sentFilter) return false
|
||||
return true
|
||||
}
|
||||
|
||||
function matchesSignalFilter(post: TrumpPost, sigFilter: SignalFilter) {
|
||||
if (sigFilter === 'actionable') return post.signal === 'buy' || post.signal === 'short'
|
||||
if (sigFilter === 'buy') return post.signal === 'buy'
|
||||
if (sigFilter === 'short') return post.signal === 'short'
|
||||
return true
|
||||
}
|
||||
|
||||
function buildLocalCounts(
|
||||
posts: TrumpPost[],
|
||||
sentFilter: SentimentFilter,
|
||||
hideNoise: boolean,
|
||||
): PostListResponse['counts'] {
|
||||
const sentimentScoped = posts.filter(p => sentFilter === 'all' || p.sentiment === sentFilter)
|
||||
const base = sentimentScoped.filter(p => matchesBaseFilters(p, sentFilter, hideNoise))
|
||||
|
||||
return {
|
||||
all: base.length,
|
||||
actionable: base.filter(p => p.signal === 'buy' || p.signal === 'short').length,
|
||||
buy: base.filter(p => p.signal === 'buy').length,
|
||||
short: base.filter(p => p.signal === 'short').length,
|
||||
off_topic: sentimentScoped.filter(p => !isAiScored(p)).length,
|
||||
}
|
||||
}
|
||||
|
||||
export default function TrumpSignalPage({ initialData = null }: TrumpSignalPageProps) {
|
||||
const [posts, setPosts] = useState<TrumpPost[]>(initialData?.items ?? [])
|
||||
const [totalPosts, setTotalPosts] = useState(initialData?.total ?? 0)
|
||||
const [counts, setCounts] = useState<PostListResponse['counts']>(initialData?.counts ?? EMPTY_COUNTS)
|
||||
const [loading, setLoading] = useState(initialData === null)
|
||||
const [loadErr, setLoadErr] = useState('')
|
||||
const [sentFilter, setSentFilter] = useState<SentimentFilter>('all')
|
||||
const [sigFilter, setSigFilter] = useState<SignalFilter>('all')
|
||||
const [hideNoise, setHideNoise] = useState(false)
|
||||
const [page, setPage] = useState(1)
|
||||
const [serverPaging, setServerPaging] = useState(true)
|
||||
|
||||
// Tracks whether we already have any rows on screen, WITHOUT putting
|
||||
// posts.length in the effect deps (which would re-run the effect on every
|
||||
// setPosts and fire a redundant fetch). Updated after each load below.
|
||||
const hasRowsRef = useRef((initialData?.items?.length ?? 0) > 0)
|
||||
|
||||
useEffect(() => {
|
||||
const filters = {
|
||||
// Don't apply the sentiment bias when a directional signal filter is
|
||||
// active — Buy/Short/Actionable already imply direction, and combining
|
||||
// them with a sentiment filter produces confusing empty results.
|
||||
// sentFilter is intentionally NOT reset when the user switches tabs so
|
||||
// their preference is preserved if they switch back to 'all'.
|
||||
sentiment: sentFilter === 'all' || sigFilter !== 'all' ? undefined : sentFilter,
|
||||
signal: sigFilter === 'all' ? undefined : sigFilter,
|
||||
aiScoredOnly: hideNoise,
|
||||
} as const
|
||||
// sentFilter only participates in the key when sigFilter is 'all' — it's
|
||||
// ignored by the query otherwise, so caching it in the key would create
|
||||
// phantom cache entries that never match on the way back.
|
||||
const effectiveSent = sigFilter === 'all' ? sentFilter : 'all'
|
||||
const key = `posts-truth-page-${page}-sent-${effectiveSent}-sig-${sigFilter}-noise-${hideNoise ? '1' : '0'}`
|
||||
const legacyKey = 'posts-truth-legacy-500'
|
||||
setLoadErr('')
|
||||
setLoading(!hasRowsRef.current && !hasCached(key) && !hasCached(legacyKey))
|
||||
|
||||
swrFetch(
|
||||
'posts-500',
|
||||
key,
|
||||
3 * 60_000,
|
||||
() => getPosts(500, 1),
|
||||
fresh => setPosts(fresh),
|
||||
() => getPostsPage(PAGE_SIZE, page, 'truth', filters),
|
||||
fresh => {
|
||||
setPosts(fresh.items)
|
||||
setTotalPosts(fresh.total)
|
||||
setCounts(fresh.counts)
|
||||
hasRowsRef.current = fresh.items.length > 0
|
||||
},
|
||||
)
|
||||
.then(p => { setPosts(p); setLoadErr('') })
|
||||
.catch(e => setLoadErr(e instanceof Error ? e.message : 'Failed to load posts'))
|
||||
.then(r => {
|
||||
setPosts(r.items)
|
||||
setTotalPosts(r.total)
|
||||
setCounts(r.counts)
|
||||
setServerPaging(true)
|
||||
setLoadErr('')
|
||||
hasRowsRef.current = r.items.length > 0
|
||||
})
|
||||
.catch(async e => {
|
||||
const detail = e instanceof Error ? e.message : 'Failed to load posts'
|
||||
if (!detail.includes('404')) {
|
||||
setLoadErr(detail)
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
// Legacy fallback (old backend without /posts-paged). Pull the
|
||||
// largest window the /posts endpoint allows (le=500) so client-side
|
||||
// pagination below has the full set to slice — 200 silently dropped
|
||||
// older matching posts once the truth feed grew past one page.
|
||||
const legacyPosts = await swrFetch(
|
||||
legacyKey,
|
||||
3 * 60_000,
|
||||
() => getPosts(500, 1, 'truth'),
|
||||
)
|
||||
const localCounts = buildLocalCounts(legacyPosts, sentFilter, hideNoise)
|
||||
setPosts(legacyPosts)
|
||||
setTotalPosts(localCounts.all)
|
||||
setCounts(localCounts)
|
||||
setServerPaging(false)
|
||||
setLoadErr('')
|
||||
hasRowsRef.current = legacyPosts.length > 0
|
||||
} catch (legacyErr) {
|
||||
setLoadErr(legacyErr instanceof Error ? legacyErr.message : detail)
|
||||
}
|
||||
})
|
||||
.finally(() => setLoading(false))
|
||||
}, [])
|
||||
}, [page, sentFilter, sigFilter, hideNoise])
|
||||
|
||||
const trumpPosts = useMemo(
|
||||
() => posts.filter(p => (p.source || '') === 'truth'),
|
||||
[posts],
|
||||
const filtered = useMemo(
|
||||
() => serverPaging
|
||||
? posts
|
||||
: posts.filter(p => matchesBaseFilters(p, sentFilter, hideNoise) && matchesSignalFilter(p, sigFilter)),
|
||||
[hideNoise, posts, sentFilter, serverPaging, sigFilter],
|
||||
)
|
||||
|
||||
const noiseCount = useMemo(
|
||||
() => trumpPosts.filter(p => !isAiScored(p)).length,
|
||||
[trumpPosts],
|
||||
)
|
||||
|
||||
const filtered = useMemo(() => trumpPosts.filter(p => {
|
||||
if (hideNoise && !isAiScored(p)) return false
|
||||
if (sentFilter !== 'all' && p.sentiment !== sentFilter) return false
|
||||
if (sigFilter === 'actionable' && p.signal !== 'buy' && p.signal !== 'short') return false
|
||||
if (sigFilter === 'buy' && p.signal !== 'buy') return false
|
||||
if (sigFilter === 'short' && p.signal !== 'short') return false
|
||||
return true
|
||||
}), [trumpPosts, sentFilter, sigFilter, hideNoise])
|
||||
|
||||
const totalPages = Math.max(1, Math.ceil(filtered.length / PAGE_SIZE))
|
||||
const noiseCount = counts.off_topic
|
||||
const totalPages = Math.max(1, Math.ceil(totalPosts / PAGE_SIZE))
|
||||
const safePage = Math.min(page, totalPages)
|
||||
const pageItems = filtered.slice((safePage - 1) * PAGE_SIZE, safePage * PAGE_SIZE)
|
||||
|
||||
const sigCounts = useMemo(() => ({
|
||||
all: trumpPosts.length,
|
||||
actionable: trumpPosts.filter(p => p.signal === 'buy' || p.signal === 'short').length,
|
||||
buy: trumpPosts.filter(p => p.signal === 'buy').length,
|
||||
short: trumpPosts.filter(p => p.signal === 'short').length,
|
||||
}), [trumpPosts])
|
||||
const pageItems = serverPaging
|
||||
? posts
|
||||
: filtered.slice((safePage - 1) * PAGE_SIZE, safePage * PAGE_SIZE)
|
||||
|
||||
const signalLabels: Record<SignalFilter, string> = {
|
||||
all: 'All', actionable: 'Actionable', buy: 'Buy', short: 'Short',
|
||||
@@ -86,10 +170,25 @@ export default function TrumpSignalPage({ initialPosts = null }: TrumpSignalPage
|
||||
<div className="page">
|
||||
<div className="page-head">
|
||||
<div>
|
||||
<h1 className="page-title">① Trump Signal</h1>
|
||||
<PageHint count={`${sigCounts.actionable} actionable / ${trumpPosts.length} posts`}>
|
||||
Watches Trump's Truth Social posts in real time, AI-scores each one,
|
||||
and only fires a trade when conviction is high enough to move the market.
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' }}>
|
||||
<h1 className="page-title" style={{ margin: 0 }}>Trump Signal</h1>
|
||||
<span style={{
|
||||
display: 'inline-flex', alignItems: 'center', gap: 4,
|
||||
padding: '2px 8px', borderRadius: 6, fontSize: 11, fontWeight: 700,
|
||||
background: 'color-mix(in oklab, var(--up) 12%, transparent)',
|
||||
color: 'var(--up)', border: '1px solid color-mix(in oklab, var(--up) 25%, transparent)',
|
||||
letterSpacing: '0.04em',
|
||||
}}>
|
||||
⚡ Auto-trade
|
||||
</span>
|
||||
</div>
|
||||
<PageHint count={
|
||||
sigFilter === 'buy' ? `${counts.buy} buy signals`
|
||||
: sigFilter === 'short' ? `${counts.short} short signals`
|
||||
: sigFilter === 'actionable' ? `${counts.actionable} actionable signals`
|
||||
: `${counts.actionable} actionable / ${counts.all} posts`
|
||||
}>
|
||||
Every Truth Social post scored in <3s. Trades only when conviction clears the threshold.
|
||||
</PageHint>
|
||||
</div>
|
||||
<span className="chip"><span className="live-dot" />Live</span>
|
||||
@@ -112,56 +211,74 @@ export default function TrumpSignalPage({ initialPosts = null }: TrumpSignalPage
|
||||
<button
|
||||
key={f.key}
|
||||
className={`nav-tab ${sigFilter === f.key ? 'active' : ''}`}
|
||||
onClick={() => { setSigFilter(f.key); setPage(1) }}
|
||||
onClick={() => {
|
||||
setSigFilter(f.key)
|
||||
setPage(1)
|
||||
// sentFilter is intentionally NOT reset here — the user's
|
||||
// bias preference is preserved so it's still active when
|
||||
// they switch back to 'all'. The query layer ignores
|
||||
// sentFilter whenever sigFilter is directional.
|
||||
}}
|
||||
>
|
||||
{f.key === 'actionable' ? '🔥 ' : ''}
|
||||
{signalLabels[f.key]}
|
||||
<span style={{ color: 'var(--ink-4)', marginLeft: 4 }}>{sigCounts[f.key]}</span>
|
||||
{signalLabels[f.key]}{' '}
|
||||
<span style={{ color: 'var(--ink-4)' }}>{counts[f.key]}</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Sentiment filter */}
|
||||
<div style={{ display: 'flex', gap: 6, flexWrap: 'wrap', alignItems: 'center' }}>
|
||||
{/* One-click collapse of off-topic (non-crypto, un-scored) posts. */}
|
||||
{noiseCount > 0 && (
|
||||
<button
|
||||
onClick={() => { setHideNoise(v => !v); setPage(1) }}
|
||||
title={`Show only crypto-relevant posts — hides ${noiseCount} off-topic Trump posts`}
|
||||
style={{
|
||||
padding: '4px 10px', borderRadius: 6,
|
||||
border: '1px solid var(--line)',
|
||||
background: hideNoise ? 'var(--ink)' : 'transparent',
|
||||
color: hideNoise ? 'var(--bg)' : 'var(--ink-3)',
|
||||
fontSize: 11, cursor: 'pointer', fontWeight: 600,
|
||||
marginRight: 4,
|
||||
}}
|
||||
>
|
||||
{hideNoise ? 'Show all' : 'Signals only'}
|
||||
</button>
|
||||
)}
|
||||
<span style={{ fontSize: 11, color: 'var(--ink-4)', marginRight: 4 }}>
|
||||
Bias
|
||||
<InfoTip
|
||||
text="Filters by the post's directional bias (bullish / bearish / neutral). Bias ≠ trade signal — a bearish post can still be a BUY if the market reads it as priced-in."
|
||||
placement="left"
|
||||
/>
|
||||
</span>
|
||||
{SENTIMENTS.map(f => (
|
||||
<button
|
||||
key={f}
|
||||
onClick={() => { setSentFilter(f); setPage(1) }}
|
||||
style={{
|
||||
padding: '4px 10px', borderRadius: 6, border: '1px solid var(--line)',
|
||||
background: sentFilter === f ? 'var(--ink)' : 'transparent',
|
||||
color: sentFilter === f ? 'var(--bg)' : 'var(--ink-3)',
|
||||
fontSize: 11, cursor: 'pointer', fontWeight: sentFilter === f ? 600 : 400,
|
||||
}}
|
||||
>
|
||||
{sentimentLabels[f]}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
{/* Sentiment + noise filters — hidden when a directional filter is
|
||||
already active (actionable / buy / short), because:
|
||||
- "buy" already implies bullish direction
|
||||
- "short" already implies bearish direction
|
||||
- "actionable" = buy ∪ short — sentiment adds no further info
|
||||
Showing them would create confusing combinations (e.g. Buy + Bearish
|
||||
returns 0 results with no explanation). */}
|
||||
{sigFilter === 'all' && (
|
||||
<div style={{ display: 'flex', gap: 6, flexWrap: 'wrap', alignItems: 'center' }}>
|
||||
{/* One-click collapse of off-topic (non-crypto, un-scored) posts.
|
||||
Hidden when a sentiment filter is active — Bullish/Bearish/Neutral
|
||||
results are all AI-scored by definition, so there are no off-topic
|
||||
posts to hide and the button would be meaningless. */}
|
||||
{(noiseCount > 0 || hideNoise) && sentFilter === 'all' && (
|
||||
<button
|
||||
onClick={() => { setHideNoise(v => !v); setPage(1) }}
|
||||
title={`Show only crypto-relevant posts — hides ${noiseCount} off-topic Trump posts`}
|
||||
style={{
|
||||
padding: '4px 10px', borderRadius: 6,
|
||||
border: '1px solid var(--line)',
|
||||
background: hideNoise ? 'var(--ink)' : 'transparent',
|
||||
color: hideNoise ? 'var(--bg)' : 'var(--ink-3)',
|
||||
fontSize: 11, cursor: 'pointer', fontWeight: 600,
|
||||
marginRight: 4,
|
||||
}}
|
||||
>
|
||||
{hideNoise ? 'Show all' : 'Signals only'}
|
||||
</button>
|
||||
)}
|
||||
<span style={{ fontSize: 11, color: 'var(--ink-4)', marginRight: 4 }}>
|
||||
Bias
|
||||
<InfoTip
|
||||
text="Filters by the post's directional bias (bullish / bearish / neutral). Bias ≠ trade signal — a bearish post can still be a BUY if the market reads it as priced-in."
|
||||
placement="left"
|
||||
/>
|
||||
</span>
|
||||
{SENTIMENTS.map(f => (
|
||||
<button
|
||||
key={f}
|
||||
onClick={() => { setSentFilter(f); setPage(1) }}
|
||||
style={{
|
||||
padding: '4px 10px', borderRadius: 6, border: '1px solid var(--line)',
|
||||
background: sentFilter === f ? 'var(--ink)' : 'transparent',
|
||||
color: sentFilter === f ? 'var(--bg)' : 'var(--ink-3)',
|
||||
fontSize: 11, cursor: 'pointer', fontWeight: sentFilter === f ? 600 : 400,
|
||||
}}
|
||||
>
|
||||
{sentimentLabels[f]}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{loading && <TrumpSkeleton />}
|
||||
@@ -176,7 +293,7 @@ export default function TrumpSignalPage({ initialPosts = null }: TrumpSignalPage
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!loading && !loadErr && filtered.length === 0 && (
|
||||
{!loading && !loadErr && totalPosts === 0 && (
|
||||
<div className="card" style={{ padding: 48, textAlign: 'center', color: 'var(--ink-3)' }}>
|
||||
No Trump signals match the current filter.
|
||||
</div>
|
||||
@@ -191,7 +308,7 @@ export default function TrumpSignalPage({ initialPosts = null }: TrumpSignalPage
|
||||
<Pagination
|
||||
page={safePage}
|
||||
total={totalPages}
|
||||
count={filtered.length}
|
||||
count={totalPosts}
|
||||
pageSize={PAGE_SIZE}
|
||||
onChange={setPage}
|
||||
/>
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { getPosts } from '@/lib/api'
|
||||
import { type PostListResponse } from '@/lib/api'
|
||||
import type { Metadata } from 'next'
|
||||
import TrumpPageClient from './TrumpPageClient'
|
||||
import Breadcrumbs from '@/components/seo/Breadcrumbs'
|
||||
import { getInitialPostPage } from '@/lib/postPage'
|
||||
|
||||
const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || 'https://trumpsignal.com'
|
||||
export const revalidate = 30
|
||||
@@ -75,7 +76,10 @@ const trumpDataset = {
|
||||
}
|
||||
|
||||
export default async function TrumpPage() {
|
||||
const posts = await getPosts(500, 1).catch(() => null)
|
||||
const initialData: PostListResponse | null = await getInitialPostPage(30, 1, {
|
||||
source: 'truth',
|
||||
legacyFallbackSource: 'truth',
|
||||
})
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -84,7 +88,7 @@ export default async function TrumpPage() {
|
||||
dangerouslySetInnerHTML={{ __html: JSON.stringify(trumpDataset) }}
|
||||
/>
|
||||
<Breadcrumbs items={[{ name: 'Trump signals', path: '/en/trump' }]} />
|
||||
<TrumpPageClient initialPosts={posts} />
|
||||
<TrumpPageClient initialData={initialData} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user