← Back
Play

Crypto Challenge

A multiplayer crypto portfolio simulation where students trade crypto using live market data, build portfolios, create research-backed strategies (Strats), and compete in seasonal leaderboards. Designed to teach portfolio construction, risk assessment, and market analysis to high school students.

Game Flow

Unlike action-based games, Crypto Challenge is an ongoing simulation with no fixed phases. Players navigate freely between four screens:

Home → Price Tracker ↔ Trading Desk ↔ Performance Center
  • Home (/crypto-challenge): Hero section, scrolling market ticker (top 50 coins), 3-step loop guide, starter quest checklist, current portfolio summary, coach toast notifications
  • Price Tracker (/crypto-challenge/price-tracker): Top 250 coins by market cap, filterable by 9 bucket categories, sortable columns, watchlist starring
  • Trading Desk (/crypto-challenge/trading-desk): Buy/sell order ticket (USD or quantity mode), inline Strat creation, holdings table with P&L, trade history, portfolio summary
  • Performance Center (/crypto-challenge/performance-center): KPI cards (cash, crypto value, total return), allocation donut chart, top 5 contributors by P&L, trade log, active Strats with countdowns and reward tiers

Core Loop

  1. Pick Coins: Browse the Price Tracker, filter by sector buckets, add to watchlist
  2. Place Trades: Buy/sell on the Trading Desk, optionally attach a Strat with direction, target %, and time horizon
  3. Track Performance: Review returns, allocation, contributors, and Strat outcomes in the Performance Center
  4. Iterate: Refine strategies, rebalance, pursue Strat reward tiers

Market Data

  • Source: CoinGecko API (Top 250 by market cap)
  • Cache: Server-side 60s TTL, client-side 1.5s minimum between refreshes, stale fallback on failure
  • API route: /api/crypto-challenge/markets

Buckets (9 categories)

KeyCategoryExamples
l1Layer 1Bitcoin, Ethereum, Solana
l2Layer 2 & ScalingArbitrum, Polygon, Optimism
stableStablecoinsUSDT, USDC, DAI
defiDeFiUniswap, Aave, Maker
infraInfrastructureChainlink, The Graph
utilityUtility & GovernanceBNB, OKB
nftNFT/Metaverse/GamingDecentraland, The Sandbox
privacyPrivacy CoinsMonero, Zcash
memeMeme & CommunityDogecoin, Shiba Inu

Categorization uses hardcoded lists plus heuristic matching on symbol/name.

Scoring

Primary Metric: Cumulative Return

Return = (NAV - Effective Starting Cash) / Effective Starting Cash
  • NAV = cash + bonus cash + sum of (position quantity x latest price)
  • Effective Starting Cash = starting cash ($100,000) + total bonus rewards earned
  • Positions use average cost basis across buys

Strat Rewards

Strats are research-backed trade theses. When a Strat's linked position hits a return tier, the player earns bonus cash:

Return TierReward
3%$100
5%$300
10%$1,000
25%$5,000
50%$20,000

Evaluation modes:

  • Instant (no horizon set): Resolves as soon as the position crosses a tier threshold
  • Time-bound (horizon in days): Evaluates at due time; success requires the direction (up/down) and optional target % to be met

Reward cash is added to bonusUsdTotal and counts toward NAV. Max 3 active Strats per player.

Starter Quest Rewards

One-time bonuses for completing onboarding actions:

QuestReward
Watchlist first coin$500
First trade$2,000
Link a Strat to a trade$5,000
Visit Performance Center$500

Daily Quest

Tag a trade with a Strat for a $5 bonus (once per day).

Seasons

  • 6-month seasons based on a UTC baseline (default: July 1, 2025)
  • Scores reset each season
  • Highest cumulative return wins the season leaderboard

Technical Architecture

Key Files

