Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

feat(event-markets): add the /event-markets/leaderboard page with season and all-time boards, pinned own row, rewards panel and scoring rules, wired into vite and the page index

nirholasc2cb17639f08
diff --git a/data/pages.json b/data/pages.json
index a8ee44e42..4b453cd85 100644
--- a/data/pages.json
+++ b/data/pages.json
@@ -1936,6 +1936,14 @@
"changefreq": "hourly",
"added": "2026-10-10"
},
+ {
+ "path": "/event-markets/leaderboard",
+ "title": "Event Markets leaderboard: season rankings and rewards",
+ "description": "Season and all-time rankings for the best event forecasters. Right calls on long odds score the most; streaks, badges and $THREE season rewards.",
+ "priority": 0.7,
+ "changefreq": "hourly",
+ "added": "2026-10-10"
+ },
{
"path": "/event-markets/view",
"title": "Event market",
diff --git a/pages/event-markets-leaderboard.html b/pages/event-markets-leaderboard.html
new file mode 100644
index 000000000..98c88116c
--- /dev/null
+++ b/pages/event-markets-leaderboard.html
@@ -0,0 +1,48 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <script>/* three.ws theme boot, no-flash; runtime in /theme-switcher.js */(function(){try{var m=localStorage.getItem('twx_theme');var l=m==='auto'?(window.matchMedia&&window.matchMedia('(prefers-color-scheme: light)').matches):m==='light';document.documentElement.setAttribute('data-theme',l?'light':'dark');}catch(e){document.documentElement.setAttribute('data-theme','dark');}})();</script>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <title>Event Markets leaderboard: season rankings, streaks and rewards · three.ws</title>
+ <meta name="description" content="Who calls event winners best? Season and all-time rankings, streaks, badges and $THREE rewards. Free to play, scored by how unlikely your call was." />
+ <meta property="og:type" content="website" />
+ <meta property="og:site_name" content="three.ws" />
+ <meta property="og:url" content="https://three.ws/event-markets/leaderboard" />
+ <meta property="og:title" content="Event Markets leaderboard: season rankings, streaks and rewards · three.ws" />
+ <meta property="og:description" content="Who calls event winners best? Season and all-time rankings, streaks, badges and $THREE rewards. Free to play, scored by how unlikely your call was." />
+ <meta property="og:image" content="https://three.ws/api/page-og?s=crypto&amp;t=Event+Markets+Leaderboard&amp;d=Season+rankings%2C+streaks+and+rewards+for+the+best+forecasters.&amp;p=%2Fevent-markets%2Fleaderboard" />
+ <meta property="og:image:width" content="1200" />
+ <meta property="og:image:height" content="630" />
+ <meta name="twitter:card" content="summary_large_image" />
+ <meta name="twitter:site" content="@trythreews" />
+ <meta name="twitter:title" content="Event Markets leaderboard: season rankings, streaks and rewards · three.ws" />
+ <meta name="twitter:image" content="https://three.ws/api/page-og?s=crypto&amp;t=Event+Markets+Leaderboard&amp;d=Season+rankings%2C+streaks+and+rewards+for+the+best+forecasters.&amp;p=%2Fevent-markets%2Fleaderboard" />
+ <meta name="theme-color" content="#0a0a0a" />
+ <meta name="robots" content="index, follow, max-image-preview:large" />
+ <link rel="canonical" href="https://three.ws/event-markets/leaderboard" />
+ <link rel="icon" href="/favicon.ico" sizes="any" />
+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
+ <link rel="stylesheet" href="/fonts/fonts.css" />
+ <link rel="stylesheet" href="/nav.css" />
+ <link rel="stylesheet" href="/src/event-markets/event-markets.css" />
+ <link rel="stylesheet" href="/src/event-markets/leaderboard.css" />
+ <link rel="stylesheet" href="/footer.css" />
+ </head>
+ <body>
+ <header><div id="nav-container"></div></header>
+ <script src="/nav.js"></script>
+ <main id="em-root" class="em">
+ <noscript>
+ <section class="em-hero">
+ <h1>Event Markets leaderboard</h1>
+ <p>Season and all-time rankings for the best event forecasters. Enable JavaScript to see the live board.</p>
+ </section>
+ </noscript>
+ </main>
+ <div id="em-live" class="em-sr" role="status" aria-live="polite"></div>
+ <div id="footer-container"></div>
+ <script src="/footer.js"></script>
+ <script type="module" src="/src/event-markets/leaderboard.js"></script>
+ </body>
+</html>
diff --git a/src/event-markets/leaderboard.css b/src/event-markets/leaderboard.css
new file mode 100644
index 000000000..f10e57133
--- /dev/null
+++ b/src/event-markets/leaderboard.css
@@ -0,0 +1,57 @@
+/* Event Markets leaderboard. Builds on event-markets.css tokens. */
+.lb-bar { display: flex; flex-wrap: wrap; gap: var(--space-sm); align-items: center; justify-content: space-between; margin-bottom: var(--space-md); }
+.lb-filters { display: flex; flex-wrap: wrap; gap: var(--space-sm); align-items: center; }
+.lb-season { color: var(--ink-dim); font-size: var(--text-ui); }
+.lb-layout { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr); gap: var(--space-lg); align-items: start; }
+@media (max-width: 900px) { .lb-layout { grid-template-columns: 1fr; } }
+
+.lb-me { border-color: var(--accent); margin-bottom: var(--space-md); }
+.lb-me h2 { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
+.lb-me .rank { font: var(--weight-bold) var(--text-lg) var(--font-mono); color: var(--ink-bright); }
+.lb-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr)); gap: .6rem; margin: .6rem 0 0; padding: 0; list-style: none; }
+.lb-stats li { background: var(--surface-2); border: 1px solid var(--stroke); border-radius: var(--radius-md); padding: .55rem .7rem; min-width: 0; }
+.lb-stats b { display: block; font: var(--weight-bold) var(--text-lg) var(--font-mono); color: var(--ink-bright); font-variant-numeric: tabular-nums; }
+.lb-stats span { font-size: var(--text-sm); color: var(--ink-dim); }
+
+.lb-scroll { overflow-x: auto; border: 1px solid var(--stroke); border-radius: var(--radius-lg); background: var(--surface-glass); }
+.lb-table { width: 100%; border-collapse: collapse; font-size: var(--text-ui); min-width: 38rem; }
+.lb-table caption { text-align: left; padding: .8rem 1rem .2rem; color: var(--ink-dim); font-size: var(--text-sm); }
+.lb-table th { text-align: right; padding: .6rem .7rem; color: var(--ink-dim); font: var(--weight-semibold) var(--text-sm) var(--font-body); border-bottom: 1px solid var(--stroke); white-space: nowrap; }
+.lb-table td { white-space: nowrap; text-align: right; padding: .6rem .7rem; border-bottom: 1px solid var(--hairline); font-variant-numeric: tabular-nums; font-family: var(--font-mono); color: var(--ink); }
+.lb-table th:nth-child(1), .lb-table td:nth-child(1) { text-align: center; width: 3.2rem; }
+.lb-table th:nth-child(2), .lb-table td:nth-child(2) { text-align: left; font-family: var(--font-body); width: 100%; }
+.lb-table tbody tr:hover { background: var(--surface-2); }
+.lb-table tr[data-mine='true'] { background: var(--accent-soft); }
+.lb-table tr.pinned td { border-top: 2px dashed var(--stroke-strong); }
+.lb-table .gap td { text-align: center; color: var(--ink-dim); font-family: var(--font-body); }
+.lb-rank { font-weight: var(--weight-bold); color: var(--ink-bright); }
+.lb-rank[data-top='true'] { color: var(--accent); }
+.lb-who { display: flex; align-items: center; gap: .6rem; min-width: 0; }
+.lb-who .em-av { width: 2rem; height: 2rem; font-size: var(--text-sm); flex: none; }
+.lb-who a, .lb-who span.nm { color: var(--ink-bright); font-weight: var(--weight-semibold); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 16rem; }
+.lb-who a:hover { text-decoration: underline; }
+.lb-score { color: var(--ink-bright); font-weight: var(--weight-bold); }
+.lb-streak { color: var(--warn); }
+
+.lb-skel { height: 2.6rem; margin: .5rem 0; }
+
+.lb-tier { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .2rem .8rem; padding: .6rem 0; border-bottom: 1px solid var(--hairline); }
+.lb-tier:last-child { border-bottom: 0; }
+.lb-tier b { font-family: var(--font-mono); color: var(--ink-bright); }
+.lb-tier span { color: var(--ink-dim); font-size: var(--text-sm); }
+.lb-rewards { list-style: none; margin: 0; padding: 0; }
+.lb-rewards li { display: grid; grid-template-columns: 2.4rem minmax(0, 1fr) auto; gap: .6rem; padding: .45rem 0; border-bottom: 1px solid var(--hairline); align-items: center; }
+.lb-rewards li:last-child { border-bottom: 0; }
+.lb-rewards .amt { font-family: var(--font-mono); color: var(--ink-bright); }
+
+.lb-how { margin-top: var(--space-lg); }
+.lb-how code { font-family: var(--font-mono); background: var(--surface-2); padding: .1rem .35rem; border-radius: var(--radius-sm); }
+.lb-formula { white-space: pre; font: var(--text-ui) var(--font-mono); background: var(--surface-2); border: 1px solid var(--stroke); border-radius: var(--radius-md); padding: .7rem .9rem; overflow-x: auto; margin: .6rem 0; color: var(--ink-bright); }
+.lb-how table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); margin: .5rem 0 1rem; }
+.lb-how th, .lb-how td { text-align: left; padding: .3rem .5rem; border-bottom: 1px solid var(--hairline); font-variant-numeric: tabular-nums; }
+.lb-how ul { margin: .4rem 0 0; padding-left: 1.2rem; color: var(--ink-dim); line-height: 1.6; }
+.lb-badges { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: .6rem; list-style: none; margin: .6rem 0 0; padding: 0; }
+.lb-badges li { display: flex; gap: .6rem; align-items: flex-start; padding: .6rem .7rem; background: var(--surface-2); border: 1px solid var(--stroke); border-radius: var(--radius-md); }
+.lb-badges .ic { font-size: 1.3rem; line-height: 1; }
+.lb-badges b { color: var(--ink-bright); display: block; }
+.lb-badges span { color: var(--ink-dim); font-size: var(--text-sm); }
diff --git a/src/event-markets/leaderboard.js b/src/event-markets/leaderboard.js
new file mode 100644
index 000000000..b34507a53
--- /dev/null
+++ b/src/event-markets/leaderboard.js
@@ -0,0 +1,236 @@
+// /event-markets/leaderboard: season and all-time rankings, the viewer's own standing,
+// season rewards and the scoring rules. Every number quoted in "How scoring works"
+// comes from `rules` in the API response (data/event-market-scoring.json).
+
+import { h, api, ApiError, SOURCE_LABELS, initials } from './common.js';
+
+const root = document.getElementById('em-root');
+const live = document.getElementById('em-live');
+
+const state = { scope: 'season', season: '', source: 'all', seasons: [], data: null, me: null, signedIn: null, rewards: null, loading: true, error: null, gen: 0 };
+try {
+ const p = new URLSearchParams(location.search);
+ if (p.get('scope') === 'all') state.scope = 'all';
+ if (/^\d{4}-Q[1-4]$/.test(p.get('season') || '')) state.season = p.get('season');
+ if (p.get('source') in SOURCE_LABELS) state.source = p.get('source');
+} catch { /* defaults */ }
+
+const els = {};
+const announce = (m) => { live.textContent = m; };
+const num = (n) => Number(n || 0).toLocaleString('en-US');
+const prob = (p) => (p == null ? 'n/a' : `${Math.round(p * 100)}%`);
+const rate = (r) => (r == null ? 'n/a' : `${Math.round(r * 100)}%`);
+
+function syncUrl() {
+ const p = new URLSearchParams();
+ if (state.scope === 'all') p.set('scope', 'all');
+ else if (state.season && state.season !== state.data?.currentSeasonId) p.set('season', state.season);
+ if (state.source !== 'all') p.set('source', state.source);
+ history.replaceState(null, '', `${location.pathname}${p.size ? `?${p}` : ''}`);
+}
+
+function who(r) {
+ const av = h('span', { class: 'em-av', 'aria-hidden': 'true' }, r.avatar ? h('img', { src: r.avatar, alt: '', loading: 'lazy', referrerpolicy: 'no-referrer' }) : initials(r.name));
+ const name = r.profile ? h('a', { href: r.profile }, r.name) : h('span', { class: 'nm' }, r.name);
+ return h('div', { class: 'lb-who' }, av, name);
+}
+
+function row(r, extra = '') {
+ return h('tr', { 'data-mine': r.is_me ? 'true' : null, class: extra },
+ h('td', null, h('span', { class: 'lb-rank', 'data-top': r.rank <= 3 ? 'true' : null }, r.rank == null ? '-' : `#${r.rank}`)),
+ h('td', null, who(r), r.is_me ? h('span', { class: 'em-sr' }, ' (you)') : null),
+ h('td', { class: 'lb-score' }, num(r.score)),
+ h('td', null, num(r.calls)),
+ h('td', null, rate(r.hit_rate)),
+ h('td', null, prob(r.avg_odds)),
+ h('td', null, r.best_call > 0 ? `+${num(r.best_call)}` : '-'),
+ h('td', { class: r.current_streak >= 3 ? 'lb-streak' : '' }, `${r.current_streak} / ${r.longest_streak}`));
+}
+
+function signIn() {
+ location.href = `/app?next=${encodeURIComponent(location.pathname + location.search)}`;
+}
+
+function skeleton() {
+ return h('div', { 'aria-busy': 'true', 'aria-label': 'Loading leaderboard' }, ...Array.from({ length: 8 }, () => h('div', { class: 'em-skel lb-skel' })));
+}
+
+function emptyState(d) {
+ const min = d?.min_calls_to_rank || 3;
+ return h('div', { class: 'em-state' },
+ h('h2', null, state.scope === 'season' ? 'Nobody is ranked yet this season' : 'No ranked calls yet'),
+ h('p', null, `Make ${min} calls on open markets to take a place on the board. Calls are free and score by how unlikely they were.`),
+ h('div', { class: 'row' }, h('a', { class: 'em-btn primary', href: '/event-markets' }, 'Browse open markets')));
+}
+
+function errorState(err) {
+ return h('div', { class: 'em-state' },
+ h('h2', null, 'Could not load the leaderboard'),
+ h('p', null, err.message || 'Something went wrong.'),
+ h('div', { class: 'row' }, h('button', { class: 'em-btn primary', type: 'button', onclick: load }, 'Retry')));
+}
+
+function board() {
+ const d = state.data;
+ if (state.loading && !d) return skeleton();
+ if (state.error && !d) return errorState(state.error);
+ if (!d.leaders.length && !d.me) return emptyState(d);
+ const meInList = d.me && d.leaders.some((r) => r.is_me);
+ const body = h('tbody', null, d.leaders.map((r) => row(r)));
+ if (d.me && !meInList) {
+ body.append(h('tr', { class: 'gap' }, h('td', { colspan: 8 }, '...')));
+ body.append(row(d.me, 'pinned'));
+ }
+ const cap = state.scope === 'all' ? 'All-time ranking' : `${d.season.label} ranking`;
+ return h('div', { class: 'lb-scroll' },
+ h('table', { class: 'lb-table' },
+ h('caption', null, `${cap}${state.source !== 'all' ? `, ${SOURCE_LABELS[state.source]}` : ''}. Ranked after ${d.min_calls_to_rank} calls.`),
+ h('thead', null, h('tr', null, ...['Rank', 'Forecaster', 'Score', 'Calls', 'Hit rate', 'Avg odds', 'Best call', 'Streak'].map((t) => h('th', { scope: 'col', title: t === 'Streak' ? 'Current / longest' : t === 'Avg odds' ? 'Average chance the market gave your pick when you made it' : null }, t)))),
+ body));
+}
+
+function myCard() {
+ const m = state.me;
+ if (state.signedIn === false) {
+ return h('section', { class: 'em-panel lb-me' }, h('h2', null, 'Your standing'),
+ h('p', { class: 'em-note' }, 'Sign in to see your rank, streak and badges.'),
+ h('button', { class: 'em-btn primary', type: 'button', onclick: signIn }, 'Sign in'));
+ }
+ if (!m) return h('div', { class: 'em-skel lb-skel', style: 'height:7rem' });
+ const s = m.season_standing, a = m.all_time;
+ if (!a) {
+ return h('section', { class: 'em-panel lb-me' }, h('h2', null, 'Your standing'),
+ h('p', { class: 'em-note' }, 'You have no scored calls yet. Pick a winner on any open market and your stats start here.'),
+ h('a', { class: 'em-btn primary', href: '/event-markets' }, 'Make a call'));
+ }
+ const stat = (v, l) => h('li', null, h('b', null, v), h('span', null, l));
+ return h('section', { class: 'em-panel lb-me' },
+ h('h2', null, 'Your standing', h('span', { class: 'rank' }, s?.rank ? `#${s.rank} this season` : 'Unranked this season')),
+ h('ul', { class: 'lb-stats' },
+ stat(num(a.score), 'All-time score'), stat(num(a.calls), 'Calls'), stat(rate(a.hit_rate), 'Hit rate'),
+ stat(prob(a.avg_odds), 'Avg odds at pick'), stat(`${a.current_streak}`, 'Current streak'), stat(`${a.longest_streak}`, 'Longest streak')),
+ h('p', { class: 'em-note' }, 'Badges you earn show on ', a.profile ? h('a', { href: a.profile }, 'your profile') : 'your profile', '.'));
+}
+
+function rewardsPanel() {
+ const r = state.rewards;
+ if (!r) return h('section', { class: 'em-panel' }, h('h2', null, 'Season rewards'), h('div', { class: 'em-skel lb-skel' }));
+ const tiers = h('div', null, r.tiers.map((t) => h('div', { class: 'lb-tier' }, h('b', null, `#${t.ranks}`), h('div', null, h('b', null, `${num(t.three)} $THREE`), h('br'), h('span', null, t.perk)))));
+ let list = null;
+ if (r.published && r.rewards.length) {
+ list = h('div', null,
+ h('h3', { class: 'em-note' }, `${r.season.label} winners`),
+ h('ol', { class: 'lb-rewards' }, r.rewards.map((w) => h('li', null, h('b', null, `#${w.rank}`), w.profile ? h('a', { href: w.profile }, w.name) : w.name, h('span', { class: 'amt' }, `${num(w.amount)} ${w.token}`)))),
+ h('p', { class: 'em-note' }, r.rewards.some((w) => w.status === 'paid') ? 'Paid rewards are on-chain.' : 'This list is a proposal until the owner approves the payout.'));
+ }
+ return h('section', { class: 'em-panel' }, h('h2', null, 'Season rewards'),
+ h('p', { class: 'em-note' }, 'Top forecasters each season earn $THREE on Solana plus platform perks.'), tiers, list);
+}
+
+const BADGE_COPY = [
+ ['✅', 'First correct call', 'Your first right pick.'],
+ ['⚡', 'Upset call', 'Right when the market gave the pick under {u}%.'],
+ ['🔥', '{s} in a row', '{s} correct calls without a miss.'],
+ ['🏆', 'Season top {t}', 'Finish a season in the top {t}.'],
+];
+
+function how() {
+ const R = state.data?.rules;
+ if (!R) return null;
+ const { min_win_multiplier: lo, max_win_multiplier: hi } = R.scoring;
+ const fill = (t) => t.replace(/\{u\}/g, Math.round(R.badges.upset_probability_below * 100)).replace(/\{s\}/g, R.badges.streak_target).replace(/\{t\}/g, R.badges.season_top_n);
+ const ex = [0.8, 0.5, 0.2, 0.05].map((p) => {
+ const m = Math.min(hi, Math.max(lo, 1 / p - 1));
+ return h('tr', null, h('td', null, `${Math.round(p * 100)}%`), h('td', null, `x${+m.toFixed(2)}`), h('td', null, `+${Math.round(100 * m)}`), h('td', null, '-100'));
+ });
+ const f = R.fairness;
+ return h('section', { class: 'em-panel lb-how' }, h('h2', null, 'How scoring works'),
+ h('p', { class: 'em-note' }, 'You back one entrant per market. The earlier the call and the longer the odds, the more a right call is worth.'),
+ h('div', { class: 'lb-formula' }, `win = round(stake x clamp(1 / p - 1, ${lo}, ${hi}))\nloss = -stake\nscore = running total, never below 0`),
+ h('p', { class: 'em-note' }, 'p is the market\'s chance for your pick at the moment you made it. Worked examples on a 100-point stake:'),
+ h('table', null, h('thead', null, h('tr', null, ['Odds at pick', 'Multiplier', 'Right', 'Wrong'].map((t) => h('th', { scope: 'col' }, t)))), h('tbody', null, ex)),
+ h('p', { class: 'em-note' }, `Seasons are calendar quarters (UTC). You rank after ${R.seasons.min_calls_to_rank} resolved calls. Void markets do not count.`),
+ h('h3', null, 'Badges'),
+ h('ul', { class: 'lb-badges' }, BADGE_COPY.map(([ic, t, d]) => h('li', null, h('span', { class: 'ic', 'aria-hidden': 'true' }, ic), h('div', null, h('b', null, fill(t)), h('span', null, fill(d)))))),
+ h('h3', null, 'Fair play'),
+ h('ul', null,
+ h('li', null, 'One account, one pick per market. Changing a pick before lock replaces it.'),
+ h('li', null, `Accounts must be at least ${f.min_account_age_hours} hours old to rank.`),
+ f.require_linked_wallet_or_verified_email ? h('li', null, 'A linked wallet or a verified email is required to rank.') : null,
+ f.exclude_service_accounts ? h('li', null, 'Service and agent-operated accounts are excluded from human rankings.') : null,
+ h('li', null, 'Picks that do not pass these checks still play, they just do not rank or earn rewards.')));
+}
+
+function controls() {
+ const seasonSel = h('select', { class: 'em-select', id: 'lb-season', 'aria-label': 'Season', disabled: state.scope === 'all' ? true : null,
+ onchange: (e) => { state.season = e.target.value; load(); } },
+ state.seasons.map((s) => h('option', { value: s.id, selected: s.id === state.season ? true : null }, s.label)));
+ const srcSel = h('select', { class: 'em-select', id: 'lb-source', 'aria-label': 'Market source',
+ onchange: (e) => { state.source = e.target.value; load(); } },
+ h('option', { value: 'all' }, 'All sources'),
+ Object.entries(SOURCE_LABELS).map(([k, v]) => h('option', { value: k, selected: k === state.source ? true : null }, v)));
+ const tab = (id, label) => h('button', { class: 'em-tab', type: 'button', role: 'tab', 'aria-selected': state.scope === id ? 'true' : 'false',
+ onclick: () => { state.scope = id; load(); } }, label);
+ return h('div', { class: 'lb-bar' },
+ h('div', { class: 'em-tabs', role: 'tablist', style: 'margin:0;border:0' }, tab('season', 'This season'), tab('all', 'All time')),
+ h('div', { class: 'lb-filters' }, seasonSel, srcSel));
+}
+
+function render() {
+ const d = state.data;
+ const sub = state.scope === 'all' ? 'Every ranked call, all time.' : d ? `${d.season.label}${d.season.ended ? ' (final)' : `, ends ${new Date(d.season.end).toLocaleDateString(undefined, { month: 'short', day: 'numeric' })}`}` : '';
+ root.replaceChildren(
+ h('section', { class: 'em-hero' },
+ h('h1', null, 'Event Markets leaderboard'),
+ h('p', null, 'The sharpest forecasters on three.ws. Right calls on long odds score the most; wrong calls cost the stake.'),
+ h('p', { class: 'lb-season' }, sub, ' ', h('a', { href: '/event-markets' }, 'Browse markets'))),
+ controls(),
+ h('div', { class: 'lb-layout' },
+ h('div', null, board()),
+ h('aside', null, myCard(), rewardsPanel())),
+ how());
+}
+
+async function load() {
+ const gen = ++state.gen;
+ state.loading = true; state.error = null;
+ if (!state.data) render();
+ try {
+ const qs = new URLSearchParams({ scope: state.scope, source_kind: state.source, limit: '50' });
+ if (state.scope === 'season' && state.season) qs.set('season', state.season);
+ const d = await api(`/leaderboard?${qs}`);
+ if (gen !== state.gen) return;
+ d.currentSeasonId = state.data?.currentSeasonId || d.season?.id;
+ state.data = d;
+ if (d.season && !state.season) state.season = d.season.id;
+ state.rewards = null;
+ syncUrl();
+ render();
+ announce(`${d.leaders.length} forecasters shown.`);
+ const rid = state.scope === 'season' ? state.season : state.seasons.find((s) => s.ended)?.id;
+ api(`/seasons/${rid || state.season}/rewards`).then((r) => { if (gen === state.gen) { state.rewards = r; render(); } }).catch(() => {
+ if (gen === state.gen) { state.rewards = { tiers: d.rules.rewards.tiers.map((t) => ({ ...t, ranks: t.from_rank === t.to_rank ? `${t.from_rank}` : `${t.from_rank}-${t.to_rank}` })), published: false, rewards: [] }; render(); }
+ });
+ } catch (err) {
+ if (gen !== state.gen) return;
+ state.error = err;
+ state.loading = false;
+ render();
+ announce(err.message);
+ return;
+ }
+ state.loading = false;
+ render();
+}
+
+async function init() {
+ render();
+ const [seasons] = await Promise.all([
+ api('/seasons').catch(() => null),
+ api('/me').then((m) => { state.me = m; state.signedIn = true; }).catch((e) => { state.signedIn = e instanceof ApiError && e.status === 401 ? false : null; }),
+ ]);
+ state.seasons = seasons?.seasons || [];
+ await load();
+}
+
+init();
diff --git a/vite.config.js b/vite.config.js
index 8386f1075..38d19a76a 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -707,6 +707,7 @@ const appConfig = {
'x-claim': resolve(__dirname, 'pages/x-claim.html'),
'event-market-announcements': resolve(__dirname, 'pages/event-market-announcements.html'),
'event-markets': resolve(__dirname, 'pages/event-markets.html'),
+ 'event-markets-leaderboard': resolve(__dirname, 'pages/event-markets-leaderboard.html'),
'event-market': resolve(__dirname, 'pages/event-market.html'),
awesome: resolve(__dirname, 'pages/awesome.html'),
prompts: resolve(__dirname, 'pages/prompts.html'),
@@ -1914,6 +1915,7 @@ const appConfig = {
'/admin/event-market-announcements': resolve(root, 'pages/event-market-announcements.html'),
'/event-markets': resolve(root, 'pages/event-markets.html'),
'/event-markets/': resolve(root, 'pages/event-markets.html'),
+ '/event-markets/leaderboard': resolve(root, 'pages/event-markets-leaderboard.html'),
'/event-markets/view': resolve(root, 'pages/event-market.html'),
'/x/claim': resolve(root, 'pages/x-claim.html'),
'/x/claim/': resolve(root, 'pages/x-claim.html'),