import { useState } from "react"; import { cn } from "~/lib/utils"; import { TrendingUp, TrendingDown, ExternalLink, Filter, Star, Clock, DollarSign, Wallet, } from "lucide-react"; import { Button } from "@/routes/ui/button"; import { ChainIcon } from "../components/shared/ChainIcon"; export interface WhaleTransaction { /** Transaction ID */ id: string; /** Token symbol */ tokenSymbol: string; /** Token name */ tokenName?: string; /** Blockchain chain */ chain: string; /** Transaction type */ type: "buy" | "sell"; /** Amount in USD */ amountUSD: number; /** Amount in tokens */ amountTokens: string; /** Wallet address */ walletAddress: string; /** Transaction hash */ txHash: string; /** When the transaction occurred */ timestamp: Date; /** Whether this is a smart money wallet */ isSmartMoney?: boolean; /** Whether this token is in user's watchlist */ isInWatchlist?: boolean; } export interface WhaleActivityFeedProps { /** List of whale transactions */ transactions: WhaleTransaction[]; /** Callback when transaction is clicked */ onTransactionClick?: (tx: WhaleTransaction) => void; /** Callback when "Track Wallet" is clicked */ onTrackWallet?: (walletAddress: string) => void; /** Callback when "View on Explorer" is clicked */ onViewExplorer?: (txHash: string, chain: string) => void; /** Additional class names */ className?: string; } /** * WhaleActivityFeed - Display whale transactions (large buys/sells >$10K) * * Features: * - Real-time feed of large transactions * - Filter by watchlist tokens or all tokens * - Smart money wallet indicators * - Quick links to block explorer * - Track wallet functionality */ export function WhaleActivityFeed({ transactions, onTransactionClick, onTrackWallet, onViewExplorer, className, }: WhaleActivityFeedProps) { const [filter, setFilter] = useState<"all" | "watchlist" | "smart_money">("all"); // Filter transactions based on selected filter const filteredTransactions = transactions.filter((tx) => { if (filter === "watchlist") return tx.isInWatchlist; if (filter === "smart_money") return tx.isSmartMoney; return true; }); const formatTimeAgo = (date: Date) => { const seconds = Math.floor((new Date().getTime() - date.getTime()) / 1000); if (seconds < 60) return `${seconds}s ago`; const minutes = Math.floor(seconds / 60); if (minutes < 60) return `${minutes}m ago`; const hours = Math.floor(minutes / 60); if (hours < 24) return `${hours}h ago`; return `${Math.floor(hours / 24)}d ago`; }; const formatAmount = (amount: number) => { if (amount >= 1000000) return `$${(amount / 1000000).toFixed(2)}M`; if (amount >= 1000) return `$${(amount / 1000).toFixed(1)}K`; return `$${amount.toFixed(0)}`; }; const shortenAddress = (address: string) => { return `${address.slice(0, 6)}...${address.slice(-4)}`; }; return (
{/* Header */}
🐋

Whale Activity

{filteredTransactions.length} transactions

{/* Filter tabs */}
{/* Transaction feed */}
{filteredTransactions.length === 0 ? (
🐋

No whale activity detected yet

Large transactions (>$10K) will appear here

) : (
{filteredTransactions.map((tx) => (
onTransactionClick?.(tx)} > {/* Time and smart money badge */}
{formatTimeAgo(tx.timestamp)}
{tx.isSmartMoney && (
⚠️ Smart Money
)}
{/* Transaction type and amount */}
{tx.type === "buy" ? (
BUY
) : (
SELL
)} {formatAmount(tx.amountUSD)} {tx.tokenSymbol}
{/* Token amount */}
Amount: {tx.amountTokens} tokens
{/* Wallet address */}
{shortenAddress(tx.walletAddress)}
{/* Action buttons */}
{!tx.isSmartMoney && ( )}
))}
)}
{/* Footer info */}
Monitoring transactions >$10K Updates every 1 min
); }