AreaFilePurpose
Enginegames/crypto-challenge/store.tsZustand store: portfolio state, order submission, performance calculations
App Datagames/crypto-challenge/models/app-data.tsAppData structure, sanitization, version normalization
Tradinggames/crypto-challenge/models/trading.tsTrade, TradingState, buildTrade(), snapshotPortfolio(), validateOrder()
Marketgames/crypto-challenge/models/market.tsMarketCoin, MarketsPayload types
Researchgames/crypto-challenge/models/research.tsStrat, Research, blankResearch()
Strat Evalgames/crypto-challenge/models/strat-evaluator.tsevaluateStrats(), StratResolution
Rewardsgames/crypto-challenge/models/rewards.tsapplyStarterQuestReward(), STARTER_QUEST_CONFIG
Configgames/crypto-challenge/models/config.tsSTRAT_REWARD_TIERS, getCurrentSeasonInfo(), DEFAULT_START_CASH
Bucketsgames/crypto-challenge/models/categorize.tscategorize(), bucket classification logic
CoinGeckogames/crypto-challenge/models/coingecko.tsCoingeckoMarketRepository, cached fetch with stale fallback
Portsgames/crypto-challenge/models/ports.tsMarketRepository interface
Utilsgames/crypto-challenge/utils.tsformatUSD(), formatPercent(), classForChange()
Hookgames/crypto-challenge/hooks/use-game-actions.tsuseGameActions(), submitPortfolioScore()

Components

Home:

ComponentPurpose
crypto-home.tsxHome page layout
hero.tsxHero section with CTA
market-ticker.tsxScrolling marquee of top 50 coins
loop-stepper.tsx3-step onboarding guide
beginners-rewards.tsxStarter quest checklist with progress
current-assets.tsxPortfolio summary card
coach-messages.tsxToast notifications for milestones
how-to-play-dialog.tsxOnboarding dialog

Trading Desk:

ComponentPurpose
trading-desk.tsxMain trading interface
order-ticket.tsxBuy/sell form with asset selection, USD/qty toggle, inline Strat creation
holdings-table.tsxCurrent positions with P&L
trade-history.tsxChronological trade log
portfolio-summary.tsxCash, portfolio value, net P&L
confirm-trade-dialog.tsxTrade confirmation with Strat preview

Performance Center:

ComponentPurpose
performance-center.tsxDashboard layout
kpi-grid.tsxCash, crypto value, total return cards
allocation-donut.tsxPortfolio allocation pie chart
contributors-table.tsxTop 5 assets by P&L contribution
trades-table.tsxComputed trade rows
active-strat-card.tsxLive Strat status with countdown, progress bar, reward tiers
strat-rewards-dialog.tsxTier rewards explanation

Price Tracker:

ComponentPurpose
price-tracker.tsxMarket data page
bucket-table.tsxSortable/filterable market table with watchlist

Layout:

ComponentPurpose
crypto-provider.tsxHydration/persistence provider, debounced auto-save
game-nav.tsxNavigation bar across all screens
page-header.tsxReusable page header
disclaimer-banner.tsxEducational disclaimer (dismissible)

Uses shared: GameShell, plus @repo/ui components (Button, Card, Dialog, Table, Select, Input, etc.).

Persistence

Storage key: crypto-challenge-state

Data structure (AppData v2):

{
  version: 2,
  trading: { startCash, trades[] },
  research: { v, thesisTitle, strats[], updatedAt },
  reality: { watchlist[], coachFlags },
  rewards: { bonusUsdTotal, lastQuestAt, starterQuests },
  strats: { resolutions, history[] }
}
  • Auto-save: Debounced (2s) on state changes via CryptoProvider
  • Hydration: Loads on mount, normalizes legacy data with tolerant parsing
  • Trades: Each trade stores time, type (buy/sell), coinId, price, qty, signed usd, optional tags.stratId

Order Validation

  • Positive amounts required
  • Live price must be available
  • Sufficient cash for buys, sufficient quantity for sells
  • Real-time validation in UI before submission

Notable Mechanics

Average Cost Basis

Tracks weighted average cost per asset across multiple buys. Sells reduce quantity; cost resets to 0 when fully sold. P&L uses (currentPrice - avgCost) × qty.

Inline Strat Creation

Players can create a Strat directly on the buy order form -- direction (up/down), target %, time horizon (days), and a reason (120 char max). The Strat auto-links to the trade via tags.stratId.

Coach Messages

Context-aware toast notifications triggered by milestones (e.g., "Nice diversification move!" when adding 2+ sectors). Tracked via coachFlags to avoid repeats.

Performance Attribution

  • Top Contributors: Ranked by absolute P&L contribution to the portfolio
  • Allocation donut: Visual breakdown of portfolio weights by asset
  • Trade-to-Strat linking: Each trade can reference its originating Strat for thesis tracking

Educational Design

  • Plain-English tooltips throughout
  • Dismissible disclaimer banner ("This is a simulation...")
  • How-to-play dialog with step-by-step walkthrough
  • Starter quests guide new players through the core loop
  • Bucket categories teach crypto sector structure