Price ({quote})
diff --git a/frontend/src/components/mobile-disclaimer.tsx b/frontend/src/components/mobile-disclaimer.tsx
deleted file mode 100644
index adb7df8..0000000
--- a/frontend/src/components/mobile-disclaimer.tsx
+++ /dev/null
@@ -1,21 +0,0 @@
-import { useState } from "react";
-import { X } from "lucide-react";
-import { Button } from "./ui/button";
-
-export function MobileDisclaimer() {
- const [dismissed, setDismissed] = useState(false);
-
- if (dismissed) return null;
-
- return (
-
-
- For the best experience, please use a desktop or tablet. Mobile layout is basic and may not
- display all features correctly.
-
-
setDismissed(true)} aria-label="Dismiss">
-
-
-
- );
-}
diff --git a/frontend/src/components/nav-main.tsx b/frontend/src/components/nav-main.tsx
deleted file mode 100644
index e9da14c..0000000
--- a/frontend/src/components/nav-main.tsx
+++ /dev/null
@@ -1,46 +0,0 @@
-import type { LucideIcon } from "lucide-react";
-import { NavLink } from "react-router-dom";
-import {
- SidebarGroup,
- SidebarGroupContent,
- SidebarMenu,
- SidebarMenuButton,
- SidebarMenuItem,
-} from "@/components/ui/sidebar";
-
-export type DashboardNavItem = {
- title: string;
- url: string;
- icon: LucideIcon;
- end?: boolean;
-};
-
-export function NavMain({ items }: { items: DashboardNavItem[] }) {
- return (
-
-
-
- {items.map((item) => (
-
-
- {({ isActive }) => (
-
-
-
- {item.title}
-
-
- )}
-
-
- ))}
-
-
-
- );
-}
diff --git a/frontend/src/components/nav-user.tsx b/frontend/src/components/nav-user.tsx
deleted file mode 100644
index d1a89c0..0000000
--- a/frontend/src/components/nav-user.tsx
+++ /dev/null
@@ -1,86 +0,0 @@
-import { ChevronsUpDown, KeyRound, LogOut, UserRound } from "lucide-react";
-import { Link, useNavigate } from "react-router-dom";
-import { toast } from "sonner";
-import { Avatar, AvatarFallback } from "@/components/ui/avatar";
-import {
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuSeparator,
- DropdownMenuTrigger,
-} from "@/components/ui/dropdown-menu";
-import {
- SidebarMenu,
- SidebarMenuButton,
- SidebarMenuItem,
- useSidebar,
-} from "@/components/ui/sidebar";
-import { useAuth } from "@/context/AuthContext";
-import { api } from "@/lib/api";
-
-export function NavUser() {
- const { user, setUser } = useAuth();
- const { isMobile } = useSidebar();
- const navigate = useNavigate();
-
- if (!user) return null;
-
- const handleLogout = async () => {
- try {
- await api.signout();
- } catch (error) {
- console.error("Signout failed:", error);
- } finally {
- setUser(null);
- toast.success("Logged out successfully");
- navigate("/");
- }
- };
-
- return (
-
-
-
-
-
-
-
- {user.name.slice(0, 1).toUpperCase()}
-
-
-
- {user.name}
- {user.email}
-
-
-
-
-
-
-
- Profile
-
-
-
-
- API keys
-
-
-
-
- Log out
-
-
-
-
-
- );
-}
diff --git a/frontend/src/components/navbar.tsx b/frontend/src/components/navbar.tsx
index 5022f94..107202d 100644
--- a/frontend/src/components/navbar.tsx
+++ b/frontend/src/components/navbar.tsx
@@ -1,22 +1,29 @@
-import { Link, useNavigate } from "react-router-dom";
-import { Button } from "./ui/button";
+import { useState } from "react";
+import { Link, useLocation, useNavigate } from "react-router-dom";
import {
- Menu,
- X,
- Sun,
- Moon,
- User,
- LogOut,
- LayoutDashboard,
- KeyRound,
+ ArrowRight,
+ ArrowUpRight,
+ BarChart3,
+ BookOpenText,
+ ChartCandlestick,
ChevronDown,
+ Database,
+ House,
+ KeyRound,
+ LogOut,
MailCheck,
+ Menu,
+ Moon,
+ Sun,
+ Trophy,
+ UserRound,
+ WalletCards,
+ X,
} from "lucide-react";
-import { useTheme } from "../lib/theme-provider";
-import { BrandLogo } from "@/components/brand-logo";
-import { useAuth } from "@/context/AuthContext";
-import { api } from "@/lib/api";
import { toast } from "sonner";
+import { Avatar, AvatarFallback } from "@/components/ui/avatar";
+import { BrandLogo } from "@/components/brand-logo";
+import { Button } from "@/components/ui/button";
import {
DropdownMenu,
DropdownMenuContent,
@@ -24,272 +31,684 @@ import {
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
-} from "./ui/dropdown-menu";
-import { Avatar, AvatarFallback } from "./ui/avatar";
-import { Sheet, SheetClose, SheetContent, SheetTitle, SheetTrigger } from "./ui/sheet";
-
-const NAV_LINKS = [
- { label: "Markets", to: "/markets" },
- { label: "Trading", to: "/trade/BTC_USD" },
- { label: "Leaderboard", to: "/leaderboard" },
- { label: "Docs", to: "/docs" },
- { label: "Dashboard", to: "/dashboard" },
-];
+} from "@/components/ui/dropdown-menu";
+import { NavigationLink } from "@/components/navigation-link";
+import { Sheet, SheetClose, SheetContent, SheetTitle, SheetTrigger } from "@/components/ui/sheet";
+import { Skeleton } from "@/components/ui/skeleton";
+import { useAuth } from "@/context/AuthContext";
+import { usePortfolio } from "@/hooks/use-portfolio";
+import { useLastTradePath } from "@/hooks/use-ux-preferences";
+import { api } from "@/lib/api";
+import { accountNavigation, getPrimaryNavigation } from "@/lib/navigation";
+import { useTheme } from "@/lib/theme-provider";
+import type { Portfolio } from "@/types";
+import { formatPrice } from "@/utils/format";
+
+const accountIcons = {
+ home: House,
+ portfolio: WalletCards,
+ activity: Database,
+ "api-keys": KeyRound,
+ profile: UserRound,
+};
+
+const accountDescriptions = {
+ home: "Account overview",
+ portfolio: "Balances and performance",
+ activity: "Open orders and trade history",
+ "api-keys": "Connect your trading bot",
+ profile: "Profile and account settings",
+};
+
+const primaryNavigationMeta = {
+ trading: { description: "Open the live terminal", icon: ChartCandlestick },
+ markets: { description: "Browse tradable pairs", icon: BarChart3 },
+ leaderboard: { description: "View global rankings", icon: Trophy },
+ docs: { description: "Build with the API", icon: BookOpenText },
+};
+
+type BalanceSnapshot = {
+ available: string | null;
+ balance: string | null;
+ returnValue: string | null;
+};
+
+function getBalanceSnapshot(portfolio: Portfolio | null): BalanceSnapshot {
+ if (!portfolio) {
+ return { available: null, balance: null, returnValue: null };
+ }
+
+ const quotePosition = portfolio.positions.find(
+ (position) => position.asset === portfolio.quoteAsset,
+ );
+ const returnNumber = Number(portfolio.pnlPercent);
+
+ return {
+ available: quotePosition
+ ? `${formatPrice(quotePosition.available)} ${portfolio.quoteAsset}`
+ : null,
+ balance: `${formatPrice(portfolio.equity)} ${portfolio.quoteAsset}`,
+ returnValue: Number.isFinite(returnNumber)
+ ? `${returnNumber > 0 ? "+" : ""}${returnNumber.toFixed(2)}%`
+ : null,
+ };
+}
export function Navbar() {
const { theme, toggleTheme } = useTheme();
- const { user, verified, setUser } = useAuth();
+ const { user, verified, loading: authLoading, setUser } = useAuth();
+ const { portfolio, loading: portfolioLoading } = usePortfolio({ enabled: Boolean(user) });
+ const [loggingOut, setLoggingOut] = useState(false);
+ const location = useLocation();
const navigate = useNavigate();
+ const lastTradePath = useLastTradePath();
+ const primaryNavigation = getPrimaryNavigation(lastTradePath);
+ const returnTo = `${location.pathname}${location.search}${location.hash}`;
+ const balance = getBalanceSnapshot(portfolio);
const handleLogout = async () => {
+ if (loggingOut) return;
+ setLoggingOut(true);
try {
await api.signout();
- } catch (err) {
- console.error("Signout failed:", err);
+ } catch (error) {
+ console.error("Signout failed:", error);
} finally {
setUser(null);
toast.success("Logged out successfully");
- navigate("/");
+ navigate("/", { replace: true });
+ setLoggingOut(false);
}
};
return (
-
-
-
+
+
+
-
- {NAV_LINKS.map((link) => (
-
+ {primaryNavigation.map((item) => (
+
- {link.label}
-
+ {item.label}
+
))}
-
-
-
-
-
-
-
+
+
+ {authLoading ? (
+ <>
+
+
+ >
+ ) : user ? (
+ <>
+
+
+
+
+ >
+ ) : (
+ <>
+
+
+
+ Sign in
+
+
+
+
+ Start trading
+
+
+ >
+ )}
+
-
- Navigation
+ {user ? : null}
-
-
-
-
+
+
+
+
+ );
+}
+
+function ThemeButton({ theme, onToggle }: { theme: "light" | "dark"; onToggle: () => void }) {
+ return (
+
+ {theme === "dark" ? : }
+
+ );
+}
-
-
-
-
-
+function DesktopBalance({ balance, loading }: { balance: string | null; loading: boolean }) {
+ return (
+
+ Balance
+ {loading ? (
+
+ ) : (
+
+ {balance ?? "Unavailable"}
+
+ )}
+
+ );
+}
+
+function MobileBalance({ balance, loading }: { balance: string | null; loading: boolean }) {
+ return (
+
+ {loading ? (
+
+ ) : (
+ {balance ?? "Balance"}
+ )}
+
+ );
+}
+
+type AuthUser = NonNullable["user"]>;
+
+function AccountMenu({
+ user,
+ verified,
+ returnTo,
+ balance,
+ balanceLoading,
+ loggingOut,
+ onLogout,
+}: {
+ user: AuthUser;
+ verified: boolean;
+ returnTo: string;
+ balance: BalanceSnapshot;
+ balanceLoading: boolean;
+ loggingOut: boolean;
+ onLogout: () => void;
+}) {
+ return (
+
+
+
+
+
+ {user.name.slice(0, 1).toUpperCase()}
+
+
+
+ {user.name}
+
+
+
+
+
+
+
+
+
+ {user.name.slice(0, 1).toUpperCase()}
+
+
+
+
{user.name}
+
{user.email}
+
+
+
+
+
+
+ {balanceLoading ? (
+
+ ) : (
+
+ {balance.balance ?? "Unavailable"}
+
+ )}
+
+
+
Available
+
+ {balanceLoading ? "Loading" : (balance.available ?? "Unavailable")}
+
+
+
All-time return
+
+ {balanceLoading ? "Loading" : (balance.returnValue ?? "Unavailable")}
+
+
+
+
+
-
- {NAV_LINKS.map((link) => (
-
-
- {link.label}
-
-
- ))}
-
-
- Theme
-
- {theme === "dark" ? : }
-
-
+ {!verified ? (
+
+
+
+ Verify your email
+
+
+ ) : null}
-
- {user ? (
- <>
-
-
-
-
- {user.name[0]}
-
-
-
-
-
- {user.name}
-
-
{user.email}
-
-
-
-
-
-
-
- Log out
-
-
- >
- ) : (
- <>
-
-
-
- Sign in
-
-
-
-
-
-
- Sign up
-
-
-
- >
- )}
-
-
-
-
+
+
+
+ {accountNavigation.map((item) => {
+ const Icon = accountIcons[item.id];
+ return (
+
+
+
+
+
+
+
+ {item.label}
+
+
+ {accountDescriptions[item.id]}
+
+
+
+
+
+ );
+ })}
+
+
+
-
-
- {theme === "dark" ? : }
+
+
+ {loggingOut ? "Logging out…" : "Log out"}
+
+
+
+ );
+}
+
+function MobileNavigation({
+ primaryNavigation,
+ user,
+ verified,
+ authLoading,
+ returnTo,
+ theme,
+ toggleTheme,
+ balance,
+ balanceLoading,
+ loggingOut,
+ onLogout,
+}: {
+ primaryNavigation: ReturnType;
+ user: AuthUser | null;
+ verified: boolean;
+ authLoading: boolean;
+ returnTo: string;
+ theme: "light" | "dark";
+ toggleTheme: () => void;
+ balance: BalanceSnapshot;
+ balanceLoading: boolean;
+ loggingOut: boolean;
+ onLogout: () => void;
+}) {
+ return (
+
+
+
+
+
+
+
+
+ Navigation
+
+
+
+
+
+
+
+
+
+
- {user ? (
-
-
-
-
-
-
-
-
-
-
- {user.name}
-
+
+
+
+ Explore
+
+
+ {primaryNavigation.map((item) => {
+ const meta = primaryNavigationMeta[item.id];
+ const Icon = meta.icon;
+ return (
+
+
+
+
+ {item.external ? (
+
+ ) : (
+
+ )}
+
+
+ {item.label}
+
+
+ {meta.description}
+
+
+
+ );
+ })}
+
+
-
-
-
+
+
+ Your account
+
-
-
-
-
-
-
-
-
-
-
- {user.name}
-
-
{user.email}
-
+ {authLoading ? (
+
+
+
+
+
+
-
-
-
-
- {!verified && (
-
-
-
- Verify email
-
-
- )}
-
-
-
- Dashboard
-
-
-
-
-
-
- API keys
-
-
-
-
-
-
- Profile
-
-
-
-
-
-
-
-
- Log out
-
-
-
+
+
+
+ ) : user ? (
+
) : (
- <>
-
-
- Sign in
-
-
-
-
Sign up
-
- >
+
+
Start your trading record
+
+ Create an account to track your balance, performance, and rank.
+
+
+
+
+ Sign in
+
+
+
+
+ Start trading
+
+
+
+
)}
+
+
+
+
+
+ {theme === "dark" ? : }
+ {theme === "dark" ? "Light theme" : "Dark theme"}
+
+ {user ? (
+
+
+
+ {loggingOut ? "Logging out…" : "Log out"}
+
+
+ ) : null}
+
+
+
+ );
+}
+
+function MobileAccount({
+ user,
+ verified,
+ returnTo,
+ balance,
+ balanceLoading,
+}: {
+ user: AuthUser;
+ verified: boolean;
+ returnTo: string;
+ balance: BalanceSnapshot;
+ balanceLoading: boolean;
+}) {
+ return (
+ <>
+
+
+
+
+ {user.name.slice(0, 1).toUpperCase()}
+
+
+
+
{user.name}
+
{user.email}
+
+
+
+ Profile
+
+
+
+
+
+
+ {balanceLoading ? (
+
+ ) : (
+
+ {balance.balance ?? "Unavailable"}
+
+ )}
+
+
+ Available{" "}
+
+ {balanceLoading ? "Loading" : (balance.available ?? "Unavailable")}
+
+
+
+ {balanceLoading ? "Loading" : (balance.returnValue ?? "Unavailable")}
+
+
+
+
-
+
+ {!verified ? (
+
+
+
+ Verify your email
+
+
+ ) : null}
+
+
+ {accountNavigation
+ .filter((item) => item.id !== "profile")
+ .map((item, index) => {
+ const Icon = accountIcons[item.id];
+ return (
+
+ 0 ? "border-t border-border/50" : ""}`}
+ activeClassName="bg-primary/5"
+ >
+
+
+
+
+
+ {item.label}
+
+
+ {accountDescriptions[item.id]}
+
+
+
+
+
+ );
+ })}
+
+ >
);
}
+
+export default Navbar;
diff --git a/frontend/src/components/navigation-link.tsx b/frontend/src/components/navigation-link.tsx
new file mode 100644
index 0000000..5be3d0e
--- /dev/null
+++ b/frontend/src/components/navigation-link.tsx
@@ -0,0 +1,48 @@
+import { forwardRef, type ComponentPropsWithoutRef } from "react";
+import { Link, useLocation } from "react-router-dom";
+import type { NavigationItem } from "@/lib/navigation";
+import { cn } from "@/lib/utils";
+
+type NavigationLinkProps = Omit
, "href"> & {
+ item: NavigationItem;
+ activeClassName?: string;
+};
+
+function isActivePath(item: NavigationItem, pathname: string) {
+ if (item.external) return false;
+
+ const activePath = item.activePath ?? item.href;
+ return item.end
+ ? pathname === activePath
+ : pathname === activePath || pathname.startsWith(`${activePath}/`);
+}
+
+export const NavigationLink = forwardRef(
+ ({ item, activeClassName, className, children, ...props }, ref) => {
+ const { pathname } = useLocation();
+ const active = isActivePath(item, pathname);
+ const resolvedClassName = cn(className, active && activeClassName);
+
+ if (item.external) {
+ return (
+
+ {children}
+
+ );
+ }
+
+ return (
+
+ {children}
+
+ );
+ },
+);
+
+NavigationLink.displayName = "NavigationLink";
diff --git a/frontend/src/components/root-layout.tsx b/frontend/src/components/root-layout.tsx
index 9e5141a..fbe0dd5 100644
--- a/frontend/src/components/root-layout.tsx
+++ b/frontend/src/components/root-layout.tsx
@@ -1,14 +1,16 @@
import { Outlet } from "react-router-dom";
-import Navbar from "@/components/landing/navbar";
+import Navbar from "@/components/navbar";
import Footer from "@/components/landing/footer";
import { SeoHead } from "@/components/seo-head";
+import { SkipLink } from "@/components/ui/skip-link";
export function RootLayout() {
return (
-
+
+
-
+
diff --git a/frontend/src/components/route-behavior.tsx b/frontend/src/components/route-behavior.tsx
new file mode 100644
index 0000000..a9c586b
--- /dev/null
+++ b/frontend/src/components/route-behavior.tsx
@@ -0,0 +1,17 @@
+import { useEffect } from "react";
+import { useLocation } from "react-router-dom";
+
+export function RouteBehavior() {
+ const { pathname } = useLocation();
+
+ useEffect(() => {
+ const frame = window.requestAnimationFrame(() => {
+ window.scrollTo({ top: 0, left: 0, behavior: "auto" });
+ document.getElementById("main-content")?.scrollTo({ top: 0, left: 0, behavior: "auto" });
+ });
+
+ return () => window.cancelAnimationFrame(frame);
+ }, [pathname]);
+
+ return null;
+}
diff --git a/frontend/src/components/route-guards.tsx b/frontend/src/components/route-guards.tsx
index 2f06f82..7c07300 100644
--- a/frontend/src/components/route-guards.tsx
+++ b/frontend/src/components/route-guards.tsx
@@ -1,21 +1,32 @@
import type { ReactNode } from "react";
-import { Navigate } from "react-router-dom";
+import { Navigate, useLocation } from "react-router-dom";
import { useAuth } from "@/context/AuthContext";
import Loader from "@/components/ui/loader";
+import { getSafeReturnTo } from "@/lib/redirect";
export function Protected({ children }: { children: ReactNode }) {
const { authenticated, verified, loading } = useAuth();
+ const location = useLocation();
+ const returnTo = `${location.pathname}${location.search}${location.hash}`;
if (loading) return ;
- if (!authenticated) return ;
- if (!verified) return ;
+ if (!authenticated) return ;
+ if (!verified) return ;
return <>{children}>;
}
export function PublicOnly({ children }: { children: ReactNode }) {
const { authenticated, verified, loading } = useAuth();
+ const location = useLocation();
+ const returnTo = getSafeReturnTo(location.state);
if (loading) return ;
- if (authenticated) return ;
+ if (authenticated) {
+ return verified ? (
+
+ ) : (
+
+ );
+ }
return <>{children}>;
}
diff --git a/frontend/src/components/seo-head.tsx b/frontend/src/components/seo-head.tsx
index 5ea1ab7..a10708b 100644
--- a/frontend/src/components/seo-head.tsx
+++ b/frontend/src/components/seo-head.tsx
@@ -1,14 +1,6 @@
import { useEffect } from "react";
import { useLocation } from "react-router-dom";
-import {
- SITE,
- OG_IMAGE,
- resolvePageSeo,
- canonicalUrl,
- jsonLdWebSite,
- jsonLdOrganization,
- jsonLdSoftwareApplication,
-} from "@/lib/seo";
+import { SITE, OG_IMAGE, resolvePageSeo, canonicalUrl, jsonLdWebPage } from "@/lib/seo";
function upsertMeta(attr: "name" | "property", key: string, content: string) {
let el = document.head.querySelector(`meta[${attr}="${key}"]`);
@@ -56,16 +48,19 @@ export function SeoHead(props?: SeoHeadProps) {
const title = seo.title;
const description = seo.description ?? SITE.description;
const canonical = canonicalUrl(seo.path ?? pathname);
- const robots = seo.noIndex ? "noindex, nofollow" : "index, follow";
+ const robots = seo.noIndex ? "noindex, nofollow" : "index, follow, max-image-preview:large";
useEffect(() => {
document.title = title;
upsertMeta("name", "description", description);
- upsertMeta("name", "keywords", SITE.keywords.join(", "));
upsertMeta("name", "robots", robots);
upsertMeta("name", "author", SITE.name);
- upsertMeta("name", "theme-color", "#0a0a0a");
+ upsertMeta(
+ "name",
+ "theme-color",
+ document.documentElement.classList.contains("dark") ? "#0a0a0c" : "#ffffff",
+ );
upsertLink("canonical", canonical);
@@ -75,23 +70,20 @@ export function SeoHead(props?: SeoHeadProps) {
upsertMeta("property", "og:description", description);
upsertMeta("property", "og:url", canonical);
upsertMeta("property", "og:image", OG_IMAGE);
- upsertMeta("property", "og:image:width", "1734");
- upsertMeta("property", "og:image:height", "907");
- upsertMeta("property", "og:image:alt", `${SITE.name} — ${SITE.tagline}`);
+ upsertMeta("property", "og:image:secure_url", OG_IMAGE);
+ upsertMeta("property", "og:image:type", "image/png");
+ upsertMeta("property", "og:image:width", "1737");
+ upsertMeta("property", "og:image:height", "906");
+ upsertMeta("property", "og:image:alt", "PaperDrill logo with a candlestick trading chart");
upsertMeta("property", "og:locale", SITE.locale);
upsertMeta("name", "twitter:card", "summary_large_image");
- upsertMeta("name", "twitter:site", SITE.twitter);
upsertMeta("name", "twitter:title", title);
upsertMeta("name", "twitter:description", description);
upsertMeta("name", "twitter:image", OG_IMAGE);
- upsertMeta("name", "twitter:image:alt", `${SITE.name} — ${SITE.tagline}`);
+ upsertMeta("name", "twitter:image:alt", "PaperDrill logo with a candlestick trading chart");
- if (pathname === "/") {
- upsertJsonLd("website", jsonLdWebSite());
- upsertJsonLd("organization", jsonLdOrganization());
- upsertJsonLd("software", jsonLdSoftwareApplication());
- }
+ upsertJsonLd("webpage", jsonLdWebPage(title, description, canonical));
}, [title, description, canonical, robots, pathname]);
return null;
diff --git a/frontend/src/components/signup-form.tsx b/frontend/src/components/signup-form.tsx
index 0a9af21..610f432 100644
--- a/frontend/src/components/signup-form.tsx
+++ b/frontend/src/components/signup-form.tsx
@@ -1,28 +1,31 @@
import { useState } from "react";
-import { Link, useNavigate } from "react-router-dom";
-import { cn } from "@/lib/utils";
+import { Link, useLocation, useNavigate } from "react-router-dom";
import { Button } from "@/components/ui/button";
-import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
-import { Field, FieldDescription, FieldGroup, FieldLabel } from "@/components/ui/field";
+import { Field, FieldDescription, FieldError, FieldGroup, FieldLabel } from "@/components/ui/field";
import { Input } from "@/components/ui/input";
import { useAuth } from "@/context/AuthContext";
import { api } from "@/lib/api";
import { useAnalytics } from "@/lib/analytics";
+import { getSafeReturnTo } from "@/lib/redirect";
import { toast } from "sonner";
-export function SignupForm({ className, ...props }: React.ComponentProps<"div">) {
+export function SignupForm() {
const [name, setName] = useState("");
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [isLoading, setIsLoading] = useState(false);
+ const [formError, setFormError] = useState(null);
const { setUser } = useAuth();
const posthog = useAnalytics();
const navigate = useNavigate();
+ const location = useLocation();
+ const returnTo = getSafeReturnTo(location.state);
const handleSubmit = async (event: React.SubmitEvent) => {
event.preventDefault();
+ setFormError(null);
if (password.length < 8) {
- toast.error("Password must be at least 8 characters long");
+ setFormError("Password must be at least 8 characters long.");
return;
}
@@ -32,79 +35,117 @@ export function SignupForm({ className, ...props }: React.ComponentProps<"div">)
setUser(user);
posthog.capture("user_signed_up", { email_verified: user.emailVerified });
toast.success(message);
- navigate(user.emailVerified ? "/dashboard" : "/verify-email", {
+ navigate(user.emailVerified ? returnTo : "/verify-email", {
replace: true,
- state: user.emailVerified ? undefined : { emailSent: true },
+ state: user.emailVerified ? undefined : { emailSent: true, returnTo },
});
} catch (error) {
- toast.error(error instanceof Error ? error.message : "Signup failed");
+ setFormError(error instanceof Error ? error.message : "Signup failed.");
} finally {
setIsLoading(false);
}
};
return (
-
-
-
- Create your account
- Create an account to start trading
-
-
-
-
-
-
+
+
+
+
+
+
+ Already have an account?{" "}
+
+ Sign in
+
+
+
+
By continuing, you agree to our Terms of Service and{" "}
Privacy Policy.
diff --git a/frontend/src/components/ui/confirm-dialog.tsx b/frontend/src/components/ui/confirm-dialog.tsx
new file mode 100644
index 0000000..4def354
--- /dev/null
+++ b/frontend/src/components/ui/confirm-dialog.tsx
@@ -0,0 +1,65 @@
+import { Dialog } from "radix-ui";
+import { Button } from "@/components/ui/button";
+import { cn } from "@/lib/utils";
+
+type ConfirmDialogProps = {
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
+ title: string;
+ description: string;
+ confirmLabel: string;
+ cancelLabel?: string;
+ onConfirm: () => void;
+ pending?: boolean;
+ pendingLabel?: string;
+ tone?: "default" | "destructive";
+};
+
+export function ConfirmDialog({
+ open,
+ onOpenChange,
+ title,
+ description,
+ confirmLabel,
+ cancelLabel = "Go back",
+ onConfirm,
+ pending = false,
+ pendingLabel = "Working…",
+ tone = "destructive",
+}: ConfirmDialogProps) {
+ return (
+
!pending && onOpenChange(nextOpen)}>
+
+
+ pending && event.preventDefault()}
+ onPointerDownOutside={(event) => pending && event.preventDefault()}
+ >
+
+ {title}
+
+
+ {description}
+
+
+
+
+ {cancelLabel}
+
+
+
+ {pending ? pendingLabel : confirmLabel}
+
+
+
+
+
+ );
+}
diff --git a/frontend/src/components/ui/decimal-input.tsx b/frontend/src/components/ui/decimal-input.tsx
index c36dc0a..8605adc 100644
--- a/frontend/src/components/ui/decimal-input.tsx
+++ b/frontend/src/components/ui/decimal-input.tsx
@@ -106,7 +106,7 @@ export const DecimalInput = forwardRef
(func
aria-valuemax={props.max === undefined ? undefined : Number(props.max)}
aria-valuenow={Number.isFinite(Number(value)) ? Number(value) : undefined}
className={cn(
- "bg-l3 border-border/60 placeholder-medium-emphasis border-1.5 w-full rounded-lg border-solid pr-12 text-left ring-0 text-lg tabular-nums text-high-emphasis outline-none h-11 px-3 placeholder:font-normal",
+ "bg-l3 border-border/60 placeholder-medium-emphasis border-1.5 w-full rounded-lg border-solid pr-12 text-left ring-0 text-lg tabular-nums text-high-emphasis outline-none h-11 px-3 placeholder:font-normal focus-visible:border-primary",
focused && "border-primary focus:border-primary",
disabled && "opacity-50 cursor-not-allowed",
asset && "pr-12",
diff --git a/frontend/src/components/ui/feedback-state.tsx b/frontend/src/components/ui/feedback-state.tsx
new file mode 100644
index 0000000..0170021
--- /dev/null
+++ b/frontend/src/components/ui/feedback-state.tsx
@@ -0,0 +1,54 @@
+import type { LucideIcon } from "lucide-react";
+import type { ReactNode } from "react";
+import { cn } from "@/lib/utils";
+
+export function FeedbackState({
+ title,
+ description,
+ icon: Icon,
+ action,
+ className,
+}: {
+ title: string;
+ description?: ReactNode;
+ icon?: LucideIcon;
+ action?: ReactNode;
+ className?: string;
+}) {
+ return (
+
+ {Icon &&
}
+
{title}
+ {description &&
{description}
}
+ {action &&
{action}
}
+
+ );
+}
+
+export function InlineNotice({
+ children,
+ tone = "neutral",
+ className,
+}: {
+ children: ReactNode;
+ tone?: "neutral" | "error";
+ className?: string;
+}) {
+ return (
+
+ {children}
+
+ );
+}
diff --git a/frontend/src/components/ui/loader.tsx b/frontend/src/components/ui/loader.tsx
index 70bcd73..422e1ec 100644
--- a/frontend/src/components/ui/loader.tsx
+++ b/frontend/src/components/ui/loader.tsx
@@ -2,8 +2,13 @@ import { cn } from "@/lib/utils";
export function Loader({ className }: { className?: string }) {
return (
-
+
);
}
diff --git a/frontend/src/components/ui/metric.tsx b/frontend/src/components/ui/metric.tsx
new file mode 100644
index 0000000..6ff3669
--- /dev/null
+++ b/frontend/src/components/ui/metric.tsx
@@ -0,0 +1,40 @@
+import * as React from "react";
+import { cn } from "@/lib/utils";
+import { Skeleton } from "./skeleton";
+
+function MetricGroup({ className, ...props }: React.HTMLAttributes
) {
+ return (
+
+ );
+}
+
+function Metric({
+ label,
+ value,
+ className,
+ valueClassName,
+}: {
+ label: React.ReactNode;
+ value: React.ReactNode | null;
+ className?: string;
+ valueClassName?: string;
+}) {
+ return (
+
+
{label}
+ {value == null ? (
+
+ ) : (
+
+ {value}
+
+ )}
+
+ );
+}
+
+export { Metric, MetricGroup };
diff --git a/frontend/src/components/ui/page.tsx b/frontend/src/components/ui/page.tsx
index 787a385..cb55485 100644
--- a/frontend/src/components/ui/page.tsx
+++ b/frontend/src/components/ui/page.tsx
@@ -5,6 +5,12 @@ interface PageProps extends React.HTMLAttributes {
fixed?: boolean;
}
+interface PageHeadingProps extends Omit, "title"> {
+ title: React.ReactNode;
+ description?: React.ReactNode;
+ action?: React.ReactNode;
+}
+
function Page({ className, fixed = false, ...props }: PageProps) {
return (
) {
return (
-
+
+
+
{title}
+ {description && (
+
{description}
+ )}
+
+ {action &&
{action}
}
+
+ );
+}
+
+export { Page, PageHeader, PageContent, PageHeading };
export type { PageProps };
diff --git a/frontend/src/components/ui/safari.tsx b/frontend/src/components/ui/safari.tsx
deleted file mode 100644
index 35ab6e5..0000000
--- a/frontend/src/components/ui/safari.tsx
+++ /dev/null
@@ -1,238 +0,0 @@
-import type { HTMLAttributes } from "react"
-
-const SAFARI_WIDTH = 1203
-const SAFARI_HEIGHT = 753
-const SCREEN_X = 1
-const SCREEN_Y = 52
-const SCREEN_WIDTH = 1200
-const SCREEN_HEIGHT = 700
-
-// Calculated percentages
-const LEFT_PCT = (SCREEN_X / SAFARI_WIDTH) * 100
-const TOP_PCT = (SCREEN_Y / SAFARI_HEIGHT) * 100
-const WIDTH_PCT = (SCREEN_WIDTH / SAFARI_WIDTH) * 100
-const HEIGHT_PCT = (SCREEN_HEIGHT / SAFARI_HEIGHT) * 100
-
-type SafariMode = "default" | "simple"
-
-export interface SafariProps extends HTMLAttributes
{
- url?: string
- imageSrc?: string
- videoSrc?: string
- mode?: SafariMode
-}
-
-export function Safari({
- imageSrc,
- videoSrc,
- url,
- mode = "default",
- className,
- style,
- ...props
-}: SafariProps) {
- const hasVideo = !!videoSrc
- const hasMedia = hasVideo || !!imageSrc
-
- return (
-
- {hasVideo && (
-
-
-
- )}
-
- {!hasVideo && imageSrc && (
-
-
-
- )}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {url}
-
-
-
- {mode === "default" ? (
- <>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- >
- ) : null}
-
-
-
- )
-}
diff --git a/frontend/src/components/ui/sidebar.tsx b/frontend/src/components/ui/sidebar.tsx
index cf5db1e..94b3be5 100644
--- a/frontend/src/components/ui/sidebar.tsx
+++ b/frontend/src/components/ui/sidebar.tsx
@@ -268,7 +268,7 @@ function SidebarRail({ className, ...props }: React.ComponentProps<"button">) {
onClick={toggleSidebar}
title="Toggle Sidebar"
className={cn(
- "absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex",
+ "absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-[color,background-color] ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex",
"in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize",
"[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
"group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar",
diff --git a/frontend/src/components/ui/skip-link.tsx b/frontend/src/components/ui/skip-link.tsx
new file mode 100644
index 0000000..14c2eca
--- /dev/null
+++ b/frontend/src/components/ui/skip-link.tsx
@@ -0,0 +1,10 @@
+export function SkipLink({ target = "main-content" }: { target?: string }) {
+ return (
+
+ Skip to content
+
+ );
+}
diff --git a/frontend/src/components/ui/surface.tsx b/frontend/src/components/ui/surface.tsx
new file mode 100644
index 0000000..2f0b720
--- /dev/null
+++ b/frontend/src/components/ui/surface.tsx
@@ -0,0 +1,38 @@
+import * as React from "react";
+import { cn } from "@/lib/utils";
+
+function Surface({ className, ...props }: React.HTMLAttributes) {
+ return (
+
+ );
+}
+
+function SurfaceHeader({ className, ...props }: React.HTMLAttributes) {
+ return (
+
+ );
+}
+
+function SurfaceContent({ className, ...props }: React.HTMLAttributes) {
+ return
;
+}
+
+function SurfaceFooter({ className, ...props }: React.HTMLAttributes) {
+ return (
+
+ );
+}
+
+export { Surface, SurfaceContent, SurfaceFooter, SurfaceHeader };
diff --git a/frontend/src/components/ui/tabs.tsx b/frontend/src/components/ui/tabs.tsx
index fa4db56..6ebb616 100644
--- a/frontend/src/components/ui/tabs.tsx
+++ b/frontend/src/components/ui/tabs.tsx
@@ -55,7 +55,7 @@ function TabsTrigger({ className, ...props }: React.ComponentProps doc.slug === slug);
-}
diff --git a/frontend/src/content/docs/account.md b/frontend/src/content/docs/account.md
deleted file mode 100644
index 9fe74c6..0000000
--- a/frontend/src/content/docs/account.md
+++ /dev/null
@@ -1,63 +0,0 @@
-# Account and portfolio
-
-These endpoints use API-key authentication. Decimal balances and values are returned as strings so clients do not lose precision.
-
-## Read balances
-
-`GET /balances` requires `ACCOUNT_READ`. Add `?asset=USD` to return one asset only.
-
-```bash
-curl https://api.paperdrill.dev/v1/balances \
- --header "x-api-key: YOUR_API_KEY"
-```
-
-```json
-{
- "USD": { "available": "9748.50", "locked": "251.50" },
- "SOL": { "available": "2.00", "locked": "0.00" }
-}
-```
-
-`available` can be used immediately. `locked` is reserved by open orders.
-
-## Read portfolio performance
-
-`GET /portfolio` requires `ACCOUNT_READ`. It values each position in the platform quote asset and compares it with the account’s PnL baseline.
-
-```bash
-curl https://api.paperdrill.dev/v1/portfolio \
- --header "x-api-key: YOUR_API_KEY"
-```
-
-| Field | Meaning |
-| -------------------- | ------------------------------------------------ |
-| `equity` | Current portfolio value |
-| `baselineEquity` | Value used as the PnL starting point |
-| `pnl` / `pnlPercent` | Change from the baseline |
-| `asOf` | Oldest price timestamp used for valuation |
-| `partial` | `true` when a position could not be fully priced |
-| `positions` | Per-asset balances, mark price, and value |
-
-## Read private trade history
-
-`GET /trades?limit=100` requires `ORDER_READ`. `limit` is optional and accepts 1–500.
-
-```bash
-curl "https://api.paperdrill.dev/v1/trades?limit=2" \
- --header "x-api-key: YOUR_API_KEY"
-```
-
-```json
-[
- {
- "id": "fill_123",
- "symbol": "SOL_USD",
- "price": "125.50",
- "qty": "1.25",
- "side": "BUY",
- "isMaker": false,
- "orderId": "order_123",
- "createdAt": "2026-09-19T10:00:00.000Z"
- }
-]
-```
diff --git a/frontend/src/content/docs/api-reference.md b/frontend/src/content/docs/api-reference.md
deleted file mode 100644
index 30ca6af..0000000
--- a/frontend/src/content/docs/api-reference.md
+++ /dev/null
@@ -1,32 +0,0 @@
-# API Reference
-
-Base URL: `https://api.paperdrill.dev/v1`. Public endpoints need no credentials. Protected endpoints require an API key in the `x-api-key` header with the listed scope.
-
-## Market data
-
-| Method | Path | Access | Description |
-| ------ | ------------------------------------ | ------ | ------------------------------ |
-| `GET` | `/markets` | Public | List markets and precisions |
-| `GET` | `/markets/tickers` | Public | Latest ticker for every market |
-| `GET` | `/markets/:symbol/ticker` | Public | Latest ticker for one market |
-| `GET` | `/markets/:symbol/orderbook` | Public | Aggregated depth snapshot |
-| `GET` | `/markets/:symbol/trades?limit=` | Public | Recent public trades |
-| `GET` | `/markets/:symbol/candles?interval=` | Public | Historical candles |
-
-## Trading
-
-| Method | Path | Required scope | Description |
-| -------- | ------------------ | -------------- | -------------------------------- |
-| `POST` | `/orders` | `ORDER_CREATE` | Create a limit or market order |
-| `GET` | `/orders` | `ORDER_READ` | Paginated order history |
-| `GET` | `/orders/open` | `ORDER_READ` | Open and partially filled orders |
-| `GET` | `/orders/:orderId` | `ORDER_READ` | Read one owned order |
-| `DELETE` | `/orders/:orderId` | `ORDER_CANCEL` | Cancel an open order |
-| `GET` | `/trades?limit=` | `ORDER_READ` | Private trade history |
-
-## Account
-
-| Method | Path | Required scope | Description |
-| ------ | ------------------ | -------------- | ----------------------------- |
-| `GET` | `/balances?asset=` | `ACCOUNT_READ` | Available and locked balances |
-| `GET` | `/portfolio` | `ACCOUNT_READ` | Valued positions and PnL |
diff --git a/frontend/src/content/docs/authentication.md b/frontend/src/content/docs/authentication.md
deleted file mode 100644
index 4bd6e13..0000000
--- a/frontend/src/content/docs/authentication.md
+++ /dev/null
@@ -1,42 +0,0 @@
-# Authentication
-
-Programmable access to PaperDrill uses API keys. Public market-data endpoints do not require authentication.
-
-API base URL:
-
-```text
-https://api.paperdrill.dev/v1
-```
-
-## Create an API key
-
-Sign in to PaperDrill, open the [API keys dashboard](/dashboard/api-keys), and create a key with only the permissions your integration needs. Copy the complete key when it appears, it is shown only once.
-
-## Send the key
-
-Pass the complete key in the `x-api-key` header:
-
-```bash
-curl https://api.paperdrill.dev/v1/orders/open \
- --header "x-api-key: YOUR_API_KEY"
-```
-
-Do not use `Authorization: Bearer` and do not add a prefix yourself.
-
-## Permissions
-
-| Scope | Allows |
-| -------------- | ------------------------------------- |
-| `ACCOUNT_READ` | Read balances and portfolio |
-| `ORDER_READ` | Read orders and private trade history |
-| `ORDER_CREATE` | Place limit and market orders |
-| `ORDER_CANCEL` | Cancel open orders |
-
-## Keep keys safe
-
-- Keep keys in server-side environment variables or a secret manager.
-- Never embed a key in browser code, mobile applications, or public repositories.
-- Use a separate key for each integration and grant only the required scopes.
-- Revoke and replace a key immediately if it may have been exposed.
-
-Continue to [Quick start](/docs) to place your first order, or [Errors & limits](/docs/errors) for failure handling and usage limits.
diff --git a/frontend/src/content/docs/markets.md b/frontend/src/content/docs/markets.md
deleted file mode 100644
index 6d3f30f..0000000
--- a/frontend/src/content/docs/markets.md
+++ /dev/null
@@ -1,83 +0,0 @@
-# Markets and candles
-
-Market endpoints are public. Values representing price, quantity, or volume are decimal strings.
-
-## List markets
-
-`GET /markets` returns every tradable market and its precision rules.
-
-```bash
-curl https://api.paperdrill.dev/v1/markets
-```
-
-```json
-{
- "data": [
- {
- "id": "market_123",
- "name": "Solana",
- "symbol": "SOL_USD",
- "baseAsset": "SOL",
- "quoteAsset": "USD",
- "pricePrecision": 2,
- "qtyPrecision": 2
- }
- ]
-}
-```
-
-Use the underscore form (`SOL_USD`) in all API paths and requests.
-
-## Tickers
-
-`GET /markets/tickers` returns an array of current tickers. `GET /markets/:symbol/ticker` returns one.
-
-```bash
-curl https://api.paperdrill.dev/v1/markets/SOL_USD/ticker
-```
-
-```json
-{
- "event": "ticker",
- "symbol": "SOL_USD",
- "lastPrice": "125.50",
- "openPrice": "122.10",
- "high": "128.00",
- "low": "120.25",
- "volume": "340.50",
- "quoteVolume": "42540.75",
- "priceChange": "+3.40",
- "priceChangePercent": 2.78,
- "timestamp": "2026-09-19T12:00:00.000Z"
-}
-```
-
-Before the first trade, price and volume values can be `null`.
-
-## Candles
-
-`GET /markets/:symbol/candles?interval=15m` returns historical OHLCV candles in chronological order.
-
-Supported intervals: `1m`, `5m`, `15m`, `30m`, `1H`, `4H`, and `1D`. The default is `15m`.
-
-```bash
-curl "https://api.paperdrill.dev/v1/markets/SOL_USD/candles?interval=1H"
-```
-
-```json
-{
- "data": [
- {
- "time": 1789812000000,
- "symbol": "SOL_USD",
- "open": "125.00",
- "high": "126.00",
- "low": "124.50",
- "close": "125.50",
- "volume": "20.00"
- }
- ]
-}
-```
-
-For live ticker and candle updates, use [WebSocket](/docs/websocket).
diff --git a/frontend/src/content/docs/orderbook.md b/frontend/src/content/docs/orderbook.md
deleted file mode 100644
index 2e0a145..0000000
--- a/frontend/src/content/docs/orderbook.md
+++ /dev/null
@@ -1,47 +0,0 @@
-# Order book
-
-`GET /markets/:symbol/orderbook` returns an aggregated depth snapshot. Authentication is not required.
-
-```bash
-curl https://api.paperdrill.dev/v1/markets/SOL_USD/orderbook
-```
-
-```json
-{
- "symbol": "SOL_USD",
- "bids": [
- { "price": "125.40", "qty": "8.50" },
- { "price": "125.20", "qty": "4.00" }
- ],
- "asks": [
- { "price": "125.60", "qty": "3.25" },
- { "price": "125.80", "qty": "6.00" }
- ],
- "lastUpdateId": 1842,
- "timestamp": 1789812000000
-}
-```
-
-Bids are highest price first; asks are lowest price first. Each level is the total remaining quantity at that price. `timestamp` is Unix milliseconds.
-
-## Maintain a live local book
-
-REST gives a snapshot. The `depth:SYMBOL` WebSocket stream gives only levels that changed. To prevent a race while loading:
-
-1. Subscribe to `depth:SYMBOL` and buffer messages.
-2. Fetch the REST snapshot.
-3. Discard buffered messages with `lastUpdateId` less than or equal to the snapshot value.
-4. Apply the remaining messages in order, then apply new messages immediately.
-
-Set a local level to the received `qty`. Remove it when `qty` is `"0.00"`.
-
-```json
-{
- "event": "depth",
- "symbol": "SOL_USD",
- "bids": [{ "price": "125.40", "qty": "0.00" }],
- "asks": [],
- "lastUpdateId": 1843,
- "timestamp": 1789812000100
-}
-```
diff --git a/frontend/src/content/docs/orders.md b/frontend/src/content/docs/orders.md
deleted file mode 100644
index 46280e6..0000000
--- a/frontend/src/content/docs/orders.md
+++ /dev/null
@@ -1,110 +0,0 @@
-# Orders
-
-Order requests require a verified account and the relevant API-key scope. `price` and `qty` are positive decimal strings. Read [Markets](/docs/markets) before placing an order so the number of decimal places matches the market.
-
-## Create a limit order
-
-`POST /orders` requires `ORDER_CREATE`.
-
-```bash
-curl --request POST https://api.paperdrill.dev/v1/orders \
- --header "Content-Type: application/json" \
- --header "x-api-key: YOUR_API_KEY" \
- --data '{
- "symbol": "SOL_USD",
- "side": "BUY",
- "type": "LIMIT",
- "price": "125.50",
- "qty": "2.00"
- }'
-```
-
-| Field | Values | Required |
-| -------- | ------------------------------------------- | -------- |
-| `symbol` | A symbol returned by `GET /markets` | Yes |
-| `side` | `BUY` or `SELL` | Yes |
-| `type` | `LIMIT` | Yes |
-| `price` | Positive decimal string at market precision | Yes |
-| `qty` | Positive decimal string at market precision | Yes |
-
-## Create a market order
-
-Market orders omit `price` and consume available liquidity.
-
-```json
-{
- "symbol": "SOL_USD",
- "side": "BUY",
- "type": "MARKET",
- "qty": "1.00"
-}
-```
-
-If the book has no liquidity, the API returns `422 NO_LIQUIDITY`. A market order may also be partially filled; inspect the response instead of assuming the whole quantity traded.
-
-## Order response
-
-`POST /orders` and `GET /orders/:orderId` return this shape:
-
-```json
-{
- "id": "order_123",
- "userId": "user_123",
- "symbol": "SOL_USD",
- "side": "BUY",
- "type": "LIMIT",
- "status": "PARTIALLY_FILLED",
- "price": "125.50",
- "qty": "2.00",
- "filledQty": "0.50",
- "averagePrice": "125.25",
- "createdAt": "2026-09-19T10:00:00.000Z"
-}
-```
-
-`status` is one of `OPEN`, `PARTIALLY_FILLED`, `FILLED`, or `CANCELLED`. `averagePrice` is omitted until a fill exists.
-
-## Read orders
-
-| Endpoint | Scope | Notes |
-| ---------------------- | ------------ | ------------------------------------ |
-| `GET /orders/open` | `ORDER_READ` | All open and partially filled orders |
-| `GET /orders/:orderId` | `ORDER_READ` | One order owned by the caller |
-| `GET /orders` | `ORDER_READ` | History, newest first |
-
-Order-history query parameters are all optional:
-
-| Parameter | Values |
-| --------- | ------------------------------------------------- |
-| `symbol` | Market symbol |
-| `status` | `OPEN`, `PARTIALLY_FILLED`, `FILLED`, `CANCELLED` |
-| `limit` | Positive integer; defaults to 10 |
-| `page` | Positive integer; defaults to 1 |
-
-```bash
-curl "https://api.paperdrill.dev/v1/orders?symbol=SOL_USD&status=FILLED&limit=10&page=1" \
- --header "x-api-key: YOUR_API_KEY"
-```
-
-## Cancel an order
-
-`DELETE /orders/:orderId` requires `ORDER_CANCEL`.
-
-```bash
-curl --request DELETE https://api.paperdrill.dev/v1/orders/order_123 \
- --header "x-api-key: YOUR_API_KEY"
-```
-
-```json
-{
- "id": "order_123",
- "symbol": "SOL_USD",
- "status": "CANCELLED",
- "side": "BUY",
- "qty": "2.00",
- "filledQty": "0.50",
- "releasedFunds": "188.25"
-}
-```
-
-A filled order cannot be cancelled and returns `409 ORDER_NOT_CANCELLABLE`.
diff --git a/frontend/src/content/docs/quick-start.md b/frontend/src/content/docs/quick-start.md
deleted file mode 100644
index 2819329..0000000
--- a/frontend/src/content/docs/quick-start.md
+++ /dev/null
@@ -1,80 +0,0 @@
-# Quick start
-
-This workflow uses the programmable API to discover a market, place a limit order, inspect it, and cancel it.
-
-## 1. Create an API key
-
-Open the [API keys dashboard](/dashboard/api-keys) and create a key with:
-
-- `ORDER_READ`
-- `ORDER_CREATE`
-- `ORDER_CANCEL`
-
-Copy the complete key when it appears. It is shown only once. See [Authentication](/docs/authentication) for safe storage and available permissions.
-
-## 2. Read the market rules
-
-Never hardcode a symbol’s precision. Read it first:
-
-```bash
-curl https://api.paperdrill.dev/v1/markets
-```
-
-```json
-{
- "data": [
- {
- "symbol": "SOL_USD",
- "baseAsset": "SOL",
- "quoteAsset": "USD",
- "pricePrecision": 2,
- "qtyPrecision": 2
- }
- ]
-}
-```
-
-For this market, `price` accepts up to two decimal places and `qty` up to four. Send decimal values as JSON strings.
-
-## 3. Inspect the order book
-
-```bash
-curl https://api.paperdrill.dev/v1/markets/SOL_USD/orderbook
-```
-
-Choose a buy price below the best ask if you want the order to rest instead of executing immediately.
-
-## 4. Place a limit order
-
-```bash
-curl --request POST https://api.paperdrill.dev/v1/orders \
- --header "Content-Type: application/json" \
- --header "x-api-key: YOUR_API_KEY" \
- --data '{
- "symbol": "SOL_USD",
- "side": "BUY",
- "type": "LIMIT",
- "price": "1.00",
- "qty": "1.00"
- }'
-```
-
-The response contains the order ID and current status. A limit order can be `OPEN`, `PARTIALLY_FILLED`, or `FILLED` immediately, so always use the returned status.
-
-## 5. Check the order
-
-```bash
-curl https://api.paperdrill.dev/v1/orders/open \
- --header "x-api-key: YOUR_API_KEY"
-```
-
-If the order is no longer open, query it directly with `GET /orders/ORDER_ID` or inspect order history.
-
-## 6. Cancel an open order
-
-```bash
-curl --request DELETE https://api.paperdrill.dev/v1/orders/ORDER_ID \
- --header "x-api-key: YOUR_API_KEY"
-```
-
-Continue to [Orders](/docs/orders) for every request and response field, or [WebSocket](/docs/websocket) for live market updates.
diff --git a/frontend/src/content/docs/trades.md b/frontend/src/content/docs/trades.md
deleted file mode 100644
index e481869..0000000
--- a/frontend/src/content/docs/trades.md
+++ /dev/null
@@ -1,30 +0,0 @@
-# Public trades
-
-`GET /markets/:symbol/trades` returns recent public fills for one market. Authentication is not required.
-
-```bash
-curl "https://api.paperdrill.dev/v1/markets/SOL_USD/trades?limit=2"
-```
-
-`limit` is optional, defaults to 50, and accepts 1–500. Results are newest first.
-
-```json
-[
- {
- "id": "fill_123",
- "symbol": "SOL_USD",
- "price": "125.50",
- "qty": "1.25",
- "buyOrderId": "buy_order_123",
- "sellOrderId": "sell_order_123",
- "buyerId": "buyer_123",
- "sellerId": "seller_123",
- "isBuyerMaker": false,
- "createdAt": 1789812000000
- }
-]
-```
-
-`createdAt` is Unix milliseconds. `isBuyerMaker` is `true` when the resting order was the buy order. An active market with no fills returns an empty array; an unknown market returns `404 MARKET_NOT_FOUND`.
-
-For a user’s own fills, use [Account & portfolio](/docs/account). For real-time public fills, subscribe to `trade:SYMBOL` over [WebSocket](/docs/websocket).
diff --git a/frontend/src/content/docs/websocket.md b/frontend/src/content/docs/websocket.md
deleted file mode 100644
index a2899fc..0000000
--- a/frontend/src/content/docs/websocket.md
+++ /dev/null
@@ -1,75 +0,0 @@
-# WebSocket
-
-The public WebSocket streams live market updates without authentication.
-
-```text
-wss://api.paperdrill.dev
-```
-
-## Subscribe and unsubscribe
-
-Send `SUBSCRIBE` after the connection opens. One message may subscribe to multiple channels.
-
-```json
-{
- "method": "SUBSCRIBE",
- "params": ["trade:SOL_USD", "depth:SOL_USD", "ticker:SOL_USD", "candle:SOL_USD"]
-}
-```
-
-| Channel | Message |
-| --------------- | ------------------------------------- |
-| `trade:SYMBOL` | Completed public trade |
-| `depth:SYMBOL` | Changed order-book levels only |
-| `ticker:SYMBOL` | Updated 24-hour statistics |
-| `candle:SYMBOL` | Current candle updated on every trade |
-
-There is no subscription acknowledgement. Data begins when the selected market changes.
-
-```js
-const socket = new WebSocket("wss://api.paperdrill.dev");
-
-socket.addEventListener("open", () => {
- socket.send(
- JSON.stringify({
- method: "SUBSCRIBE",
- params: ["trade:SOL_USD", "ticker:SOL_USD"],
- }),
- );
-});
-
-socket.addEventListener("message", ({ data }) => {
- const message = JSON.parse(data);
- console.log(message.event, message);
-});
-```
-
-To stop a channel, send the same params with `UNSUBSCRIBE`.
-
-## Message shapes
-
-### Trade
-
-```json
-{
- "event": "trade",
- "symbol": "SOL_USD",
- "id": "fill_123",
- "price": "125.50",
- "qty": "1.25",
- "maker": false,
- "timestamp": 1789812000000
-}
-```
-
-### Ticker and candle
-
-Ticker messages use the [REST ticker](/docs/markets) shape. Candle messages use the same OHLCV fields as the candle endpoint and have `event: "candle"`.
-
-### Depth
-
-Depth messages contain changed levels only. See [Order book](/docs/orderbook) for the snapshot-and-buffer procedure.
-
-## Reconnect
-
-Connections can close during a deployment or network interruption. Reconnect with exponential backoff, then resubscribe to every desired channel. Fetch a fresh depth snapshot after reconnecting before trusting a local order book.
diff --git a/frontend/src/content/terms.ts b/frontend/src/content/terms.ts
index e509fa5..97ab4fa 100644
--- a/frontend/src/content/terms.ts
+++ b/frontend/src/content/terms.ts
@@ -22,7 +22,7 @@ export const terms: LegalContent = {
blocks: [
{
type: "paragraph",
- text: "PaperDrill is a paper-trading simulator, not a real exchange. All balances, credits, prices, orders, trades, profit and loss, and leaderboard results are simulated. No real funds or assets are deposited, held, transferred or withdrawn, and nothing on PaperDrill can be redeemed for money or other value.",
+ text: "PaperDrill is a simulated trading platform, not a real exchange. All balances, credits, prices, orders, trades, profit and loss, and leaderboard results are simulated. No real funds or assets are deposited, held, transferred or withdrawn, and nothing on PaperDrill can be redeemed for money or other value.",
},
],
},
diff --git a/frontend/src/frontend.tsx b/frontend/src/frontend.tsx
index ef5a5ba..75c2a2e 100644
--- a/frontend/src/frontend.tsx
+++ b/frontend/src/frontend.tsx
@@ -9,6 +9,8 @@ import { ThemeProvider } from "./lib/theme-provider";
import { queryClient } from "./lib/query-client";
import { Toaster } from "./components/ui/sonner";
import { PostHogProvider } from "@posthog/react";
+import { AuthProvider } from "./context/AuthContext";
+import { MarketProvider } from "./context/MarketContext";
const options = {
api_host: process.env.BUN_PUBLIC_POSTHOG_HOST ?? "https://us.i.posthog.com",
@@ -23,8 +25,12 @@ const content = (
-
-
+
+
+
+
+
+
diff --git a/frontend/src/hooks/use-account.ts b/frontend/src/hooks/use-account.ts
index d586094..4f36802 100644
--- a/frontend/src/hooks/use-account.ts
+++ b/frontend/src/hooks/use-account.ts
@@ -30,6 +30,7 @@ export function useOpenOrders({ enabled = true }: QueryOptions = {}) {
openOrders: query.data ?? [],
loading: active && query.isPending,
error: query.data === undefined ? query.error : null,
+ refresh: query.refetch,
};
}
@@ -50,6 +51,7 @@ export function useOrderHistory(
orders: query.data ?? [],
loading: active && query.isPending,
error: query.data === undefined ? query.error : null,
+ refresh: query.refetch,
};
}
@@ -67,6 +69,7 @@ export function useTradeHistory(limit = 100, { enabled = true }: QueryOptions =
trades: query.data ?? [],
loading: active && query.isPending,
error: query.data === undefined ? query.error : null,
+ refresh: query.refetch,
};
}
diff --git a/frontend/src/hooks/use-orderbook.ts b/frontend/src/hooks/use-orderbook.ts
index 9326851..e91934d 100644
--- a/frontend/src/hooks/use-orderbook.ts
+++ b/frontend/src/hooks/use-orderbook.ts
@@ -7,6 +7,7 @@ export function useOrderbook(symbol: string) {
const [orderbook, setOrderbook] = useState({ bids: {}, asks: {} });
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
+ const [retryKey, setRetryKey] = useState(0);
const bufferRef = useRef([]);
useEffect(() => {
@@ -78,7 +79,7 @@ export function useOrderbook(symbol: string) {
active = false;
unsubscribe();
};
- }, [symbol]);
+ }, [symbol, retryKey]);
const bestBid = useMemo(() => {
const prices = Object.keys(orderbook.bids).map(Number).filter(Number.isFinite);
@@ -90,5 +91,12 @@ export function useOrderbook(symbol: string) {
return prices.length ? String(Math.min(...prices)) : null;
}, [orderbook.asks]);
- return { orderbook, loading, error, bestBid, bestAsk };
+ return {
+ orderbook,
+ loading,
+ error,
+ bestBid,
+ bestAsk,
+ refresh: () => setRetryKey((current) => current + 1),
+ };
}
diff --git a/frontend/src/hooks/use-tickers.ts b/frontend/src/hooks/use-tickers.ts
index 164b1c5..4daa9af 100644
--- a/frontend/src/hooks/use-tickers.ts
+++ b/frontend/src/hooks/use-tickers.ts
@@ -52,6 +52,7 @@ export function useTickers() {
const [tickers, setTickers] = useState>({});
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
+ const [retryKey, setRetryKey] = useState(0);
useEffect(() => {
let active = true;
@@ -92,7 +93,7 @@ export function useTickers() {
active = false;
unsubs.forEach((u) => u());
};
- }, [markets]);
+ }, [markets, retryKey]);
- return { tickers, loading, error };
+ return { tickers, loading, error, refresh: () => setRetryKey((current) => current + 1) };
}
diff --git a/frontend/src/hooks/use-trades.ts b/frontend/src/hooks/use-trades.ts
index d4a71b7..dfd3173 100644
--- a/frontend/src/hooks/use-trades.ts
+++ b/frontend/src/hooks/use-trades.ts
@@ -7,6 +7,7 @@ export function useTrades(symbol: string, limit = 50) {
const [trades, setTrades] = useState([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
+ const [retryKey, setRetryKey] = useState(0);
useEffect(() => {
let active = true;
@@ -55,7 +56,7 @@ export function useTrades(symbol: string, limit = 50) {
active = false;
unsubscribe();
};
- }, [symbol, limit]);
+ }, [symbol, limit, retryKey]);
- return { trades, loading, error };
+ return { trades, loading, error, refresh: () => setRetryKey((current) => current + 1) };
}
diff --git a/frontend/src/hooks/use-ux-preferences.ts b/frontend/src/hooks/use-ux-preferences.ts
new file mode 100644
index 0000000..f062a9f
--- /dev/null
+++ b/frontend/src/hooks/use-ux-preferences.ts
@@ -0,0 +1,12 @@
+import { useSyncExternalStore } from "react";
+import {
+ DEFAULT_TRADE_SYMBOL,
+ getLastTradePath,
+ subscribeToPreferences,
+} from "@/lib/ux-preferences";
+
+const DEFAULT_TRADE_PATH = `/trade/${DEFAULT_TRADE_SYMBOL}`;
+
+export function useLastTradePath() {
+ return useSyncExternalStore(subscribeToPreferences, getLastTradePath, () => DEFAULT_TRADE_PATH);
+}
diff --git a/frontend/src/index.html b/frontend/src/index.html
index 3dfaae7..e7e8347 100644
--- a/frontend/src/index.html
+++ b/frontend/src/index.html
@@ -5,11 +5,9 @@
-
+ content="PaperDrill is a competitive trading platform where traders trade credit markets, connect bots through the API, and climb the global leaderboard." />
-
+
@@ -25,45 +23,74 @@
- PaperDrill - The Exchange Built for Developers
+ PaperDrill - Competitive Trading Platform
-
+
+ content="Trade credit markets through a live matching engine, connect bots, and earn your rank." />
-
-
-
+
+
+
+
+
-
-
+
+ content="Trade credit markets through a live matching engine, connect bots, and earn your rank." />
-
+
-
diff --git a/frontend/src/lib/api-key-scopes.ts b/frontend/src/lib/api-key-scopes.ts
new file mode 100644
index 0000000..884ded9
--- /dev/null
+++ b/frontend/src/lib/api-key-scopes.ts
@@ -0,0 +1,35 @@
+import type { ApiKeyScope } from "@/types";
+
+export const API_KEY_SCOPE_OPTIONS: {
+ value: ApiKeyScope;
+ label: string;
+ description: string;
+}[] = [
+ {
+ value: "ACCOUNT_READ",
+ label: "Read balances",
+ description: "View balances and portfolio information.",
+ },
+ {
+ value: "ORDER_READ",
+ label: "Read orders",
+ description: "View open orders and trading history.",
+ },
+ {
+ value: "ORDER_CREATE",
+ label: "Create orders",
+ description: "Place market and limit orders.",
+ },
+ {
+ value: "ORDER_CANCEL",
+ label: "Cancel orders",
+ description: "Cancel existing open orders.",
+ },
+];
+
+export const API_KEY_SCOPE_LABELS: Record = {
+ ACCOUNT_READ: "Balances",
+ ORDER_READ: "Read orders",
+ ORDER_CREATE: "Create orders",
+ ORDER_CANCEL: "Cancel orders",
+};
diff --git a/frontend/src/lib/asset-colors.ts b/frontend/src/lib/asset-colors.ts
new file mode 100644
index 0000000..379344a
--- /dev/null
+++ b/frontend/src/lib/asset-colors.ts
@@ -0,0 +1,12 @@
+const ASSET_COLORS: Record = {
+ BTC: "#F7931A",
+ ETH: "#3C3C3D",
+ SOL: "#9945FF",
+ USD: "#009393",
+};
+
+export function getAssetColor(asset: string) {
+ const symbol = asset.trim().toUpperCase();
+ const knownColor = ASSET_COLORS[symbol];
+ if (knownColor) return knownColor;
+}
diff --git a/frontend/src/lib/navigation.ts b/frontend/src/lib/navigation.ts
new file mode 100644
index 0000000..18c30dd
--- /dev/null
+++ b/frontend/src/lib/navigation.ts
@@ -0,0 +1,38 @@
+import { getLastTradePath } from "@/lib/ux-preferences";
+
+export type NavigationId =
+ | "home"
+ | "portfolio"
+ | "activity"
+ | "profile"
+ | "markets"
+ | "trading"
+ | "leaderboard"
+ | "docs"
+ | "api-keys";
+
+export type NavigationItem = {
+ id: NavigationId;
+ label: string;
+ href: string;
+ activePath?: string;
+ end?: boolean;
+ external?: boolean;
+};
+
+export function getPrimaryNavigation(tradePath = getLastTradePath()) {
+ return [
+ { id: "trading", label: "Trade", href: tradePath, activePath: "/trade" },
+ { id: "markets", label: "Markets", href: "/markets", end: true },
+ { id: "leaderboard", label: "Leaderboard", href: "/leaderboard", end: true },
+ { id: "docs", label: "Docs", href: "https://docs.paperdrill.dev", external: true },
+ ] satisfies NavigationItem[];
+}
+
+export const accountNavigation = [
+ { id: "home", label: "Home", href: "/home", end: true },
+ { id: "portfolio", label: "Portfolio", href: "/portfolio", end: true },
+ { id: "activity", label: "Orders & trades", href: "/activity", end: true },
+ { id: "api-keys", label: "API keys", href: "/settings/api-keys", end: true },
+ { id: "profile", label: "Profile", href: "/settings/profile", end: true },
+] satisfies NavigationItem[];
diff --git a/frontend/src/lib/redirect.ts b/frontend/src/lib/redirect.ts
new file mode 100644
index 0000000..418cb8b
--- /dev/null
+++ b/frontend/src/lib/redirect.ts
@@ -0,0 +1,20 @@
+export type ReturnLocationState = {
+ returnTo?: string;
+ emailSent?: boolean;
+};
+
+export function getSafeReturnTo(state: unknown, fallback = "/home") {
+ if (!state || typeof state !== "object" || !("returnTo" in state)) return fallback;
+
+ const returnTo = (state as ReturnLocationState).returnTo;
+ if (
+ typeof returnTo !== "string" ||
+ !returnTo.startsWith("/") ||
+ returnTo.startsWith("//") ||
+ returnTo.includes("\\")
+ ) {
+ return fallback;
+ }
+
+ return returnTo;
+}
diff --git a/frontend/src/lib/seo.ts b/frontend/src/lib/seo.ts
index ebb9c0b..46b8024 100644
--- a/frontend/src/lib/seo.ts
+++ b/frontend/src/lib/seo.ts
@@ -1,27 +1,15 @@
export const SITE = {
name: "PaperDrill",
- tagline: "The Exchange Built for Developers",
+ tagline: "Competitive Trading Platform",
url: "https://paperdrill.dev",
description:
- "PaperDrill is a live paper-trading exchange with a real matching engine and order book. Trade on the UI or connect a bot via API — no KYC and no real funds at risk.",
+ "PaperDrill is a competitive trading platform where traders trade credit markets, connect bots through the API, and climb the global leaderboard.",
shortDescription:
- "Real matching engine. Real order book. Trade on the UI or connect a bot. No real funds at risk.",
- keywords: [
- "paper trading",
- "crypto exchange simulator",
- "matching engine",
- "order book",
- "developer exchange",
- "algorithmic trading sandbox",
- "BTC paper trading",
- "API trading",
- "WebSocket trading",
- "PaperDrill",
- ],
+ "Trade credit markets through a live matching engine, connect bots, and earn your rank.",
locale: "en_US",
- twitter: "@paperdrill",
contact: "support@paperdrill.dev",
securityContact: "security@paperdrill.dev",
+ github: "https://github.com/hars-21/paperdrill",
} as const;
export const OG_IMAGE = `${SITE.url}/og-image.png`;
@@ -45,15 +33,9 @@ export const ROUTE_SEO: Record = {
description: SITE.description,
path: "/",
},
- "/docs": {
- title: `Documentation | ${SITE.name}`,
- description:
- "Learn how PaperDrill works — markets, trading, REST API, WebSocket feeds, and paper-trading sandbox setup for developers.",
- path: "/docs",
- },
"/terms": {
title: `Terms of Service | ${SITE.name}`,
- description: "Terms of service for using the PaperDrill simulated trading platform.",
+ description: "Rules and terms for using the PaperDrill competitive trading platform.",
path: "/terms",
},
"/privacy": {
@@ -64,67 +46,74 @@ export const ROUTE_SEO: Record = {
"/markets": {
title: `Markets | ${SITE.name}`,
description:
- "Browse live BTC/USD, ETH/USD, and SOL/USD spot markets on PaperDrill with real-time order books.",
+ "Explore live BTC/USD, ETH/USD, and SOL/USD credit markets with real-time charts and order books.",
path: "/markets",
},
"/leaderboard": {
title: `Leaderboard | ${SITE.name}`,
description:
- "View PaperDrill's global leaderboard, ranked by all-time portfolio return across live simulated markets.",
+ "See the PaperDrill global trading leaderboard, ranked by portfolio return across live credit markets.",
path: "/leaderboard",
},
"/login": {
title: `Sign In | ${SITE.name}`,
- description: "Sign in to your PaperDrill account to trade and manage simulated balances.",
+ description: "Sign in to your PaperDrill account to trade and manage your credit balance.",
path: "/login",
noIndex: true,
},
"/signup": {
title: `Sign Up | ${SITE.name}`,
- description: "Create a free PaperDrill account and start paper trading with simulated funds.",
+ description:
+ "Join PaperDrill, trade live credit markets, and build your place on the leaderboard.",
path: "/signup",
},
- "/profile": {
+ "/verify-email": {
+ title: `Verify Email | ${SITE.name}`,
+ description: "Verify your email address to finish setting up your PaperDrill account.",
+ path: "/verify-email",
+ noIndex: true,
+ },
+ "/home": {
+ title: `Home | ${SITE.name}`,
+ description: "Review your PaperDrill portfolio and recent trading activity.",
+ path: "/home",
+ noIndex: true,
+ },
+ "/portfolio": {
+ title: `Portfolio | ${SITE.name}`,
+ description: "Review your credit balance, asset positions, and portfolio performance.",
+ path: "/portfolio",
+ noIndex: true,
+ },
+ "/activity": {
+ title: `Orders & Trades | ${SITE.name}`,
+ description: "Review your open orders, order history, and completed trades.",
+ path: "/activity",
+ noIndex: true,
+ },
+ "/settings/profile": {
title: `Profile | ${SITE.name}`,
- description: "View your PaperDrill account, balances, and trading history.",
- path: "/profile",
+ description: "Manage your PaperDrill account details and session.",
+ path: "/settings/profile",
+ noIndex: true,
+ },
+ "/settings/api-keys": {
+ title: `API Keys | ${SITE.name}`,
+ description: "Manage scoped API credentials for your trading bots and clients.",
+ path: "/settings/api-keys",
noIndex: true,
},
};
export function resolvePageSeo(pathname: string): PageSeo {
if (ROUTE_SEO[pathname]) return ROUTE_SEO[pathname];
- if (pathname.startsWith("/docs/")) {
- const page = pathname.split("/").at(-1)?.replaceAll("-", " ") ?? "Documentation";
- return {
- title: `${page.replace(/^./, (letter) => letter.toUpperCase())} | ${SITE.name}`,
- description: "PaperDrill API documentation and developer guides.",
- path: pathname,
- };
- }
-
- if (pathname === "/dashboard" || pathname.startsWith("/dashboard/")) {
- const page =
- pathname.split("/").at(-1)?.replace("api-keys", "API Keys").replace("data", "Account Data") ??
- "Dashboard";
- const title =
- pathname === "/dashboard"
- ? "Dashboard"
- : page.replace(/^./, (letter) => letter.toUpperCase());
- return {
- title: `${title} | ${SITE.name}`,
- description: "Manage your PaperDrill account, balances, API keys and trading activity.",
- path: pathname,
- noIndex: true,
- };
- }
const tradeMatch = pathname.match(/^\/trade\/([A-Z_]+)$/);
if (tradeMatch) {
- const symbol = tradeMatch[1]?.replace("_", "/") ?? "BTC/USD";
+ const symbol = tradeMatch[1]?.replaceAll("_", "/") ?? "BTC/USD";
return {
title: `Trade ${symbol} | ${SITE.name}`,
- description: `Live ${symbol} paper trading on PaperDrill — real matching engine, order book depth, and WebSocket market data.`,
+ description: `Trade ${symbol} with credits through PaperDrill's live matching engine, order book depth, and WebSocket market data.`,
path: pathname,
};
}
@@ -142,18 +131,29 @@ export function canonicalUrl(path = "/"): string {
return normalized === "/" ? SITE.url : `${SITE.url}${normalized}`;
}
+export function jsonLdWebPage(title: string, description: string, url: string): object {
+ return {
+ "@context": "https://schema.org",
+ "@type": "WebPage",
+ "@id": `${url}#webpage`,
+ url,
+ name: title,
+ description,
+ inLanguage: "en",
+ isPartOf: { "@id": `${SITE.url}/#website` },
+ };
+}
+
export function jsonLdWebSite(): object {
return {
"@context": "https://schema.org",
"@type": "WebSite",
+ "@id": `${SITE.url}/#website`,
name: SITE.name,
url: SITE.url,
description: SITE.description,
- potentialAction: {
- "@type": "SearchAction",
- target: `${SITE.url}/markets?q={search_term_string}`,
- "query-input": "required name=search_term_string",
- },
+ inLanguage: "en",
+ publisher: { "@id": `${SITE.url}/#organization` },
};
}
@@ -161,10 +161,17 @@ export function jsonLdOrganization(): object {
return {
"@context": "https://schema.org",
"@type": "Organization",
+ "@id": `${SITE.url}/#organization`,
name: SITE.name,
url: SITE.url,
- logo: `${SITE.url}/og-image.png`,
+ logo: {
+ "@type": "ImageObject",
+ url: `${SITE.url}/apple-touch-icon.png`,
+ width: 180,
+ height: 180,
+ },
description: SITE.description,
+ sameAs: [SITE.github],
contactPoint: {
"@type": "ContactPoint",
email: SITE.contact,
@@ -176,12 +183,24 @@ export function jsonLdOrganization(): object {
export function jsonLdSoftwareApplication(): object {
return {
"@context": "https://schema.org",
- "@type": "SoftwareApplication",
+ "@type": "WebApplication",
+ "@id": `${SITE.url}/#application`,
name: SITE.name,
applicationCategory: "FinanceApplication",
+ applicationSubCategory: "Competitive trading",
operatingSystem: "Web",
url: SITE.url,
description: SITE.description,
+ isAccessibleForFree: true,
+ browserRequirements: "Requires a modern web browser with JavaScript enabled.",
+ featureList: [
+ "Competitive credit markets",
+ "Global trading leaderboard",
+ "Live order books and matching engine",
+ "REST API and WebSocket market data",
+ "API keys for trading bots",
+ ],
+ provider: { "@id": `${SITE.url}/#organization` },
offers: {
"@type": "Offer",
price: "0",
diff --git a/frontend/src/lib/theme-provider.tsx b/frontend/src/lib/theme-provider.tsx
index 83c16f4..2491f93 100644
--- a/frontend/src/lib/theme-provider.tsx
+++ b/frontend/src/lib/theme-provider.tsx
@@ -26,6 +26,9 @@ export function ThemeProvider({ children }: { children: React.ReactNode }) {
root.classList.remove("dark");
}
localStorage.setItem("theme", theme);
+ document
+ .querySelector('meta[name="theme-color"]')
+ ?.setAttribute("content", theme === "dark" ? "#0a0a0c" : "#ffffff");
let favicon = document.querySelector('link[data-theme-favicon="true"]');
if (!favicon) {
diff --git a/frontend/src/lib/ux-preferences.ts b/frontend/src/lib/ux-preferences.ts
new file mode 100644
index 0000000..bf7fc72
--- /dev/null
+++ b/frontend/src/lib/ux-preferences.ts
@@ -0,0 +1,138 @@
+import type { CandleInterval } from "@/hooks/use-candles";
+import type { ChartStyle } from "@/components/chart/chart-utils";
+
+const STORAGE_KEY = "paperdrill:ux-preferences:v1";
+export const DEFAULT_TRADE_SYMBOL = "BTC_USD";
+
+const CANDLE_INTERVALS = new Set([
+ "1m",
+ "5m",
+ "15m",
+ "30m",
+ "1H",
+ "4H",
+ "1D",
+]);
+const CHART_STYLES = new Set(["candlestick", "line", "area"]);
+const MARKET_SYMBOL_PATTERN = /^[A-Z0-9]{2,12}_[A-Z0-9]{2,12}$/;
+
+type StoredPreferences = {
+ lastTradeSymbol?: string;
+ chart?: Partial;
+};
+
+export type ChartPreferences = {
+ interval: CandleInterval;
+ style: ChartStyle;
+ showVolume: boolean;
+};
+
+const DEFAULT_CHART_PREFERENCES: ChartPreferences = {
+ interval: "1H",
+ style: "candlestick",
+ showVolume: true,
+};
+
+let cachedPreferences: StoredPreferences | undefined;
+let storageListenerAttached = false;
+const preferenceListeners = new Set<() => void>();
+
+function isRecord(value: unknown): value is Record {
+ return typeof value === "object" && value !== null && !Array.isArray(value);
+}
+
+function attachStorageListener() {
+ if (storageListenerAttached || typeof window === "undefined") return;
+ window.addEventListener("storage", (event) => {
+ if (event.key !== STORAGE_KEY) return;
+ cachedPreferences = undefined;
+ preferenceListeners.forEach((listener) => listener());
+ });
+ storageListenerAttached = true;
+}
+
+function readPreferences(): StoredPreferences {
+ if (cachedPreferences) return cachedPreferences;
+ attachStorageListener();
+ if (typeof window === "undefined") return {};
+
+ try {
+ const raw = window.localStorage.getItem(STORAGE_KEY);
+ if (!raw) return (cachedPreferences = {});
+ const parsed: unknown = JSON.parse(raw);
+ return (cachedPreferences = isRecord(parsed) ? parsed : {});
+ } catch {
+ return (cachedPreferences = {});
+ }
+}
+
+function writePreferences(preferences: StoredPreferences) {
+ cachedPreferences = preferences;
+ if (typeof window !== "undefined") {
+ try {
+ window.localStorage.setItem(STORAGE_KEY, JSON.stringify(preferences));
+ } catch {
+ // Preferences are optional when browser storage is unavailable.
+ }
+ }
+ preferenceListeners.forEach((listener) => listener());
+}
+
+function isMarketSymbol(value: unknown): value is string {
+ return typeof value === "string" && MARKET_SYMBOL_PATTERN.test(value);
+}
+
+export function getLastTradeSymbol() {
+ const symbol = readPreferences().lastTradeSymbol;
+ return isMarketSymbol(symbol) ? symbol : DEFAULT_TRADE_SYMBOL;
+}
+
+export function getLastTradePath() {
+ return `/trade/${getLastTradeSymbol()}`;
+}
+
+export function subscribeToPreferences(listener: () => void) {
+ attachStorageListener();
+ preferenceListeners.add(listener);
+ return () => preferenceListeners.delete(listener);
+}
+
+export function saveLastTradeSymbol(symbol: string) {
+ const normalizedSymbol = symbol.trim().toUpperCase();
+ if (!isMarketSymbol(normalizedSymbol)) return;
+ const currentPreferences = readPreferences();
+ if (currentPreferences.lastTradeSymbol === normalizedSymbol) return;
+
+ writePreferences({
+ ...currentPreferences,
+ lastTradeSymbol: normalizedSymbol,
+ });
+}
+
+export function getChartPreferences(): ChartPreferences {
+ const chart = readPreferences().chart;
+ return {
+ interval:
+ typeof chart?.interval === "string" && CANDLE_INTERVALS.has(chart.interval)
+ ? chart.interval
+ : DEFAULT_CHART_PREFERENCES.interval,
+ style:
+ typeof chart?.style === "string" && CHART_STYLES.has(chart.style)
+ ? chart.style
+ : DEFAULT_CHART_PREFERENCES.style,
+ showVolume:
+ typeof chart?.showVolume === "boolean"
+ ? chart.showVolume
+ : DEFAULT_CHART_PREFERENCES.showVolume,
+ };
+}
+
+export function saveChartPreferences(preferences: Partial) {
+ writePreferences({
+ ...readPreferences(),
+ chart: {
+ ...getChartPreferences(),
+ ...preferences,
+ },
+ });
+}
diff --git a/frontend/src/pages/activity.tsx b/frontend/src/pages/activity.tsx
new file mode 100644
index 0000000..abea862
--- /dev/null
+++ b/frontend/src/pages/activity.tsx
@@ -0,0 +1,33 @@
+import { Link } from "react-router-dom";
+import { DataPanel } from "@/components/market/data-panel";
+import { Button } from "@/components/ui/button";
+import { Page, PageContent } from "@/components/ui/page";
+
+export function ActivityPage() {
+ return (
+
+
+
+
+
+
+
+ );
+}
diff --git a/frontend/src/pages/api-keys.tsx b/frontend/src/pages/api-keys.tsx
new file mode 100644
index 0000000..93d1cc4
--- /dev/null
+++ b/frontend/src/pages/api-keys.tsx
@@ -0,0 +1,294 @@
+import { useCallback, useEffect, useState } from "react";
+import { Link } from "react-router-dom";
+import { toast } from "sonner";
+import { CreateApiKeyDialog } from "@/components/api-keys/create-api-key-dialog";
+import { Button } from "@/components/ui/button";
+import { ConfirmDialog } from "@/components/ui/confirm-dialog";
+import { Page, PageContent } from "@/components/ui/page";
+import { Skeleton } from "@/components/ui/skeleton";
+import { useAuth } from "@/context/AuthContext";
+import { api } from "@/lib/api";
+import { API_KEY_SCOPE_LABELS } from "@/lib/api-key-scopes";
+import { cn } from "@/lib/utils";
+import type { ApiKeyRecord, ApiKeyScope, CreatedApiKey } from "@/types";
+import { formatDateTime } from "@/utils/format";
+
+type ApiKeyRowProps = {
+ record: ApiKeyRecord;
+ verified: boolean;
+ revoking: boolean;
+ onRevoke: (key: ApiKeyRecord) => void;
+};
+
+function ApiKeyRow({ record, verified, revoking, onRevoke }: ApiKeyRowProps) {
+ const active = record.revokedAt === null;
+
+ return (
+
+
+
+ {record.label}
+
+
Created {formatDateTime(record.createdAt)}
+
+
+
+
Permissions
+
+ {record.scopes.map((scope) => API_KEY_SCOPE_LABELS[scope]).join(", ")}
+
+
+
+
+
Last used
+
+ {record.lastUsedAt ? formatDateTime(record.lastUsedAt) : "Never used"}
+
+
+
+
+
+ {active ? "Active" : "Revoked"}
+
+ {active ? (
+ onRevoke(record)}
+ aria-label={`Revoke ${record.label}`}
+ title={verified ? undefined : "Verify your email to revoke API keys"}
+ className="px-2.5 text-medium-emphasis hover:bg-transparent hover:text-red-text"
+ >
+ {revoking ? "Revoking…" : "Revoke"}
+
+ ) : null}
+
+
+ );
+}
+
+function KeysLoading() {
+ return (
+
+ {Array.from({ length: 3 }).map((_, index) => (
+
+ ))}
+
+ );
+}
+
+function KeyListState({
+ title,
+ description,
+ action,
+ error = false,
+}: {
+ title: string;
+ description: string;
+ action?: React.ReactNode;
+ error?: boolean;
+}) {
+ return (
+
+
+
+ {title}
+
+
{description}
+ {action ?
{action}
: null}
+
+
+ );
+}
+
+export function ApiKeysPage() {
+ const { verified } = useAuth();
+ const [keys, setKeys] = useState(null);
+ const [loadError, setLoadError] = useState(null);
+ const [createDialogOpen, setCreateDialogOpen] = useState(false);
+ const [revoking, setRevoking] = useState(null);
+ const [keyToRevoke, setKeyToRevoke] = useState(null);
+
+ const loadKeys = useCallback(async () => {
+ setLoadError(null);
+ try {
+ const response = await api.getApiKeys();
+ setKeys(response.keys);
+ } catch (error) {
+ console.error("Failed to load API keys:", error);
+ setLoadError(error instanceof Error ? error.message : "Failed to load API keys.");
+ }
+ }, []);
+
+ useEffect(() => {
+ void loadKeys();
+ }, [loadKeys]);
+
+ const handleCreate = async (label: string, scopes: ApiKeyScope[]): Promise => {
+ if (!verified) throw new Error("Verify your email before creating an API key.");
+ const key = await api.createApiKey(label, scopes);
+ await loadKeys();
+ toast.success("API key created");
+ return key;
+ };
+
+ const handleRevoke = async () => {
+ if (!verified || !keyToRevoke) return;
+
+ setRevoking(keyToRevoke.id);
+ try {
+ await api.revokeApiKey(keyToRevoke.id);
+ await loadKeys();
+ setKeyToRevoke(null);
+ toast.success("API key revoked");
+ } catch (error) {
+ toast.error(error instanceof Error ? error.message : "Failed to revoke API key");
+ } finally {
+ setRevoking(null);
+ }
+ };
+
+ const createAction = verified ? (
+ setCreateDialogOpen(true)}>
+ Create API key
+
+ ) : (
+
+
+ Verify email to create keys
+
+
+ );
+
+ return (
+
+
+
+
+
+
+
+
+ Credentials
+
+
+ Use a separate key for each integration.
+
+
+
+
+ {!loadError && keys && keys.length > 0 ? (
+
+ Name
+ Permissions
+ Last used
+ Status
+
+ ) : null}
+
+ {loadError ? (
+ void loadKeys()}>
+ Try again
+
+ }
+ />
+ ) : keys === null ? (
+
+ ) : keys.length === 0 ? (
+
+ ) : (
+
+ {keys.map((key) => (
+
+ ))}
+
+ )}
+
+
+
+
+
+
+ !open && setKeyToRevoke(null)}
+ title="Revoke this API key?"
+ description={
+ keyToRevoke
+ ? `Revoke "${keyToRevoke.label}". Applications using it will lose access immediately.`
+ : "Applications using this key will lose access immediately."
+ }
+ confirmLabel="Revoke key"
+ cancelLabel="Keep key"
+ pendingLabel="Revoking…"
+ pending={revoking !== null}
+ onConfirm={() => void handleRevoke()}
+ />
+
+
+ );
+}
diff --git a/frontend/src/pages/dashboard/api-keys.tsx b/frontend/src/pages/dashboard/api-keys.tsx
deleted file mode 100644
index 52be969..0000000
--- a/frontend/src/pages/dashboard/api-keys.tsx
+++ /dev/null
@@ -1,298 +0,0 @@
-import { useEffect, useState } from "react";
-import { Check, Copy, KeyRound, Plus, Trash2, X } from "lucide-react";
-import { Link } from "react-router-dom";
-import { toast } from "sonner";
-import { DashboardPage } from "@/components/dashboard-page";
-import { Button } from "@/components/ui/button";
-import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
-import { Checkbox } from "@/components/ui/checkbox";
-import { Input } from "@/components/ui/input";
-import { Label } from "@/components/ui/label";
-import { Skeleton } from "@/components/ui/skeleton";
-import { useAuth } from "@/context/AuthContext";
-import {
- Table,
- TableBody,
- TableCell,
- TableHead,
- TableHeader,
- TableRow,
-} from "@/components/ui/table";
-import { api } from "@/lib/api";
-import type { ApiKeyRecord, ApiKeyScope, CreatedApiKey } from "@/types";
-import { formatDateTime } from "@/utils/format";
-
-const scopeOptions: { value: ApiKeyScope; label: string; description: string }[] = [
- { value: "ACCOUNT_READ", label: "Read balances", description: "View account balances." },
- { value: "ORDER_READ", label: "Read orders", description: "View orders and trade history." },
- { value: "ORDER_CREATE", label: "Create orders", description: "Place market and limit orders." },
- { value: "ORDER_CANCEL", label: "Cancel orders", description: "Cancel existing open orders." },
-];
-
-const scopeLabels: Record = {
- ACCOUNT_READ: "Balances",
- ORDER_READ: "Read orders",
- ORDER_CREATE: "Create orders",
- ORDER_CANCEL: "Cancel orders",
-};
-
-export function DashboardApiKeysPage() {
- const { verified } = useAuth();
- const [keys, setKeys] = useState(null);
- const [showForm, setShowForm] = useState(false);
- const [label, setLabel] = useState("");
- const [scopes, setScopes] = useState(scopeOptions.map((scope) => scope.value));
- const [creating, setCreating] = useState(false);
- const [deleting, setDeleting] = useState(null);
- const [createdKey, setCreatedKey] = useState(null);
- const [copied, setCopied] = useState(false);
-
- const loadKeys = async () => {
- try {
- const response = await api.getApiKeys();
- setKeys(response.keys);
- } catch (error) {
- console.error("Failed to load API keys:", error);
- setKeys([]);
- toast.error("Failed to load API keys");
- }
- };
-
- useEffect(() => {
- loadKeys();
- }, []);
-
- const toggleScope = (scope: ApiKeyScope, checked: boolean) => {
- setScopes((current) =>
- checked ? [...current, scope] : current.filter((item) => item !== scope),
- );
- };
-
- const handleCreate = async (event: React.FormEvent) => {
- event.preventDefault();
- if (!verified || !label.trim() || scopes.length === 0) return;
-
- setCreating(true);
- try {
- const key = await api.createApiKey(label.trim(), scopes);
- setCreatedKey(key);
- setLabel("");
- setShowForm(false);
- setCopied(false);
- await loadKeys();
- toast.success("API key created");
- } catch (error) {
- toast.error(error instanceof Error ? error.message : "Failed to create API key");
- } finally {
- setCreating(false);
- }
- };
-
- const handleDelete = async (key: ApiKeyRecord) => {
- if (!verified) return;
-
- const confirmed = window.confirm(
- `Delete the API key “${key.label}”? Applications using it will lose access immediately.`,
- );
- if (!confirmed) return;
-
- setDeleting(key.id);
- try {
- await api.revokeApiKey(key.id);
- await loadKeys();
- toast.success("API key deleted");
- } catch (error) {
- toast.error(error instanceof Error ? error.message : "Failed to delete API key");
- } finally {
- setDeleting(null);
- }
- };
-
- const copyKey = async () => {
- if (!createdKey) return;
- try {
- await navigator.clipboard.writeText(createdKey.key);
- setCopied(true);
- toast.success("API key copied");
- } catch {
- toast.error("Could not copy the API key");
- }
- };
-
- return (
- setShowForm((current) => !current)}>
- {showForm ? : }
- {showForm ? "Cancel" : "Create API key"}
-
- ) : (
-
- Verify email to create keys
-
- )
- }
- >
- {createdKey && (
-
-
-
-
Copy your new API key
-
- This key is shown only once. Store it somewhere secure.
-
-
- setCreatedKey(null)}
- aria-label="Dismiss"
- >
-
-
-
-
- event.currentTarget.select()}
- />
-
- {copied ? : }
- {copied ? "Copied" : "Copy"}
-
-
-
- )}
-
- {showForm && verified && (
-
-
- Create API key
-
-
-
-
-
- )}
-
-
- {keys == null ? (
-
- {Array.from({ length: 3 }).map((_, index) => (
-
- ))}
-
- ) : keys.length === 0 ? (
-
-
-
No API keys
-
- Create a key when you are ready to connect a bot.
-
-
- ) : (
-
-
-
-
- Name
- Permissions
- Last used
- Created
- Status
-
- Actions
-
-
-
-
- {keys.map((key) => (
-
-
- {key.label}
-
-
- {key.scopes.map((scope) => scopeLabels[scope]).join(", ")}
-
-
- {key.lastUsedAt ? formatDateTime(key.lastUsedAt) : "Never"}
-
-
- {formatDateTime(key.createdAt)}
-
-
-
- {key.revokedAt ? "Revoked" : "Active"}
-
-
-
- {!key.revokedAt && (
- handleDelete(key)}
- aria-label={`Delete ${key.label}`}
- title={verified ? undefined : "Verify your email to delete API keys"}
- className="hover:text-red-text"
- >
-
-
- )}
-
-
- ))}
-
-
-
- )}
-
-
- );
-}
diff --git a/frontend/src/pages/dashboard/balances.tsx b/frontend/src/pages/dashboard/balances.tsx
deleted file mode 100644
index f8c2efe..0000000
--- a/frontend/src/pages/dashboard/balances.tsx
+++ /dev/null
@@ -1,246 +0,0 @@
-import { useEffect, useMemo } from "react";
-import { toast } from "sonner";
-import { DashboardPage } from "@/components/dashboard-page";
-import { AssetIcon, assetNames } from "@/components/icons/asset-icon";
-import { Skeleton } from "@/components/ui/skeleton";
-import {
- Table,
- TableBody,
- TableCell,
- TableHead,
- TableHeader,
- TableRow,
-} from "@/components/ui/table";
-import { useMarkets } from "@/context/MarketContext";
-import { useBalance } from "@/hooks/use-balance";
-import { usePortfolio } from "@/hooks/use-portfolio";
-import { cn } from "@/lib/utils";
-import type { PortfolioPosition } from "@/types";
-import { formatPrice, formatQty } from "@/utils/format";
-
-type BalanceRow = PortfolioPosition & { precision: number };
-
-export function DashboardBalancesPage() {
- const { markets } = useMarkets();
- const { balances, loading: balanceLoading } = useBalance();
- const { portfolio, loading: portfolioLoading, error: portfolioError } = usePortfolio();
-
- useEffect(() => {
- if (portfolioError) toast.error("Portfolio valuation is temporarily unavailable");
- }, [portfolioError]);
-
- const loading = balanceLoading || portfolioLoading;
-
- const precisionFor = (asset: string) => {
- const market = markets.find((item) => item.baseAsset === asset || item.quoteAsset === asset);
- if (!market) return 4;
- return market.baseAsset === asset ? market.qtyPrecision : market.pricePrecision;
- };
-
- const rows = useMemo(() => {
- if (portfolio) {
- return portfolio.positions
- .map((position) => ({ ...position, precision: precisionFor(position.asset) }))
- .sort((left, right) =>
- left.asset === portfolio.quoteAsset
- ? -1
- : right.asset === portfolio.quoteAsset
- ? 1
- : Number(right.value) - Number(left.value),
- );
- }
-
- return Object.entries(balances ?? {})
- .map(([asset, balance]) => ({
- asset,
- available: balance.available ?? "0",
- locked: balance.locked ?? "0",
- total: String(Number(balance.available ?? 0) + Number(balance.locked ?? 0)),
- markPrice: "",
- value: "",
- precision: precisionFor(asset),
- }))
- .sort((left, right) => (left.asset === "USD" ? -1 : right.asset === "USD" ? 1 : 0));
- }, [balances, markets, portfolio]);
-
- const pnl = Number(portfolio?.pnl ?? 0);
- const pnlClassName = pnl >= 0 ? "text-green-text" : "text-red-text";
- const quotePosition = portfolio?.positions.find(
- (position) => position.asset === portfolio.quoteAsset,
- );
- const lockedValue = portfolio?.positions.reduce(
- (total, position) => total + Number(position.locked) * Number(position.markPrice),
- 0,
- );
-
- return (
-
-
-
- 0 ? "+" : ""}${formatPrice(portfolio.pnl)} ${portfolio.quoteAsset}`
- : "Unavailable"
- }
- valueClassName={pnlClassName}
- />
- 0 ? "+" : ""}${portfolio.pnlPercent}%`
- : "Unavailable"
- }
- valueClassName={pnlClassName}
- />
-
-
-
-
-
-
-
Asset breakdown
-
- Balances, current value and share of your portfolio.
-
-
- {portfolio && lockedValue != null ? (
-
- In open orders:{" "}
-
- {formatPrice(lockedValue)} {portfolio.quoteAsset}
-
-
- ) : null}
-
-
- {loading ? (
-
- {Array.from({ length: 4 }).map((_, index) => (
-
- ))}
-
- ) : rows.length === 0 ? (
-
- No balances available.
-
- ) : (
-
-
-
-
- Asset
- Total
- Available
- Locked
- Mark price
- Value
- Allocation
-
-
-
- {rows.map((row) => {
- const allocation =
- portfolio && Number(portfolio.equity) > 0 && row.value
- ? (Number(row.value) / Number(portfolio.equity)) * 100
- : null;
-
- return (
-
-
-
-
-
-
{row.asset}
-
- {assetNames[row.asset] ?? row.asset}
-
-
-
-
-
- {formatQty(row.total, row.precision)}
-
-
- {formatQty(row.available, row.precision)}
-
-
- {formatQty(row.locked, row.precision)}
-
-
- {row.markPrice ? formatPrice(row.markPrice) : "—"}
-
-
- {row.value
- ? `${formatPrice(row.value)} ${portfolio?.quoteAsset ?? "USD"}`
- : "—"}
-
-
- {allocation == null ? "—" : `${allocation.toFixed(2)}%`}
-
-
- );
- })}
-
-
-
- )}
-
-
- );
-}
-
-function Metric({
- label,
- value,
- className,
- valueClassName,
-}: {
- label: string;
- value: string | null;
- className?: string;
- valueClassName?: string;
-}) {
- return (
-
-
{label}
- {value == null ? (
-
- ) : (
-
- {value}
-
- )}
-
- );
-}
diff --git a/frontend/src/pages/dashboard/data.tsx b/frontend/src/pages/dashboard/data.tsx
deleted file mode 100644
index 99514bb..0000000
--- a/frontend/src/pages/dashboard/data.tsx
+++ /dev/null
@@ -1,15 +0,0 @@
-import { DashboardPage } from "@/components/dashboard-page";
-import { DataPanel } from "@/components/market/data-panel";
-
-export function DashboardDataPage() {
- return (
-
-
-
-
-
- );
-}
diff --git a/frontend/src/pages/dashboard/overview.tsx b/frontend/src/pages/dashboard/overview.tsx
deleted file mode 100644
index e20c233..0000000
--- a/frontend/src/pages/dashboard/overview.tsx
+++ /dev/null
@@ -1,250 +0,0 @@
-import { useEffect, useMemo } from "react";
-import { ArrowRight, Database, KeyRound, WalletCards } from "lucide-react";
-import { Link } from "react-router-dom";
-import { toast } from "sonner";
-import { AssetIcon, assetNames } from "@/components/icons/asset-icon";
-import { DashboardPage } from "@/components/dashboard-page";
-import { Button } from "@/components/ui/button";
-import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
-import { Skeleton } from "@/components/ui/skeleton";
-import { useAuth } from "@/context/AuthContext";
-import { useMarkets } from "@/context/MarketContext";
-import { useOpenOrders, useTradeHistory } from "@/hooks/use-account";
-import { useBalance } from "@/hooks/use-balance";
-import { usePortfolio } from "@/hooks/use-portfolio";
-import { formatDateTime, formatPrice, formatQty } from "@/utils/format";
-
-export function DashboardOverviewPage() {
- const { user } = useAuth();
- const { markets } = useMarkets();
- const { balances, loading: balanceLoading } = useBalance();
- const { portfolio, loading: portfolioLoading, error: portfolioError } = usePortfolio();
- const { openOrders, loading: openOrdersLoading, error: openOrdersError } = useOpenOrders();
- const { trades, loading: tradesLoading, error: tradesError } = useTradeHistory(5);
- const dashboardError = portfolioError ?? openOrdersError ?? tradesError;
-
- useEffect(() => {
- if (!dashboardError) return;
- console.error("Failed to load dashboard:", dashboardError);
- toast.error("Failed to load dashboard overview");
- }, [dashboardError]);
-
- const balanceEntries = useMemo(() => Object.entries(balances), [balances]);
- const pnl = Number(portfolio?.pnl ?? 0);
- const pnlClassName = pnl >= 0 ? "text-green-text!" : "text-red-text!";
-
- const precisionFor = (asset: string) => {
- const market = markets.find((item) => item.baseAsset === asset || item.quoteAsset === asset);
- if (!market) return 4;
- return market.baseAsset === asset ? market.qtyPrecision : market.pricePrecision;
- };
-
- return (
-
-
- Open trading
-
-
- }
- >
-
-
- 0 ? "+" : ""}${formatPrice(portfolio.pnl)} ${portfolio.quoteAsset}`
- : "-"
- }
- valueClassName={pnlClassName}
- />
- 0 ? "+" : ""}${portfolio.pnlPercent}%`
- : "-"
- }
- valueClassName={pnlClassName}
- />
-
-
-
-
-
-
- Balances
-
-
- {balanceLoading ? (
-
-
-
-
- ) : balanceEntries.length === 0 ? (
- No balances available.
- ) : (
- balanceEntries.slice(0, 4).map(([asset, balance]) => (
-
-
-
-
-
{asset}
-
{assetNames[asset] ?? asset}
-
-
-
- {formatQty(balance.available, precisionFor(asset))}
-
-
- ))
- )}
-
-
-
-
-
- Recent trades
-
-
- {tradesLoading ? (
-
-
-
-
- ) : trades.length === 0 ? (
-
- Your completed trades will appear here.
-
- ) : (
- trades.map((trade) => {
- const market = markets.find((item) => item.symbol === trade.symbol);
- return (
-
-
-
-
- {trade.side === "BUY" ? "Bought" : "Sold"}
- {" "}
- {trade.symbol.replace("_", "/")}
-
-
- {formatDateTime(trade.createdAt)}
-
-
-
-
{formatQty(trade.qty, market?.qtyPrecision)}
-
- at {formatPrice(trade.price, market?.pricePrecision)}
-
-
-
- );
- })
- )}
-
-
-
-
-
-
-
-
-
-
- );
-}
-
-function Metric({
- label,
- value,
- className,
- valueClassName,
-}: {
- label: string;
- value: string | null;
- className?: string;
- valueClassName?: string;
-}) {
- return (
-
-
{label}
- {value == null ? (
-
- ) : (
-
- {value}
-
- )}
-
- );
-}
-
-function QuickLink({
- to,
- icon: Icon,
- title,
- text,
-}: {
- to: string;
- icon: typeof KeyRound;
- title: string;
- text: string;
-}) {
- return (
-
-
-
-
-
- );
-}
diff --git a/frontend/src/pages/docs.tsx b/frontend/src/pages/docs.tsx
deleted file mode 100644
index 2ce6e4b..0000000
--- a/frontend/src/pages/docs.tsx
+++ /dev/null
@@ -1,12 +0,0 @@
-import { Navigate, useParams } from "react-router-dom";
-import { MarkdownContent } from "@/components/docs/markdown-content";
-import { getDoc } from "@/content/docs";
-
-export function DocsPage() {
- const { slug = "" } = useParams();
- const doc = getDoc(slug);
-
- if (!doc) return ;
-
- return ;
-}
diff --git a/frontend/src/pages/home.tsx b/frontend/src/pages/home.tsx
new file mode 100644
index 0000000..944b8d8
--- /dev/null
+++ b/frontend/src/pages/home.tsx
@@ -0,0 +1,615 @@
+import { useMemo, useState } from "react";
+import { ArrowUpRight } from "lucide-react";
+import { Link } from "react-router-dom";
+import { MarketPulseChart } from "@/components/home/market-pulse-chart";
+import { AssetIcon } from "@/components/icons/asset-icon";
+import { Button } from "@/components/ui/button";
+import { InlineNotice } from "@/components/ui/feedback-state";
+import { Page, PageContent } from "@/components/ui/page";
+import { Skeleton } from "@/components/ui/skeleton";
+import { useAuth } from "@/context/AuthContext";
+import { useMarkets } from "@/context/MarketContext";
+import { useOpenOrders, useTradeHistory } from "@/hooks/use-account";
+import { usePortfolio } from "@/hooks/use-portfolio";
+import { useTickers } from "@/hooks/use-tickers";
+import { getAssetColor } from "@/lib/asset-colors";
+import { getLastTradeSymbol } from "@/lib/ux-preferences";
+import { cn } from "@/lib/utils";
+import type { Market, OrderRecord, Portfolio, Ticker, UserTrade } from "@/types";
+import { formatChange, formatDateTime, formatPrice, formatQty, formatVolume } from "@/utils/format";
+
+const MANAGEMENT_LINKS = [
+ {
+ to: "/markets",
+ title: "Markets",
+ description: "Compare live prices and choose where to trade.",
+ },
+ {
+ to: "/portfolio",
+ title: "Portfolio",
+ description: "Review allocation, available credits and reserved funds.",
+ },
+ {
+ to: "/activity",
+ title: "Orders & trades",
+ description: "Manage open orders and inspect execution history.",
+ },
+ {
+ to: "/leaderboard",
+ title: "Leaderboard",
+ description: "See how your all-time return compares globally.",
+ },
+ {
+ to: "/settings/api-keys",
+ title: "API keys",
+ description: "Connect bots and server-side trading clients.",
+ },
+] as const;
+
+type ActivityItem = {
+ id: string;
+ kind: "order" | "trade";
+ symbol: string;
+ side: "BUY" | "SELL";
+ qty: string;
+ price: string | null;
+ createdAt: string;
+ detail: string;
+};
+
+function formatMoney(value?: string | number | null, precision = 2) {
+ if (value === undefined || value === null || value === "" || !Number.isFinite(Number(value))) {
+ return "-";
+ }
+ return `$${formatPrice(value, precision)}`;
+}
+
+function formatQuoteVolume(value?: string | number) {
+ const formatted = formatVolume(value);
+ return formatted === "-" ? formatted : `$${formatted}`;
+}
+
+function MarketFocus({
+ market,
+ ticker,
+ markets,
+ loading,
+ error,
+ onSelect,
+}: {
+ market: Market | undefined;
+ ticker: Ticker | undefined;
+ markets: Market[];
+ loading: boolean;
+ error: string | null;
+ onSelect: (symbol: string) => void;
+}) {
+ const symbol = market?.symbol ?? "BTC_USD";
+ const baseAsset = market?.baseAsset ?? symbol.split("_")[0] ?? "BTC";
+ const quoteAsset = market?.quoteAsset ?? symbol.split("_")[1] ?? "USD";
+ const change = formatChange(ticker?.priceChangePercent);
+ const positive = Number(ticker?.priceChangePercent ?? 0) >= 0;
+
+ return (
+
+
+
+
+ Market pulse
+
+
Live price and 72-hour movement.
+
+
+ {markets.map((item) => (
+
onSelect(item.symbol)}
+ aria-pressed={item.symbol === symbol}
+ className={cn(
+ "flex h-8 cursor-pointer items-center gap-2 rounded-md px-2.5 text-xs font-medium whitespace-nowrap outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring",
+ item.symbol === symbol
+ ? "bg-l3 text-high-emphasis"
+ : "text-medium-emphasis hover:bg-l2 hover:text-high-emphasis",
+ )}
+ >
+
+ {item.baseAsset}
+
+ ))}
+
+
+
+
+
+
+
+
+
+
{baseAsset}
+
/{quoteAsset}
+
+
+ {market?.name ?? symbol.replace("_", "/")}
+
+
+
+
+
+ {loading && !ticker ? (
+ <>
+
+
+ >
+ ) : (
+ <>
+
+ {formatMoney(ticker?.lastPrice, market?.pricePrecision)}
+
+ {ticker ? (
+
+ {change.text} today
+
+ ) : (
+
Waiting for live price
+ )}
+ >
+ )}
+
+
+
+
+
+
+
+
24h high
+
+ {formatMoney(ticker?.high, market?.pricePrecision)}
+
+
+
+
24h low
+
+ {formatMoney(ticker?.low, market?.pricePrecision)}
+
+
+
+
24h volume
+
+ {formatQuoteVolume(ticker?.quoteVolume)}
+
+
+
+
+
+
+ {error && !ticker ? "Live ticker data is delayed." : "Prices update as trades settle."}
+
+
+
+ Trade {baseAsset}
+
+
+
+
+
+
+ );
+}
+
+function AccountSnapshot({
+ portfolio,
+ loading,
+ openOrders,
+}: {
+ portfolio: Portfolio | null;
+ loading: boolean;
+ openOrders: number | null;
+}) {
+ const pnl = Number(portfolio?.pnl ?? 0);
+ const quotePosition = portfolio?.positions.find(
+ (position) => position.asset === portfolio.quoteAsset,
+ );
+ const equity = Number(portfolio?.equity ?? 0);
+ const positions = (portfolio?.positions ?? [])
+ .filter((position) => Number(position.value) > 0)
+ .sort((left, right) => Number(right.value) - Number(left.value));
+
+ return (
+
+
+
+
+ Your account
+
+
Credits and current performance.
+
+
+ View portfolio
+
+
+
+
+ {loading ? (
+ <>
+
+
+
+ >
+ ) : (
+ <>
+
Portfolio value
+
+ {portfolio
+ ? `${formatPrice(portfolio.equity)} ${portfolio.quoteAsset}`
+ : "Unavailable"}
+
+ {portfolio ? (
+
+ = 0 ? "text-green-text" : "text-red-text",
+ )}
+ >
+ {pnl > 0 ? "+" : ""}{formatPrice(portfolio.pnl)} {portfolio.quoteAsset}
+
+ = 0 ? "text-green-text" : "text-red-text",
+ )}
+ >
+ {pnl > 0 ? "+" : ""}{portfolio.pnlPercent}%
+
+
+ ) : null}
+ >
+ )}
+
+ {loading ? (
+ <>
+
+
+ >
+ ) : (
+ <>
+
+
+
Capital split
+
+ {positions.length} {positions.length === 1 ? "funded asset" : "funded assets"}
+
+
+
+ {positions.map((position) => (
+ 0 ? (Number(position.value) / equity) * 100 : 0}%`,
+ backgroundColor: getAssetColor(position.asset),
+ }}
+ />
+ ))}
+
+
+ {positions.slice(0, 4).map((position) => (
+
+
+
+ {position.asset}
+
+
+ {equity > 0 ? ((Number(position.value) / equity) * 100).toFixed(1) : "0.0"}%
+
+
+ ))}
+
+
+
+
+
+
Available cash
+
+ {quotePosition && portfolio
+ ? `${formatPrice(quotePosition.available)} ${portfolio.quoteAsset}`
+ : "-"}
+
+
+
+
Open orders
+ {openOrders === null ? (
+
+ ) : (
+
+ {openOrders}
+
+ )}
+
+
+ >
+ )}
+
+
+ );
+}
+
+function ActivityFeed({
+ items,
+ markets,
+ loading,
+}: {
+ items: ActivityItem[];
+ markets: Map;
+ loading: boolean;
+}) {
+ return (
+
+
+
+
+ Recent activity
+
+
Open orders and completed trades.
+
+
+ View all
+
+
+
+ {loading ? (
+
+ {Array.from({ length: 4 }).map((_, index) => (
+
+ ))}
+
+ ) : items.length ? (
+
+ {items.map((item) => {
+ const market = markets.get(item.symbol);
+ const baseAsset = market?.baseAsset ?? item.symbol.split("_")[0] ?? item.symbol;
+ return (
+
+
+
+
+
+ {item.side === "BUY" ? "Buy" : "Sell"}
+ {" "}
+ {item.kind === "order" ? "order open" : "trade completed"}
+
+
+ {item.symbol.replace("_", "/")}, {item.detail}
+
+
+
+
+ {formatQty(item.qty, market?.qtyPrecision)} {baseAsset}
+
+
+ {item.price ? `at ${formatPrice(item.price, market?.pricePrecision)}` : "Market price"}
+
+
+
+ {formatDateTime(item.createdAt)}
+
+
+ );
+ })}
+
+ ) : (
+
+
+
No trading activity yet
+
+ Place your first order to start building a trading record.
+
+
+ Browse markets
+
+
+
+ )}
+
+ );
+}
+
+function ManagementRail() {
+ return (
+
+
+
+ Manage PaperDrill
+
+
Move directly to the work you need.
+
+
+ {MANAGEMENT_LINKS.map((item) => (
+
+
+
{item.title}
+
{item.description}
+
+
+
+ ))}
+
+
+ );
+}
+
+function buildActivity(openOrders: OrderRecord[], trades: UserTrade[]) {
+ const orders: ActivityItem[] = openOrders.map((order) => ({
+ id: order.id,
+ kind: "order",
+ symbol: order.symbol,
+ side: order.side,
+ qty: order.qty,
+ price: order.price,
+ createdAt: order.createdAt,
+ detail: `${order.type === "MARKET" ? "Market" : "Limit"} order`,
+ }));
+ const executions: ActivityItem[] = trades.map((trade) => ({
+ id: trade.id,
+ kind: "trade",
+ symbol: trade.symbol,
+ side: trade.side,
+ qty: trade.qty,
+ price: trade.price,
+ createdAt: trade.createdAt,
+ detail: trade.isMaker ? "Maker execution" : "Taker execution",
+ }));
+
+ return [...orders, ...executions]
+ .sort((left, right) => Date.parse(right.createdAt) - Date.parse(left.createdAt))
+ .slice(0, 6);
+}
+
+export function HomePage() {
+ const { user, verified } = useAuth();
+ const { markets, loading: marketsLoading, error: marketsError } = useMarkets();
+ const { tickers, loading: tickersLoading, error: tickersError } = useTickers();
+ const { portfolio, loading: portfolioLoading, error: portfolioError } = usePortfolio();
+ const { openOrders, loading: openOrdersLoading, error: openOrdersError } = useOpenOrders();
+ const { trades, loading: tradesLoading, error: tradesError } = useTradeHistory(6);
+ const [selectedSymbol, setSelectedSymbol] = useState(getLastTradeSymbol);
+ const featuredMarkets = useMemo(() => markets.slice(0, 3), [markets]);
+ const focusMarket =
+ markets.find((market) => market.symbol === selectedSymbol) ?? featuredMarkets[0] ?? markets[0];
+ const focusSymbol = focusMarket?.symbol ?? "BTC_USD";
+ const activity = useMemo(() => buildActivity(openOrders, trades), [openOrders, trades]);
+ const marketBySymbol = useMemo(
+ () => new Map(markets.map((market) => [market.symbol, market])),
+ [markets],
+ );
+ const accountError = portfolioError ?? openOrdersError ?? tradesError;
+ const marketError = tickersError ?? marketsError;
+ const firstName = user?.name.trim().split(/\s+/)[0] ?? "trader";
+
+ return (
+
+
+
+
+ {!verified ? (
+
+ Verify your email to place orders and create API keys. {" "}
+
+ Verify email
+
+
+ ) : null}
+
+ {accountError ? (
+
+ Some account information could not be refreshed. Available data is still shown.
+
+ ) : null}
+
+
+
+
+
+
+ );
+}
diff --git a/frontend/src/pages/landing.tsx b/frontend/src/pages/landing.tsx
index 43f2690..189b874 100644
--- a/frontend/src/pages/landing.tsx
+++ b/frontend/src/pages/landing.tsx
@@ -1,17 +1,17 @@
import Hero from "@/components/landing/hero";
-import MarketDataSection from "@/components/landing/market-data";
-import MatchingEngineSection from "@/components/landing/matching-engine";
-import PersistentSection from "@/components/landing/persistent";
+import TradingModesSection from "@/components/landing/trading-modes";
+import RankingSection from "@/components/landing/ranking-section";
+import ExchangeCoreSection from "@/components/landing/exchange-core";
import CtaSection from "@/components/landing/cta-section";
export function LandingPage() {
return (
- <>
+
);
}
diff --git a/frontend/src/pages/leaderboard.tsx b/frontend/src/pages/leaderboard.tsx
index f41a0fb..f3d2865 100644
--- a/frontend/src/pages/leaderboard.tsx
+++ b/frontend/src/pages/leaderboard.tsx
@@ -1,25 +1,17 @@
import { useCallback, useEffect, useState } from "react";
import { ChevronLeft, ChevronRight, Trophy } from "lucide-react";
-import { Link } from "react-router-dom";
+import { Link, useSearchParams } from "react-router-dom";
+import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import { Button } from "@/components/ui/button";
-import { Page, PageContent, PageHeader } from "@/components/ui/page";
+import { FeedbackState, InlineNotice } from "@/components/ui/feedback-state";
+import { Page, PageContent, PageHeader, PageHeading } from "@/components/ui/page";
import { Skeleton } from "@/components/ui/skeleton";
-import {
- Table,
- TableBody,
- TableCell,
- TableHead,
- TableHeader,
- TableRow,
-} from "@/components/ui/table";
+import { Surface } from "@/components/ui/surface";
import { useAuth } from "@/context/AuthContext";
import { api } from "@/lib/api";
+import { getLastTradePath } from "@/lib/ux-preferences";
import { cn } from "@/lib/utils";
-import type {
- LeaderboardEntry,
- LeaderboardResponse,
- MyLeaderboardResponse,
-} from "@/types";
+import type { LeaderboardEntry, LeaderboardResponse, MyLeaderboardResponse } from "@/types";
import { formatChange, formatDateTime, formatPrice } from "@/utils/format";
const PAGE_SIZE = 25;
@@ -27,7 +19,20 @@ const REFRESH_INTERVAL = 60_000;
export function LeaderboardPage() {
const { authenticated } = useAuth();
- const [page, setPage] = useState(1);
+ const [searchParams, setSearchParams] = useSearchParams();
+ const pageParam = Number(searchParams.get("page"));
+ const page = Number.isInteger(pageParam) && pageParam > 0 ? pageParam : 1;
+ const setPage = useCallback(
+ (nextPage: number) => {
+ setSearchParams((current) => {
+ const next = new URLSearchParams(current);
+ if (nextPage <= 1) next.delete("page");
+ else next.set("page", String(nextPage));
+ return next;
+ });
+ },
+ [setSearchParams],
+ );
const [leaderboard, setLeaderboard] = useState(null);
const [mine, setMine] = useState(null);
const [loading, setLoading] = useState(true);
@@ -38,26 +43,23 @@ export function LeaderboardPage() {
async (showLoading = false) => {
if (showLoading) setLoading(true);
+ const personalRequest = authenticated
+ ? api.getMyLeaderboardEntry().catch(() => null)
+ : Promise.resolve(null);
+
try {
- const data = await api.getLeaderboard(PAGE_SIZE, offset);
+ const [data, personal] = await Promise.all([
+ api.getLeaderboard(PAGE_SIZE, offset),
+ personalRequest,
+ ]);
setLeaderboard(data);
+ setMine(personal);
setError(null);
} catch (cause) {
setError(cause instanceof Error ? cause.message : "Failed to load leaderboard");
} finally {
setLoading(false);
}
-
- if (!authenticated) {
- setMine(null);
- return;
- }
-
- try {
- setMine(await api.getMyLeaderboardEntry());
- } catch {
- setMine(null);
- }
},
[authenticated, offset],
);
@@ -82,241 +84,570 @@ export function LeaderboardPage() {
const lastVisible = Math.min(offset + PAGE_SIZE, total);
const myEntry = mine?.eligible ? mine.entry : null;
const rows = leaderboard?.entries ?? [];
+ const podiumEntries = page === 1 ? rows.slice(0, 3) : [];
+ const rankingEntries = page === 1 ? rows.slice(3) : rows;
+
+ useEffect(() => {
+ if (leaderboard && page > totalPages) setPage(totalPages);
+ }, [leaderboard, page, setPage, totalPages]);
return (
-
-
-
Leaderboard
-
- Global standings ranked by all-time portfolio return.
-
-
+
+
-
+
{mine?.eligible ? (
) : mine ? (
) : null}
-
-
-
-
Standings
- {leaderboard && (
-
- {total} {total === 1 ? "trader" : "traders"}
-
- )}
-
- {leaderboard && (
-
- Updated {formatDateTime(leaderboard.asOf)}
-
- )}
-
-
- {leaderboard?.stale && (
-
- Updates are delayed. Showing the latest completed standings.
-
- )}
+ {leaderboard?.stale ? (
+
+ Updates are delayed. Showing the latest completed standings.
+
+ ) : null}
- {error && leaderboard && (
-
- The latest standings could not be loaded. Existing results are still shown.
-
- )}
+ {error && leaderboard ? (
+
+ The latest standings could not be loaded. Existing results are still shown.
+
+ ) : null}
- {loading ? (
-
- ) : !leaderboard ? (
+ {loading ? (
+
+ ) : !leaderboard ? (
+
void load(true)} />
- ) : rows.length === 0 ? (
+
+ ) : rows.length === 0 ? (
+
- ) : (
-
+ ) : (
+ <>
+ {podiumEntries.length > 0 ? (
+
+ ) : null}
+
+
- )}
-
- {leaderboard && total > PAGE_SIZE && (
-
-
- {firstVisible}–{lastVisible} of {total}
-
-
- setPage((current) => Math.max(1, current - 1))}
- aria-label="Previous page"
- >
-
-
-
- {page} / {totalPages}
-
- setPage((current) => Math.min(totalPages, current + 1))}
- aria-label="Next page"
- >
-
-
-
-
- )}
-
+ >
+ )}
);
}
-function LeaderboardTable({ entries, quoteAsset, myPosition }: { entries: LeaderboardEntry[]; quoteAsset: string; myPosition?: number }) {
+function Podium({
+ entries,
+ quoteAsset,
+ myPosition,
+}: {
+ entries: LeaderboardEntry[];
+ quoteAsset: string;
+ myPosition?: number;
+}) {
+ const champion = entries[0];
+ if (!champion) return null;
+ const runners = entries.slice(1);
+
return (
-
-
-
- Rank
- Trader
- Return
- PnL
- Portfolio
-
-
-
- {entries.map((entry) => (
-
- ))}
-
-
+
+
+ Leading traders
+
+ 0 && "md:grid-cols-[minmax(0,1.35fr)_minmax(18rem,0.85fr)]",
+ )}
+ >
+
+ {runners.length > 0 ? (
+
+ {runners.map((entry) => (
+
+ ))}
+
+ ) : null}
+
+
);
}
-function LeaderboardTableRow({ entry, quoteAsset, current }: { entry: LeaderboardEntry; quoteAsset: string; current: boolean }) {
+function Champion({
+ entry,
+ quoteAsset,
+ current,
+}: {
+ entry: LeaderboardEntry;
+ quoteAsset: string;
+ current: boolean;
+}) {
const pnl = Number(entry.pnl);
const change = formatChange(entry.pnlPercent);
return (
-
- {entry.rank}
-
-
-
{entry.name}
- {current &&
You }
+
+
+
+
+ Rank #{entry.rank}
-
-
- {change.text}
-
-
- {pnl > 0 ? "+" : ""}{formatPrice(entry.pnl)} {quoteAsset}
-
-
- {formatPrice(entry.equity)} {quoteAsset}
-
-
+ {current ?
Your position : null}
+
+
+
+
+
+
+ {entry.name}
+
+
+ {change.text}
+
+
All-time return
+
+
+
+
+ 0 ? "+" : ""}${formatPrice(entry.pnl)} ${quoteAsset}`}
+ valueClassName={valueTone(entry.pnl)}
+ />
+
+
+
);
}
-function PersonalStanding({ entry, quoteAsset }: { entry: LeaderboardEntry; quoteAsset: string }) {
+function Runner({
+ entry,
+ quoteAsset,
+ current,
+}: {
+ entry: LeaderboardEntry;
+ quoteAsset: string;
+ current: boolean;
+}) {
const pnl = Number(entry.pnl);
const change = formatChange(entry.pnlPercent);
return (
-
-
-
-
-
0 ? "+" : ""}${formatPrice(entry.pnl)} ${quoteAsset}`} className={valueTone(entry.pnl)} />
-
+
+
+
+ #{entry.rank}
+
+
+
+
+
{entry.name}
+ {current ?
You : null}
+
+
+ {pnl > 0 ? "+" : ""}
+ {formatPrice(entry.pnl)} {quoteAsset} PnL
+
+
+
+ {change.text}
+
+
+ );
+}
+
+function RankingsPanel({
+ entries,
+ quoteAsset,
+ myPosition,
+ total,
+ asOf,
+ page,
+ totalPages,
+ firstVisible,
+ lastVisible,
+ onPageChange,
+}: {
+ entries: LeaderboardEntry[];
+ quoteAsset: string;
+ myPosition?: number;
+ total: number;
+ asOf: string;
+ page: number;
+ totalPages: number;
+ firstVisible: number;
+ lastVisible: number;
+ onPageChange: (page: number) => void;
+}) {
+ return (
+
+
+
+
+
+
+ Rankings
+
+
+
Updated {formatDateTime(asOf)}
+
+
Return determines rank
+
+
+
+ Rank
+ Trader
+ Return
+ PnL ({quoteAsset})
+ Portfolio ({quoteAsset})
+
+
+ {entries.length > 0 ? (
+
+ {entries.map((entry) => (
+
+ ))}
+
+ ) : (
+
+ The full ranking will grow as more traders qualify.
+
+ )}
+
+ {total > PAGE_SIZE ? (
+
+
+ {firstVisible}-{lastVisible} of {total}
+
+
+ onPageChange(Math.max(1, page - 1))}
+ aria-label="Previous page"
+ >
+
+
+
+ {page} / {totalPages}
+
+ onPageChange(Math.min(totalPages, page + 1))}
+ aria-label="Next page"
+ >
+
+
+
+
+ ) : null}
+
);
}
-function StandingMetric({ label, value, className }: { label: string; value: string; className?: string }) {
+function RankingRow({
+ entry,
+ quoteAsset,
+ current,
+}: {
+ entry: LeaderboardEntry;
+ quoteAsset: string;
+ current: boolean;
+}) {
+ const pnl = Number(entry.pnl);
+ const change = formatChange(entry.pnlPercent);
+
+ return (
+
+ #{entry.rank}
+
+
+
+
+
{entry.name}
+ {current ?
You : null}
+
+
+ Portfolio {formatPrice(entry.equity)} {quoteAsset}
+
+
+
+
+
+ {change.text}
+
+
+ {pnl > 0 ? "+" : ""}
+ {formatPrice(entry.pnl)}
+
+
+
+ {pnl > 0 ? "+" : ""}
+ {formatPrice(entry.pnl)}
+
+
+ {formatPrice(entry.equity)}
+
+
+ );
+}
+
+function PersonalStanding({ entry, quoteAsset }: { entry: LeaderboardEntry; quoteAsset: string }) {
+ const pnl = Number(entry.pnl);
+ const change = formatChange(entry.pnlPercent);
+
+ return (
+
+
+
+
+
Your standing
+
{entry.name}
+
+
+
+
+ 0 ? "+" : ""}${formatPrice(entry.pnl)} ${quoteAsset}`}
+ valueClassName={valueTone(entry.pnl)}
+ />
+
+ );
+}
+
+function StandingMetric({
+ label,
+ value,
+ valueClassName,
+ className,
+}: {
+ label: string;
+ value: string;
+ valueClassName?: string;
+ className?: string;
+}) {
return (
-
+
{label}
-
{value}
+
+ {value}
+
);
}
-function EligibilityMessage({ reason }: { reason: "EMAIL_NOT_VERIFIED" | "NO_TRADES" | "NOT_CALCULATED" }) {
- const content = reason === "EMAIL_NOT_VERIFIED"
- ? { text: "Verify your email to join the leaderboard.", to: "/verify-email", action: "Verify email" }
- : reason === "NO_TRADES"
- ? { text: "Complete your first trade to join the leaderboard.", to: "/trade/BTC_USD", action: "Start trading" }
- : null;
+function TraderAvatar({
+ entry,
+ className,
+ fallbackClassName,
+}: {
+ entry: LeaderboardEntry;
+ className?: string;
+ fallbackClassName?: string;
+}) {
+ return (
+
+ {entry.avatarUrl ? (
+
+ ) : null}
+
+ {initials(entry.name)}
+
+
+ );
+}
+
+function initials(name: string) {
+ return (
+ name
+ .trim()
+ .split(/\s+/)
+ .slice(0, 2)
+ .map((part) => part[0]?.toUpperCase())
+ .join("") || "T"
+ );
+}
+
+function EligibilityMessage({
+ reason,
+}: {
+ reason: "EMAIL_NOT_VERIFIED" | "NO_TRADES" | "NOT_CALCULATED";
+}) {
+ const content =
+ reason === "EMAIL_NOT_VERIFIED"
+ ? {
+ text: "Verify your email to join the leaderboard.",
+ to: "/verify-email",
+ action: "Verify email",
+ }
+ : reason === "NO_TRADES"
+ ? {
+ text: "Complete your first trade to join the leaderboard.",
+ to: getLastTradePath(),
+ action: "Start trading",
+ }
+ : null;
return (
-
-
{content?.text ?? "Your standing will appear after the next leaderboard update."}
- {content && (
+
+
+ {content?.text ?? "Your standing will appear after the next leaderboard update."}
+
+ {content ? (
{content.action}
- )}
-
+ ) : null}
+
);
}
function UnavailableState({ error, onRetry }: { error: string | null; onRetry: () => void }) {
return (
-
-
-
Leaderboard unavailable
-
{error ?? "The first standings are still being calculated."}
-
Try again
-
+
+ Try again
+
+ }
+ />
);
}
function EmptyState() {
return (
-
-
-
No ranked traders yet
-
Verify your account and complete a trade to enter the standings.
-
Start trading
-
+
+ Start trading
+
+ }
+ />
);
}
function LeaderboardSkeleton() {
return (
-
-
-
- Rank
- Trader
- Return
- PnL
- Portfolio
-
-
-
- {Array.from({ length: 10 }).map((_, index) => (
-
-
-
-
-
-
-
- ))}
-
-
+
+
+
+
+ {Array.from({ length: 2 }).map((_, index) => (
+
+
+
+
+
+
+ ))}
+
+
+
+
+
+
+ {Array.from({ length: 6 }).map((_, index) => (
+
+ ))}
+
+
+
);
}
diff --git a/frontend/src/pages/login.tsx b/frontend/src/pages/login.tsx
index 85a4fc3..81fa203 100644
--- a/frontend/src/pages/login.tsx
+++ b/frontend/src/pages/login.tsx
@@ -1,9 +1,10 @@
+import { AuthShell } from "@/components/auth/auth-shell";
import { LoginForm } from "@/components/login-form";
export function LoginPage() {
return (
-
-
-
+
+
+
);
}
diff --git a/frontend/src/pages/markets.tsx b/frontend/src/pages/markets.tsx
index ffb579d..cadf9ea 100644
--- a/frontend/src/pages/markets.tsx
+++ b/frontend/src/pages/markets.tsx
@@ -1,160 +1,290 @@
-import { useState } from "react";
-import { useNavigate } from "react-router-dom";
-import { ArrowUpRight } from "lucide-react";
+import { useMemo } from "react";
+import { Link, useSearchParams } from "react-router-dom";
+import { ArrowUpRight, Search } from "lucide-react";
+import { AssetIcon } from "@/components/icons/asset-icon";
+import { MarketLineChart } from "@/components/market/market-line-chart";
+import { Button } from "@/components/ui/button";
+import { FeedbackState, InlineNotice } from "@/components/ui/feedback-state";
+import { Input } from "@/components/ui/input";
+import { Page, PageContent } from "@/components/ui/page";
import { Skeleton } from "@/components/ui/skeleton";
-import {
- Table,
- TableBody,
- TableCell,
- TableHead,
- TableHeader,
- TableRow,
-} from "@/components/ui/table";
-import { useTickers } from "@/hooks/use-tickers";
+import { Surface } from "@/components/ui/surface";
import { useMarkets } from "@/context/MarketContext";
-import { Page, PageContent, PageHeader } from "@/components/ui/page";
-import { Button } from "@/components/ui/button";
-import { AssetIcon } from "@/components/icons/asset-icon";
-import { formatPrice, formatVolume, formatChange } from "@/utils/format";
+import { useTickers } from "@/hooks/use-tickers";
+import { cn } from "@/lib/utils";
+import type { Market, Ticker } from "@/types";
+import { formatChange, formatPrice, formatVolume } from "@/utils/format";
-const TABS = ["Spot"];
+interface MarketCardProps {
+ market: Market;
+ ticker?: Ticker;
+ featured?: boolean;
+}
-export function MarketsPage() {
- const { markets, loading: marketsLoading } = useMarkets();
- const { tickers, loading, error } = useTickers();
- const [activeTab, setActiveTab] = useState("Spot");
- const navigate = useNavigate();
+function formatMoney(value?: string | number | null, precision = 2) {
+ if (value === undefined || value === null || value === "" || !Number.isFinite(Number(value)))
+ return "-";
+ return `$${formatPrice(value, precision)}`;
+}
+
+function formatQuoteVolume(value?: string | number) {
+ const formatted = formatVolume(value);
+ return formatted === "-" ? formatted : `$${formatted}`;
+}
+
+function MarketCard({ market, ticker, featured = false }: MarketCardProps) {
+ const change = formatChange(ticker?.priceChangePercent);
return (
-
-
-
-
Spot Markets
-
- Zero-fee sandbox paper trading playground on digital assets
-
-
-
-
-
-
-
-
- {TABS.map((tab) => (
-
setActiveTab(tab)}
- className={`flex justify-center flex-col cursor-pointer rounded-lg py-1 whitespace-nowrap text-[13px] font-semibold px-3 h-8 transition-colors ${
- activeTab === tab
- ? "text-high-emphasis bg-muted"
- : "text-medium-emphasis hover:text-high-emphasis"
- }`}
- >
- {tab}
-
- ))}
+
+
+
+
+
+
+
{market.baseAsset}
+ /{market.quoteAsset}
+
{market.name}
+
+
+
- {error ? (
-
-
Failed to load markets
-
{error}
-
- ) : (
-
-
-
-
- Name
- Price
-
- 24h Volume
-
- 24h Change
-
- Trade
-
-
-
-
- {loading || marketsLoading
- ? Array.from({ length: 3 }).map((_, i) => (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ))
- : markets.map((m) => {
- const ticker = tickers[m.symbol];
- const change = formatChange(ticker?.priceChangePercent);
-
- return (
- navigate(`/trade/${m.symbol}`)}
- >
-
-
-
-
-
{m.baseAsset}
-
{m.name}
-
-
-
-
- {formatPrice(ticker?.lastPrice, m.pricePrecision)}
-
-
- ${formatVolume(ticker?.quoteVolume)}
-
-
-
- {change.text}
-
-
-
- {
- e.stopPropagation();
- navigate(`/trade/${m.symbol}`);
- }}
- >
- Trade
-
-
-
-
- );
- })}
-
-
-
+
+
+ {formatMoney(ticker?.lastPrice, market.pricePrecision)}
+
+
+
+
+
+
+
+
+
+
+
+ );
+}
+
+function MarketStat({ label, value }: { label: string; value: string }) {
+ return (
+
+
{label}
+
+ {value}
+
+
+ );
+}
+
+function MarketCardSkeleton({ featured = false }: { featured?: boolean }) {
+ return (
+
+
+
+
+
+ {Array.from({ length: 3 }).map((_, index) => (
+
+
+
+
+ ))}
+
+
+ );
+}
+
+export function MarketsPage() {
+ const [searchParams, setSearchParams] = useSearchParams();
+ const query = searchParams.get("q") ?? "";
+ const {
+ markets,
+ loading: marketsLoading,
+ error: marketsError,
+ refresh: refreshMarkets,
+ } = useMarkets();
+ const {
+ tickers,
+ loading: tickersLoading,
+ error: tickerError,
+ refresh: refreshTickers,
+ } = useTickers();
+
+ const sortedMarkets = useMemo(
+ () =>
+ [...markets].sort(
+ (a, b) =>
+ Number(tickers[b.symbol]?.quoteVolume ?? 0) - Number(tickers[a.symbol]?.quoteVolume ?? 0),
+ ),
+ [markets, tickers],
+ );
+ const filteredMarkets = useMemo(() => {
+ const normalizedQuery = query.trim().toLowerCase();
+ if (!normalizedQuery) return sortedMarkets;
+ return sortedMarkets.filter((market) =>
+ [market.symbol, market.name, market.baseAsset, market.quoteAsset].some((value) =>
+ value.toLowerCase().includes(normalizedQuery),
+ ),
+ );
+ }, [query, sortedMarkets]);
+
+ const initialLoading = marketsLoading || (tickersLoading && !Object.keys(tickers).length);
+ const updateQuery = (value: string) => {
+ setSearchParams(
+ (current) => {
+ const next = new URLSearchParams(current);
+ const normalized = value.trimStart();
+ if (normalized) next.set("q", normalized);
+ else next.delete("q");
+ return next;
+ },
+ { replace: true },
+ );
+ };
+
+ return (
+
+
+
+
+ {marketsError && !markets.length ? (
+
+ void refreshMarkets()}>
+ Try again
+
+ }
+ />
+
+ ) : (
+ <>
+ {tickerError && (
+
+
+ Live ticker data is temporarily unavailable. Market prices may be incomplete.
+
+
+ Retry
+
+
+ )}
+
+
+ {initialLoading ? (
+
+
+
+
+
+ ) : filteredMarkets.length ? (
+
+ {filteredMarkets.map((market, index) => (
+
+ ))}
+
+ ) : (
+
+
+
+ )}
+
+ >
+ )}
);
diff --git a/frontend/src/pages/not-found.tsx b/frontend/src/pages/not-found.tsx
new file mode 100644
index 0000000..53d6b2c
--- /dev/null
+++ b/frontend/src/pages/not-found.tsx
@@ -0,0 +1,41 @@
+import { Link } from "react-router-dom";
+import { Button } from "@/components/ui/button";
+import { Page, PageContent } from "@/components/ui/page";
+import { useAuth } from "@/context/AuthContext";
+
+export function NotFoundPage() {
+ const { authenticated } = useAuth();
+
+ return (
+
+
+
+
+
Page not found
+
+ This page is not here.
+
+
+ The address may have changed, or the page may no longer exist.
+
+
+
+ Go home
+
+
+ Browse markets
+
+
+
+
+
+ 404
+
+
+
+
+ );
+}
diff --git a/frontend/src/pages/portfolio.tsx b/frontend/src/pages/portfolio.tsx
new file mode 100644
index 0000000..971cff7
--- /dev/null
+++ b/frontend/src/pages/portfolio.tsx
@@ -0,0 +1,468 @@
+import { useMemo, useState } from "react";
+import type { CSSProperties } from "react";
+import { Link } from "react-router-dom";
+import { AssetIcon, assetNames } from "@/components/icons/asset-icon";
+import { Button } from "@/components/ui/button";
+import { InlineNotice } from "@/components/ui/feedback-state";
+import { Page, PageContent } from "@/components/ui/page";
+import { Skeleton } from "@/components/ui/skeleton";
+import { useMarkets } from "@/context/MarketContext";
+import { useBalance } from "@/hooks/use-balance";
+import { usePortfolio } from "@/hooks/use-portfolio";
+import { getAssetColor } from "@/lib/asset-colors";
+import { cn } from "@/lib/utils";
+import type { PortfolioPosition } from "@/types";
+import { formatDateTime, formatPrice, formatQty } from "@/utils/format";
+
+type BalanceRow = PortfolioPosition & {
+ precision: number;
+ allocation: number | null;
+ marketSymbol: string | null;
+};
+
+function allocationBackground(rows: BalanceRow[]) {
+ let cursor = 0;
+ const stops = rows
+ .filter((row) => row.allocation !== null && row.allocation > 0)
+ .map((row) => {
+ const start = cursor;
+ cursor = Math.min(100, cursor + (row.allocation ?? 0));
+ return `${getAssetColor(row.asset)} ${start}% ${cursor}%`;
+ });
+
+ return stops.length ? `conic-gradient(${stops.join(", ")})` : "var(--l2)";
+}
+
+function HoldingRow({ row, quoteAsset }: { row: BalanceRow; quoteAsset: string }) {
+ const tradePath = row.marketSymbol ? `/trade/${row.marketSymbol}` : "/markets";
+
+ return (
+
+
+
+
+
+
{row.asset}
+
+ {assetNames[row.asset] ?? row.asset}
+
+
+
+
+
+
+ {row.value ? `${formatPrice(row.value)} ${quoteAsset}` : "-"}
+
+
+ {formatQty(row.total, row.precision)} {row.asset}
+
+
+
+
+
+ {formatQty(row.available, row.precision)}
+
+
Available
+
+
+
+
0
+ ? "font-medium text-high-emphasis"
+ : "text-medium-emphasis",
+ )}
+ >
+ {formatQty(row.locked, row.precision)}
+
+
Reserved
+
+
+
+
+
+ {row.allocation === null ? "-" : `${row.allocation.toFixed(1)}%`}
+
+
+
+
Allocation
+
+
+
+ {row.marketSymbol ? "Trade" : "Markets"}
+
+
+
+
+
+
Available
+
+ {formatQty(row.available, row.precision)}
+
+
+
+
Reserved
+
+ {formatQty(row.locked, row.precision)}
+
+
+
+
Allocation
+
+ {row.allocation === null ? "-" : `${row.allocation.toFixed(1)}%`}
+
+
+
+
+
+ {row.marketSymbol ? `Trade ${row.asset}` : "Browse markets"}
+
+
+ );
+}
+
+function PortfolioLoading() {
+ return (
+ <>
+
+
+
+
+
+
+
+ {Array.from({ length: 3 }).map((_, index) => (
+
+
+
+
+ ))}
+
+
+
+
+
+ {Array.from({ length: 3 }).map((_, index) => (
+
+ ))}
+
+
+
+
+
+
+
+
+
+
+
+ {Array.from({ length: 4 }).map((_, index) => (
+
+
+
+
+
+ ))}
+
+
+ >
+ );
+}
+
+export function PortfolioPage() {
+ const { markets } = useMarkets();
+ const { balances, loading: balanceLoading, error: balanceError } = useBalance();
+ const { portfolio, loading: portfolioLoading, error: portfolioError } = usePortfolio();
+ const [hideZeroBalances, setHideZeroBalances] = useState(true);
+ const loading = balanceLoading || portfolioLoading;
+
+ const rows = useMemo
(() => {
+ const precisionFor = (asset: string) => {
+ const market = markets.find(
+ (item) => item.baseAsset === asset || item.quoteAsset === asset,
+ );
+ if (!market) return 4;
+ return market.baseAsset === asset ? market.qtyPrecision : market.pricePrecision;
+ };
+ const marketSymbolFor = (asset: string) =>
+ markets.find((market) => market.baseAsset === asset)?.symbol ?? null;
+
+ if (portfolio) {
+ const equity = Number(portfolio.equity);
+ return portfolio.positions
+ .map((position) => ({
+ ...position,
+ precision: precisionFor(position.asset),
+ allocation: equity > 0 ? (Number(position.value) / equity) * 100 : null,
+ marketSymbol: marketSymbolFor(position.asset),
+ }))
+ .sort((left, right) =>
+ left.asset === portfolio.quoteAsset
+ ? -1
+ : right.asset === portfolio.quoteAsset
+ ? 1
+ : Number(right.value) - Number(left.value),
+ );
+ }
+
+ return Object.entries(balances ?? {})
+ .map(([asset, balance]) => {
+ const available = balance.available ?? "0";
+ const locked = balance.locked ?? "0";
+ return {
+ asset,
+ available,
+ locked,
+ total: String(Number(available) + Number(locked)),
+ markPrice: "",
+ value: "",
+ precision: precisionFor(asset),
+ allocation: null,
+ marketSymbol: marketSymbolFor(asset),
+ };
+ })
+ .sort((left, right) => (left.asset === "USD" ? -1 : right.asset === "USD" ? 1 : 0));
+ }, [balances, markets, portfolio]);
+
+ const fundedRows = useMemo(
+ () => rows.filter((row) => Number(row.total) > 0 || Number(row.value) > 0),
+ [rows],
+ );
+ const visibleRows = hideZeroBalances ? fundedRows : rows;
+ const allocationRows = fundedRows.filter(
+ (row) => row.allocation !== null && row.allocation > 0,
+ );
+ const allocationStyle = {
+ background: allocationBackground(allocationRows),
+ } satisfies CSSProperties;
+ const pnl = Number(portfolio?.pnl ?? 0);
+ const pnlClassName = pnl >= 0 ? "text-green-text" : "text-red-text";
+ const quotePosition = portfolio?.positions.find(
+ (position) => position.asset === portfolio.quoteAsset,
+ );
+ const quoteValue = Number(quotePosition?.value ?? 0);
+ const marketExposure = Math.max(0, Number(portfolio?.equity ?? 0) - quoteValue);
+ const lockedValue = portfolio?.positions.reduce(
+ (total, position) => total + Number(position.locked) * Number(position.markPrice),
+ 0,
+ );
+
+ return (
+
+
+
+
+ {balanceError || portfolioError ? (
+
+ Portfolio valuation is temporarily unavailable. Balances already loaded are still shown.
+
+ ) : null}
+
+ {loading ? (
+
+ ) : (
+ <>
+
+ {portfolio?.partial ? (
+
+ Some market prices are unavailable, so the displayed value may be incomplete.
+
+ ) : null}
+
+
+
+
+ Total portfolio value
+
+ {portfolio ? (
+
+ Updated {formatDateTime(portfolio.asOf)}
+
+ ) : null}
+
+
+
+ {portfolio
+ ? `${formatPrice(portfolio.equity)} ${portfolio.quoteAsset}`
+ : "Unavailable"}
+
+
+ {portfolio ? (
+
+
+ {pnl > 0 ? "+" : ""}{formatPrice(portfolio.pnl)} {portfolio.quoteAsset}
+
+
+ {pnl > 0 ? "+" : ""}{portfolio.pnlPercent}%
+
+
+ Since {formatDateTime(portfolio.baselineAt)}
+
+
+ ) : null}
+
+
+
+
Available cash
+
+ {quotePosition && portfolio
+ ? `${formatPrice(quotePosition.available)} ${portfolio.quoteAsset}`
+ : "Unavailable"}
+
+
+
+
Market exposure
+
+ {portfolio
+ ? `${formatPrice(marketExposure)} ${portfolio.quoteAsset}`
+ : "Unavailable"}
+
+
+
+
In open orders
+
+ {portfolio && lockedValue !== undefined
+ ? `${formatPrice(lockedValue)} ${portfolio.quoteAsset}`
+ : "Unavailable"}
+
+
+
+
+
+
+
+
Allocation
+
Current value by asset.
+
+
+ {allocationRows.length ? (
+
+
+
+
+
+ {allocationRows.length}
+
+
+ {allocationRows.length === 1 ? "asset" : "assets"}
+
+
+
+
+
+
+ {allocationRows.map((row) => (
+
+
+
+ {row.asset}
+
+
+ {row.allocation?.toFixed(1)}%
+
+
+ ))}
+
+
+ ) : (
+
+ Allocation appears after your account holds funded assets.
+
+ )}
+
+
+
+
+
+
+
+
+ Holdings
+
+
+ Available funds can trade now. Reserved funds are held by open orders.
+
+
+ {rows.length !== fundedRows.length ? (
+
setHideZeroBalances((current) => !current)}
+ className="text-medium-emphasis"
+ >
+ {hideZeroBalances ? "Show zero balances" : "Hide zero balances"}
+
+ ) : null}
+
+
+ {visibleRows.length ? (
+
+ {visibleRows.map((row) => (
+
+ ))}
+
+ ) : (
+
+
+
No funded balances
+
+ Your credits and traded assets will appear here.
+
+
+ Browse markets
+
+
+
+ )}
+
+ >
+ )}
+
+
+ );
+}
diff --git a/frontend/src/pages/privacy.tsx b/frontend/src/pages/privacy.tsx
index e2cba68..e12d387 100644
--- a/frontend/src/pages/privacy.tsx
+++ b/frontend/src/pages/privacy.tsx
@@ -1,31 +1,12 @@
-import { ContentBlocks } from "@/components/content-blocks";
-import { Page, PageContent, PageHeader } from "@/components/ui/page";
+import { LegalDocument } from "@/components/legal/legal-document";
import { privacy } from "@/content/privacy";
export function PrivacyPage() {
return (
-
-
-
-
Privacy Policy
-
Last updated: {privacy.lastUpdated}
-
-
-
-
-
- {privacy.sections.map((section) => (
-
-
- {section.title}
-
-
-
-
-
- ))}
-
-
-
+
);
}
diff --git a/frontend/src/pages/profile.tsx b/frontend/src/pages/profile.tsx
index 3fe9a56..c6440cb 100644
--- a/frontend/src/pages/profile.tsx
+++ b/frontend/src/pages/profile.tsx
@@ -1,28 +1,95 @@
import { useState } from "react";
-import { Check, Copy, LogOut, Mail, ShieldCheck, UserRound } from "lucide-react";
import { Link, useNavigate } from "react-router-dom";
import { toast } from "sonner";
-import { DashboardPage } from "@/components/dashboard-page";
import { Avatar, AvatarFallback } from "@/components/ui/avatar";
import { Button } from "@/components/ui/button";
-import { Card, CardContent } from "@/components/ui/card";
+import { Page, PageContent } from "@/components/ui/page";
import { useAuth } from "@/context/AuthContext";
import { api } from "@/lib/api";
+function getInitials(name: string) {
+ return name
+ .trim()
+ .split(/\s+/)
+ .slice(0, 2)
+ .map((part) => part[0]?.toUpperCase())
+ .join("");
+}
+
+function DetailRow({
+ label,
+ value,
+ description,
+ action,
+ mono = false,
+}: {
+ label: string;
+ value: string;
+ description: string;
+ action?: React.ReactNode;
+ mono?: boolean;
+}) {
+ return (
+
+
{label}
+
+
+ {value}
+
+
{description}
+
+ {action ?
{action}
: null}
+
+ );
+}
+
+function AccessRow({
+ title,
+ description,
+ action,
+}: {
+ title: string;
+ description: string;
+ action: React.ReactNode;
+}) {
+ return (
+
+
+
{title}
+
{description}
+
+
{action}
+
+ );
+}
+
export function ProfilePage() {
const { user, verified, setUser } = useAuth();
const navigate = useNavigate();
const [copied, setCopied] = useState(false);
+ const [loggingOut, setLoggingOut] = useState(false);
if (!user) return null;
const copyUserId = async () => {
- await navigator.clipboard.writeText(user.id);
- setCopied(true);
- toast.success("Account ID copied");
+ try {
+ await navigator.clipboard.writeText(user.id);
+ setCopied(true);
+ toast.success("Account ID copied");
+ } catch {
+ toast.error("Could not copy the account ID");
+ }
};
const handleLogout = async () => {
+ if (loggingOut) return;
+ setLoggingOut(true);
try {
await api.signout();
} catch (error) {
@@ -35,82 +102,130 @@ export function ProfilePage() {
};
return (
-
- Log out
-
- }
- >
-
-
-
-
-
- {user.name.slice(0, 1).toUpperCase()}
-
-
- {user.name}
- {user.email}
- {verified ? (
-
- Email verified
-
- ) : (
-
- Verify email
-
- )}
-
-
+
+
+
-
-
-
-
-
-
Account ID
+
+
+
+
+
+ {getInitials(user.name)}
+
+
+
+ {user.name}
+
+
{user.email}
+
+
+
+ {verified ? "Email verified" : "Verification required"}
+
+
+ {verified
+ ? "Your account can create orders and API keys."
+ : "Verify your email to unlock account actions."}
+
+
-
-
{user.id}
-
- {copied ? : }
-
+
+
+
+
+ Personal details
+
+
+ Information attached to your PaperDrill account.
+
+
+
+
+
+ Verified
+ ) : (
+
+
+ Verify email
+
+
+ )
+ }
+ />
+
+ {copied ? "Copied" : "Copy"}
+
+ }
+ />
+
-
-
-
- );
-}
+
-function DetailRow({
- icon: Icon,
- label,
- value,
-}: {
- icon: typeof UserRound;
- label: string;
- value: string;
-}) {
- return (
-
-
- {label}
-
-
- {value}
-
-
+
+
+
+ Account access
+
+
+ Manage programmatic access and your current session.
+
+
+
+
+
+ Manage API keys
+
+ }
+ />
+ void handleLogout()}
+ className="hover:border-red-text/40 hover:bg-transparent hover:text-red-text"
+ >
+ {loggingOut ? "Logging out…" : "Log out"}
+
+ }
+ />
+
+
+
+
);
}
diff --git a/frontend/src/pages/signup.tsx b/frontend/src/pages/signup.tsx
index 9096bf2..b38cd28 100644
--- a/frontend/src/pages/signup.tsx
+++ b/frontend/src/pages/signup.tsx
@@ -1,9 +1,10 @@
+import { AuthShell } from "@/components/auth/auth-shell";
import { SignupForm } from "@/components/signup-form";
export function SignupPage() {
return (
-
-
-
+
+
+
);
}
diff --git a/frontend/src/pages/terms.tsx b/frontend/src/pages/terms.tsx
index e6adb7b..0a28185 100644
--- a/frontend/src/pages/terms.tsx
+++ b/frontend/src/pages/terms.tsx
@@ -1,33 +1,12 @@
-import { Page, PageContent, PageHeader } from "@/components/ui/page";
+import { LegalDocument } from "@/components/legal/legal-document";
import { terms } from "@/content/terms";
-import { ContentBlocks } from "@/components/content-blocks";
export function TermsPage() {
return (
-
-
-
-
Terms of Service
-
- Last updated: {terms.lastUpdated}
-
-
-
-
-
-
- {terms.sections.map((section) => (
-
-
- {section.title}
-
-
-
-
-
- ))}
-
-
-
+
);
}
diff --git a/frontend/src/pages/trade.tsx b/frontend/src/pages/trade.tsx
index eaaf141..a2da4bd 100644
--- a/frontend/src/pages/trade.tsx
+++ b/frontend/src/pages/trade.tsx
@@ -1,5 +1,6 @@
-import { useState } from "react";
-import { useParams } from "react-router-dom";
+import { CircleAlert } from "lucide-react";
+import { useEffect } from "react";
+import { Link, useParams, useSearchParams } from "react-router-dom";
import { Chart } from "../components/chart";
import { DataPanel } from "../components/market/data-panel";
import { MarketHeader } from "../components/market/market-header";
@@ -9,28 +10,82 @@ import { TradeForm } from "../components/market/trade-form";
import { Trades } from "../components/market/trades";
import { Page } from "../components/ui/page";
import { Skeleton } from "../components/ui/skeleton";
+import { Button } from "../components/ui/button";
+import { FeedbackState } from "../components/ui/feedback-state";
import { useAuth } from "@/context/AuthContext";
import { useMarkets } from "@/context/MarketContext";
import { useOrderbook } from "@/hooks/use-orderbook";
import { useTickers } from "@/hooks/use-tickers";
import { useTrades } from "@/hooks/use-trades";
+import { useIsMobile } from "@/hooks/use-mobile";
+import { saveLastTradeSymbol } from "@/lib/ux-preferences";
+import { cn } from "@/lib/utils";
+
+const PANEL_CLASS_NAME = "overflow-hidden rounded-xl border border-border/60 bg-l1 shadow-sm";
export function TradePage() {
const { symbol = "BTC_USD" } = useParams();
const { loading: authLoading, authenticated, verified } = useAuth();
- const { markets } = useMarkets();
- const { tickers, loading: tickerLoading } = useTickers();
- const [leftTab, setLeftTab] = useState<"book" | "trades">("book");
- const { orderbook, loading: orderbookLoading, bestBid, bestAsk } = useOrderbook(symbol);
- const { trades, loading: tradesLoading } = useTrades(symbol);
+ const { markets, loading: marketsLoading, error: marketsError, refresh } = useMarkets();
+ const {
+ tickers,
+ loading: tickerLoading,
+ error: tickerError,
+ refresh: refreshTickers,
+ } = useTickers();
+ const [searchParams, setSearchParams] = useSearchParams();
+ const leftTab = searchParams.get("panel") === "trades" ? "trades" : "book";
+ const {
+ orderbook,
+ loading: orderbookLoading,
+ error: orderbookError,
+ refresh: refreshOrderbook,
+ bestBid,
+ bestAsk,
+ } = useOrderbook(symbol);
+ const {
+ trades,
+ loading: tradesLoading,
+ error: tradesError,
+ refresh: refreshTrades,
+ } = useTrades(symbol);
+ const isMobile = useIsMobile();
const ticker = tickers[symbol] ?? null;
+ const marketExists = markets.some((market) => market.symbol === symbol);
+
+ useEffect(() => {
+ if (marketExists) saveLastTradeSymbol(symbol);
+ }, [marketExists, symbol]);
+
+ const setLeftTab = (tab: "book" | "trades") => {
+ setSearchParams((current) => {
+ const next = new URLSearchParams(current);
+ if (tab === "book") next.delete("panel");
+ else next.set("panel", tab);
+ return next;
+ });
+ };
+
+ const handleTabKeyDown = (event: React.KeyboardEvent
) => {
+ if (!["ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key)) return;
+ event.preventDefault();
+ const nextTab = event.key === "ArrowRight" || event.key === "End" ? "trades" : "book";
+ setLeftTab(nextTab);
+ document.getElementById(`${nextTab}-tab`)?.focus();
+ };
const bookTradesTabs = (
-
+
setLeftTab("book")}
- className={`flex h-8 cursor-pointer items-center rounded-lg px-3 text-[13px] font-semibold whitespace-nowrap transition-colors ${
+ onKeyDown={handleTabKeyDown}
+ tabIndex={leftTab === "book" ? 0 : -1}
+ className={`flex h-8 cursor-pointer items-center rounded-lg px-3 text-[13px] font-semibold whitespace-nowrap outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring ${
leftTab === "book"
? "bg-muted text-high-emphasis"
: "text-medium-emphasis hover:text-high-emphasis"
@@ -39,9 +94,15 @@ export function TradePage() {
Book
setLeftTab("trades")}
- className={`flex h-8 cursor-pointer items-center rounded-lg px-3 text-[13px] font-semibold whitespace-nowrap transition-colors ${
+ onKeyDown={handleTabKeyDown}
+ tabIndex={leftTab === "trades" ? 0 : -1}
+ className={`flex h-8 cursor-pointer items-center rounded-lg px-3 text-[13px] font-semibold whitespace-nowrap outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring ${
leftTab === "trades"
? "bg-muted text-high-emphasis"
: "text-medium-emphasis hover:text-high-emphasis"
@@ -52,75 +113,122 @@ export function TradePage() {
);
+ if (marketsLoading && markets.length === 0) {
+ return (
+
+
+
+ );
+ }
+
+ if (marketsError && markets.length === 0) {
+ return (
+
+ void refresh()}>Try again}
+ />
+
+ );
+ }
+
+ if (!marketExists) {
+ return (
+
+
+ Browse markets
+
+ }
+ />
+
+ );
+ }
+
+ const orderbookPanel = (
+
+ );
+ const tradesPanel = (
+
+ );
+
return (
-
-
-
+
+
+
-
-
-
{bookTradesTabs}
-
- {leftTab === "book" ? (
-
- ) : (
-
- )}
-
-
-
-
-
{bookTradesTabs}
-
- {leftTab === "book" ? (
-
- ) : (
-
- )}
-
-
-
-
- {tickerLoading && !ticker ? (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ {tickerLoading && !ticker ? (
+
+
+
+
+
+
+
+
+
+
+
+
+ ) : tickerError && !ticker ? (
+
+ Try again
+
+ }
+ />
+ ) : (
+
+ )}
-
-
+
+
-
+ {!isMobile && (
+
+
{bookTradesTabs}
+
+ {leftTab === "book" ? orderbookPanel : tradesPanel}
+
+
+ )}
+
diff --git a/frontend/src/pages/verify-email.tsx b/frontend/src/pages/verify-email.tsx
index cd40876..6e15db6 100644
--- a/frontend/src/pages/verify-email.tsx
+++ b/frontend/src/pages/verify-email.tsx
@@ -1,12 +1,12 @@
import { useEffect, useState } from "react";
import { Link, useLocation, useNavigate, useSearchParams } from "react-router-dom";
-import { Loader2 } from "lucide-react";
import { useAnalytics } from "@/lib/analytics";
+import { AuthShell } from "@/components/auth/auth-shell";
import { Button } from "@/components/ui/button";
-import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import { useAuth } from "@/context/AuthContext";
import { api } from "@/lib/api";
+import { getSafeReturnTo, type ReturnLocationState } from "@/lib/redirect";
import { toast } from "sonner";
type Status = "waiting" | "verifying" | "success" | "error";
@@ -18,12 +18,16 @@ export function VerifyEmailPage() {
const posthog = useAnalytics();
const navigate = useNavigate();
const location = useLocation();
- const emailWasJustSent = Boolean((location.state as { emailSent?: boolean } | null)?.emailSent);
+ const locationState = location.state as ReturnLocationState | null;
+ const emailWasJustSent = Boolean(locationState?.emailSent);
+ const returnTo = getSafeReturnTo(location.state);
const [status, setStatus] = useState
(token ? "verifying" : "waiting");
+ const [verificationError, setVerificationError] = useState(null);
const [resending, setResending] = useState(false);
const [editingEmail, setEditingEmail] = useState(false);
const [email, setEmail] = useState("");
const [updatingEmail, setUpdatingEmail] = useState(false);
+ const [emailError, setEmailError] = useState(null);
const [resendAt, setResendAt] = useState(() =>
emailWasJustSent ? Date.now() + 30_000 : null,
);
@@ -64,7 +68,9 @@ export function VerifyEmailPage() {
.catch((error) => {
if (!active) return;
setStatus("error");
- toast.error(error instanceof Error ? error.message : "Email verification failed");
+ setVerificationError(
+ error instanceof Error ? error.message : "Email verification failed.",
+ );
});
return () => {
@@ -74,9 +80,9 @@ export function VerifyEmailPage() {
useEffect(() => {
if (!verified) return;
- const timer = window.setTimeout(() => navigate("/dashboard", { replace: true }), 1000);
+ const timer = window.setTimeout(() => navigate(returnTo, { replace: true }), 1000);
return () => window.clearTimeout(timer);
- }, [verified, navigate]);
+ }, [verified, navigate, returnTo]);
const handleResend = async () => {
if (!user || resending || resendAt) return;
@@ -86,7 +92,8 @@ export function VerifyEmailPage() {
setResendAt(Date.now() + 30_000);
setCountdown(30);
setStatus("waiting");
- navigate("/verify-email", { replace: true });
+ setVerificationError(null);
+ navigate("/verify-email", { replace: true, state: { returnTo } });
toast.success(result.message);
} catch (error) {
toast.error(error instanceof Error ? error.message : "Failed to resend verification email");
@@ -98,6 +105,7 @@ export function VerifyEmailPage() {
const handleEmailUpdate = async (event: React.SubmitEvent) => {
event.preventDefault();
if (!user || updatingEmail) return;
+ setEmailError(null);
const nextEmail = email.trim();
if (nextEmail === user.email) {
setEditingEmail(false);
@@ -112,11 +120,12 @@ export function VerifyEmailPage() {
setResendAt(Date.now() + 30_000);
setCountdown(30);
setStatus("waiting");
- navigate("/verify-email", { replace: true });
+ setVerificationError(null);
+ navigate("/verify-email", { replace: true, state: { returnTo } });
posthog.capture("verification_email_updated");
toast.success(message);
} catch (error) {
- toast.error(error instanceof Error ? error.message : "Failed to update email");
+ setEmailError(error instanceof Error ? error.message : "Failed to update email.");
} finally {
setUpdatingEmail(false);
}
@@ -124,105 +133,148 @@ export function VerifyEmailPage() {
if (loading || status === "verifying") {
return (
-
-
- Verifying your email...
-
+
+
+
+
+ Verifying your email
+
+
+ Checking your verification link. This should only take a moment.
+
+
+
);
}
+ const heading = verificationComplete
+ ? "Email verified"
+ : status === "error"
+ ? "Verification failed"
+ : "Check your inbox";
+ const description = verificationComplete
+ ? user
+ ? "Your email is verified. Returning you to PaperDrill."
+ : "Your email is verified. Sign in to continue."
+ : status === "error"
+ ? verificationError ?? "This verification link is invalid or has expired."
+ : user
+ ? "Open the verification email we sent and confirm your address to continue."
+ : "Sign in to request a new verification email.";
+
return (
-
-
-
-
- {verificationComplete
- ? "Email verified"
- : status === "error"
- ? "Verification failed"
- : "Check your inbox"}
-
-
- {verificationComplete ? (
- user
- ? "Your email has been successfully verified. Redirecting to your dashboard..."
- : "Your email has been successfully verified. Sign in to continue."
- ) : user ? (
- <>
- To create your PaperDrill account, click the verification button in the email we
- sent to: {user.email} .
- >
- ) : (
- "Sign in to request a new verification email."
- )}
-
-
-
- {user && !verificationComplete && (
- <>
- {editingEmail ? (
-
+
);
}
diff --git a/frontend/src/types/index.ts b/frontend/src/types/index.ts
index 7819712..db0e9f8 100644
--- a/frontend/src/types/index.ts
+++ b/frontend/src/types/index.ts
@@ -51,6 +51,7 @@ export interface LeaderboardEntry {
position: number;
rank: number;
name: string;
+ avatarUrl?: string | null;
equity: string;
pnl: string;
pnlPercent: string;
diff --git a/frontend/src/utils/format.ts b/frontend/src/utils/format.ts
index 3c07057..d2a1755 100644
--- a/frontend/src/utils/format.ts
+++ b/frontend/src/utils/format.ts
@@ -1,5 +1,5 @@
export function formatPrice(n?: string | number | null, pricePrecision: number = 2) {
- if (n === undefined || n === null || n === "" || !Number.isFinite(Number(n))) return "—";
+ if (n === undefined || n === null || n === "" || !Number.isFinite(Number(n))) return "-";
return Number(n).toLocaleString(undefined, {
minimumFractionDigits: pricePrecision,
@@ -8,7 +8,7 @@ export function formatPrice(n?: string | number | null, pricePrecision: number =
}
export function formatQty(n?: string | number | null, qtyPrecision: number = 4) {
- if (n === undefined || n === null || n === "" || !Number.isFinite(Number(n))) return "—";
+ if (n === undefined || n === null || n === "" || !Number.isFinite(Number(n))) return "-";
return Number(n).toLocaleString(undefined, {
minimumFractionDigits: qtyPrecision,
@@ -17,10 +17,10 @@ export function formatQty(n?: string | number | null, qtyPrecision: number = 4)
}
export function formatVolume(vol?: string | number) {
- if (!vol) return "—";
+ if (!vol) return "-";
const n = Number(vol);
- if (!Number.isFinite(n)) return "—";
+ if (!Number.isFinite(n)) return "-";
if (n >= 1e9) return `${(n / 1e9).toFixed(2)}B`;
if (n >= 1e6) return `${(n / 1e6).toFixed(2)}M`;
@@ -43,7 +43,7 @@ export function formatTime(ts: string | number) {
export function formatDateTime(ts: string | number) {
const date = new Date(ts);
- if (!Number.isFinite(date.getTime())) return "—";
+ if (!Number.isFinite(date.getTime())) return "-";
return date.toLocaleString(undefined, {
month: "short",
day: "numeric",
diff --git a/frontend/styles/globals.css b/frontend/styles/globals.css
index f8d2c94..fb862fd 100644
--- a/frontend/styles/globals.css
+++ b/frontend/styles/globals.css
@@ -59,7 +59,7 @@
}
:root {
- --radius: 0.75rem;
+ --radius: 0.5rem;
--background: #FFFFFF;
--foreground: #09090B;
@@ -92,6 +92,9 @@
--l1: var(--card);
--l2: color-mix(in srgb, var(--muted) 30%, transparent);
--l3: var(--muted);
+ --scrollbar-thumb: color-mix(in srgb, var(--medium-emphasis) 38%, transparent);
+ --scrollbar-thumb-hover: color-mix(in srgb, var(--medium-emphasis) 58%, transparent);
+ --scrollbar-thumb-active: color-mix(in srgb, var(--medium-emphasis) 74%, transparent);
--green-depth: color-mix(in srgb, var(--success) 35%, transparent);
--red-depth: color-mix(in srgb, var(--destructive) 35%, transparent);
@@ -187,13 +190,64 @@
@layer base {
* {
@apply border-border outline-ring/50;
+ scrollbar-color: var(--scrollbar-thumb) transparent;
+ scrollbar-width: thin;
+ }
+
+ *::-webkit-scrollbar {
+ width: 10px;
+ height: 10px;
+ }
+
+ *::-webkit-scrollbar-track,
+ *::-webkit-scrollbar-corner {
+ background: transparent;
+ }
+
+ *::-webkit-scrollbar-thumb {
+ border: 2px solid transparent;
+ border-radius: 999px;
+ background: var(--scrollbar-thumb);
+ background-clip: content-box;
+ }
+
+ *::-webkit-scrollbar-thumb:hover {
+ background-color: var(--scrollbar-thumb-hover);
+ }
+
+ *::-webkit-scrollbar-thumb:active {
+ background-color: var(--scrollbar-thumb-active);
+ }
+
+ html {
+ color-scheme: light;
+ }
+
+ html.dark {
+ color-scheme: dark;
}
body {
@apply bg-background text-foreground;
+ min-width: 320px;
+ min-height: 100dvh;
+ overflow-x: hidden;
font-variant-numeric: tabular-nums;
}
+ button,
+ a,
+ input,
+ select,
+ textarea {
+ touch-action: manipulation;
+ }
+
+ :focus-visible {
+ outline: 2px solid var(--ring);
+ outline-offset: 2px;
+ }
+
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
-webkit-appearance: none;
@@ -205,15 +259,6 @@
appearance: textfield;
}
- * {
- scrollbar-width: none;
- -ms-overflow-style: none;
- }
-
- *::-webkit-scrollbar {
- display: none;
- }
-
.no-scrollbar {
-ms-overflow-style: none;
scrollbar-width: none;
@@ -222,39 +267,19 @@
.no-scrollbar::-webkit-scrollbar {
display: none;
}
-}
-
-@layer components {
- .hljs-comment,
- .hljs-quote {
- color: var(--low-emphasis);
+ .safe-area-bottom {
+ padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
}
- .hljs-keyword,
- .hljs-selector-tag,
- .hljs-literal,
- .hljs-name {
- color: var(--primary);
+ @media (prefers-reduced-motion: reduce) {
+ *,
+ *::before,
+ *::after {
+ scroll-behavior: auto !important;
+ animation-duration: 0.01ms !important;
+ animation-iteration-count: 1 !important;
+ transition-duration: 0.01ms !important;
+ }
}
-
- .hljs-string,
- .hljs-title,
- .hljs-section,
- .hljs-attribute {
- color: var(--green-text);
- }
-
- .hljs-number,
- .hljs-variable,
- .hljs-template-variable,
- .hljs-type {
- color: var(--chart-4);
- }
-
- .hljs-built_in,
- .hljs-symbol,
- .hljs-bullet {
- color: var(--chart-5);
- }
-}
\ No newline at end of file
+}