Gamification Banking (Save & Bet)
Status: ✅ Implemented (backend + Banking tab in Progression)
Last Updated: 2026-08-18
Overview
Banking is a gamification skill that lets users invest and save their coins and bet on a simulated market:
- Savings: Move coins from wallet to savings. Savings earn 1% interest per day (applied once per calendar day).
- Market: A global market index (starts at 100) that ticks once per day (midnight UTC). Users can place bets on whether the next tick will be UP or DOWN. Correct guess = 2× coins back; wrong = stake lost.
- Banking skill: Levelling is done by earning XP when you deposit or place a bet (10 XP each). Same skill progression as Cooking, Herblore, etc.
Implementation
Schema
- UserGamification:
coinsInSavings,savingsInterestAppliedAt(for daily interest). - GamificationSkillType:
BANKINGadded. - GamificationMarket: Single row –
currentPrice,previousPrice,lastTickedAt. - UserMarketBet:
userId,marketId,amount,direction(UP/DOWN),marketPriceAtBet,resolvedAt,payout.
Service
- BankingService:
getSummary,getMarketStatus,depositToSavings,withdrawFromSavings,placeBet,getOpenBets,getResolvedBets,tickMarket,applySavingsInterest,getBankingSkill. - BankingSchedulerService: Registers daily job
banking-daily(midnight UTC): runstickMarket()thenapplySavingsInterest().
API (under /api/v1/gamification)
| Method | Path | Auth | Description |
|---|---|---|---|
| GET | /banking | Yes | Full summary (coins, savings, market, open bets) |
| GET | /banking/market | No | Current market price and last tick time |
| GET | /banking/skill | Yes | Banking skill level and XP |
| POST | /banking/deposit | Yes | Body: { "amount": number } – move coins to savings |
| POST | /banking/withdraw | Yes | Body: { "amount": number } – move coins to wallet |
| POST | /banking/bet | Yes | Body: { "amount": number, "direction": "UP" | "DOWN" } – place bet |
| GET | /banking/bets/open | Yes | List unresolved bets |
| GET | /banking/bets/resolved | Yes | List recently resolved bets (?limit=20) |
Admin
- POST
/api/v1/admin/banking/tick(admin): Manually run market tick + savings interest (for testing or external cron).
Constants
- Savings interest: 1% per day.
- Market volatility: ±4% per tick (random walk).
- Bet payout: 2× stake if correct.
Migration
Run:
cd server && pnpm prisma migrate deploy
Migration: 20260205100000_add_banking_skill_and_market.
Frontend
Live on the Progression hub as Banking (web/src/components/ProgressionTabs/BankingTab.tsx): wallet vs savings, market price, deposit/withdraw/bet, open and resolved bets, portfolio buy/sell, banking skill level.