Skip to content

Architecture

System Overview

System architecture

Components

Velo RGS (Remote Game Server)

The core game server, built in Rust with the Axum framework and Tokio async runtime.

ComponentTechnologyPurpose
HTTP ServerAxumREST API and WebSocket endpoints
Pricing EngineCustom Rust5-stage calibrated pricing pipeline
Round ManagerTokio tasksRound lifecycle (active → locked → settled)
Oracle RouterWebSocketDual price feeds (Binance + Coinbase) with failover
SettlementPyth NetworkVerifiable on-chain price proofs
Wallet Providervelo-wallet crateAbstraction layer for all money operations
ReconciliationREST APIRound + transaction queries for operator auditing

Wallet Integration

The RGS uses a WalletProvider trait that abstracts all balance operations. Two implementations ship out of the box:

ModeImplementationWhen Used
B2B ProductionSeamlessWalletClientLive — sends HMAC-signed HTTP requests to your wallet API
SandboxSandboxWalletCertification testing — in-memory balances with configurable error injection
DemoDemoWalletDevelopment/demo — operates against local demo_players DB table

The mode is selected automatically based on environment:

  • OPERATOR_WALLET_URL set → SeamlessWalletClient (B2B mode)
  • WALLET_MODE=sandboxSandboxWallet (certification mode)
  • DATABASE_URL set → DemoWallet (demo mode)

Oracle Router

Dual-feed architecture with automatic failover:

  • Primary: Binance WebSocket (always connected)
  • Secondary: Coinbase WebSocket (hot standby)
  • Cross-validation: warns if feeds diverge >0.5%
  • Failover: primary stale >2s → switch to secondary
  • Failback: primary healthy for 10s → switch back
  • All-down: both stale >10s → pause game

Pricing Pipeline

Odds are computed once per second through this pipeline:

  1. Drifted Brownian Bridge — Path-conditioned probability using 10s subsampled price history
  2. Isotonic Calibration — 200-breakpoint monotonic mapping trained on 3 years of BTC data
  3. Trend Persistence — Momentum adjustment based on empirical BTC trend continuation rates (5 magnitude buckets × 14 time windows)
  4. House Edge — 5% flat margin applied symmetrically

Volatility is estimated from a 360-candle rolling window of Binance 1-minute klines, refreshed every 60 seconds.

Round Lifecycle

Rounds are clock-aligned to :X0:00 and :X5:00 UTC (e.g., 14:00, 14:05, 14:10...):

  ACTIVE ──────────► LOCKED ──► SETTLED
  (4m50s)             (10s)       │
    │                   │         │ Pyth settlement
    │ Bets accepted     │         │ Wallet credits
    │ Odds updating     │ No bets │
  • Active (0:00–4:50): Bets accepted, odds update every second
  • Locked (4:50–5:00): Last 10 seconds — no new bets, odds still visible
  • Settled (5:00): Pyth oracle price fetched, result determined, wallets credited

Game Constants

ConstantValueDescription
Round duration5 minutesClock-aligned
Lock buffer10 secondsBefore round end
Max stake$1,000Per bet
Max payout$50,000Per bet
Max odds1000xTail bet cap
Cashout spread3%Early exit spread
House margin5%Flat symmetric

Infrastructure

Hosted on Google Cloud Platform:

ServiceGCP ComponentPurpose
ComputeCloud RunAuto-scaling containers
DatabaseCloud SQL (PostgreSQL)Rounds, bets, players, sessions
FrontendFirebase HostingStatic game frontend
Analytics (planned)BigQueryLong-term audit trail and compliance analytics

B2B Integration Documentation