Skip to main content

Overview

Hyperscape integrates with Solana’s Central Limit Order Book (CLOB) market program for decentralized duel betting. The system supports both devnet (testing) and mainnet (production) deployments. Key Features:
  • CLOB (Central Limit Order Book) market for price discovery
  • Mainnet-ready with production program IDs
  • Automated keeper bot for market operations
  • Multi-chain support (Solana + EVM)
  • Real-time order book updates
  • Market maker bot integration

Architecture

Mainnet Configuration

Program IDs

Mainnet Addresses (updated in commit dba3e03):
IDL Files:
  • packages/gold-betting-demo/app/src/idl/fight_oracle.json
  • packages/gold-betting-demo/app/src/idl/gold_clob_market.json
  • packages/gold-betting-demo/keeper/src/idl/fight_oracle.json
All IDL files updated with mainnet program addresses.

Environment Configuration

Frontend (.env.mainnet):
Keeper Bot:
Server Arena Config:

CLOB Market Instructions

The keeper bot was rewritten for CLOB market instructions (commit dba3e03):

Market Initialization

Match Lifecycle

Removed Features

The CLOB market migration removed binary market logic:
  • ❌ Binary market seeding/vault logic
  • ❌ Keeper binary market IDL
  • ✅ Replaced with CLOB market instructions

Market Maker Integration

The market maker bot provides liquidity to the CLOB: Configuration:
Duel Signal Integration:
  • Fetches real-time HP data from streaming duel API
  • Adjusts order prices based on HP edge
  • 90% weight on duel signal, 10% on random walk
  • 2.5s fetch timeout with graceful fallback
Startup Modes:

Keeper Bot

The keeper bot automates market operations: Responsibilities:
  1. Monitor game server for fight state changes
  2. Initialize matches when fights start
  3. Create order books for betting
  4. Resolve matches when fights end
  5. Distribute payouts to winners
Configuration:
Polling Strategy:
  • Polls /api/streaming/state every 3 seconds
  • 5-second timeout per request
  • Backs off when signer funding is low
  • Warns and continues on transient errors

Frontend Integration

Chain Selector

The betting app supports multiple chains:

Order Book Component

Real-time order book display:
Features:
  • Live order updates via WebSocket
  • Bid/ask spread visualization
  • Order depth chart
  • Recent trades list

Betting Panel

Testing

Local Development

E2E Tests

Test Coverage:
  • CLOB market initialization
  • Order placement and matching
  • Match resolution and payouts
  • UI interactions and wallet connections

Simulation Tests

Simulation Output:
  • PnL tracking for all participants
  • Order book state snapshots
  • Match resolution verification
  • Saved to simulations/solana-clob-localnet-pnl.json

Deployment

Mainnet Deployment Checklist

  • Update program IDs in all IDL files
  • Update declare_id! in Rust programs
  • Deploy programs to mainnet
  • Update frontend .env.mainnet with program IDs
  • Update keeper bot with mainnet RPC and program IDs
  • Update server arena config with mainnet oracle
  • Test with small amounts before full launch
  • Monitor keeper bot logs for errors
  • Verify CORS configuration for betting domains

Program Deployment

Frontend Deployment

Security Considerations

Always test on devnet before deploying to mainnet. Solana transactions are irreversible.
Best Practices:
  1. Use separate wallets for keeper bot and deployer
  2. Fund keeper wallet with minimal SOL (auto-refill recommended)
  3. Monitor keeper bot logs for unusual activity
  4. Set conservative order size limits in market maker
  5. Enable CORS only for known betting domains
  6. Use rate limiting on betting API endpoints
  7. Validate all fight outcomes before resolution

Monitoring

Keeper Bot Health

Market Maker Health

Duel Arena System

PvP duel mechanics and arena system

Streaming Duels

Live streaming infrastructure for AI duels

Market Maker Bot

Automated liquidity provision for betting markets

Deployment Guide

Production deployment configuration