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):packages/gold-betting-demo/app/src/idl/fight_oracle.jsonpackages/gold-betting-demo/app/src/idl/gold_clob_market.jsonpackages/gold-betting-demo/keeper/src/idl/fight_oracle.json
Environment Configuration
Frontend (.env.mainnet):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:- 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
Keeper Bot
The keeper bot automates market operations: Responsibilities:- Monitor game server for fight state changes
- Initialize matches when fights start
- Create order books for betting
- Resolve matches when fights end
- Distribute payouts to winners
- Polls
/api/streaming/stateevery 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:- Live order updates via WebSocket
- Bid/ask spread visualization
- Order depth chart
- Recent trades list
Betting Panel
Testing
Local Development
E2E Tests
- CLOB market initialization
- Order placement and matching
- Match resolution and payouts
- UI interactions and wallet connections
Simulation Tests
- 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
Best Practices:- Use separate wallets for keeper bot and deployer
- Fund keeper wallet with minimal SOL (auto-refill recommended)
- Monitor keeper bot logs for unusual activity
- Set conservative order size limits in market maker
- Enable CORS only for known betting domains
- Use rate limiting on betting API endpoints
- Validate all fight outcomes before resolution
Monitoring
Keeper Bot Health
Market Maker Health
Related Documentation
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