Skip to main content

CLOB Market Program Migration

Overview

The betting system has been migrated from a binary market program to a CLOB (Central Limit Order Book) market program for Solana mainnet deployment (commits dba3e03, 35c14f9).

Changes

Program Addresses (Mainnet)

Fight Oracle:
  • Program ID: Fg6PaFpoGXkYsidMpWxTWqkY8B4sT2u7hN8sV5kP6h1
  • Location: packages/gold-betting-demo/anchor/programs/fight_oracle/src/lib.rs
GOLD CLOB Market:
  • Program ID: Updated to mainnet address
  • Location: packages/gold-betting-demo/anchor/programs/gold_clob_market/src/lib.rs
  • Replaces: gold_binary_market program (deprecated)
GOLD Token:
  • Mint: DK9nBUMfdu4XprPRWeh8f6KnQiGWD8Z4xz3yzs9gpump
  • Token Program: TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb
  • Associated Token Program: ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL

IDL Updates

Updated Files:
  • packages/gold-betting-demo/keeper/src/idl/fight_oracle.json - Mainnet program ID
  • packages/gold-betting-demo/app/src/idl/fight_oracle.json - Mainnet program ID
  • packages/gold-betting-demo/app/src/idl/gold_clob_market.json - New CLOB market IDL
  • Removed: gold_binary_market.json (deprecated)

Bot Rewrite

Location: packages/gold-betting-demo/keeper/src/bot.ts Old Instructions (Binary Market):
  • initializeMarket
  • seedMarket
  • createVault
  • placeBet
  • resolveMarket
New Instructions (CLOB Market):
  • initializeConfig - Initialize global market configuration
  • initializeMatch - Create a new duel match
  • initializeOrderBook - Create order book for a match
  • placeBuyOrder - Place buy order (bet on fighter A)
  • placeSellOrder - Place sell order (bet on fighter B)
  • resolveMatch - Resolve match outcome and settle orders
Key Differences:
  • CLOB uses order book matching instead of binary yes/no pools
  • Supports limit orders with price discovery
  • More complex settlement logic (match buyers/sellers)
  • No vault seeding required (liquidity provided by market makers)

Server Configuration

Location: packages/server/src/arena/config.ts Fallback Program IDs:

Keeper Common

Location: packages/gold-betting-demo/keeper/src/common.ts Fallback Program IDs:

Frontend Configuration

Location: packages/gold-betting-demo/app/.env.mainnet Updated Variables:

Migration Guide

For Developers

1. Update Environment Variables:
2. Update Keeper Bot: The keeper bot now uses CLOB instructions:
3. Update Frontend: Replace binary market IDL imports:
4. Remove Binary Market Code:
  • Delete gold_binary_market program references
  • Remove vault seeding logic
  • Update PDA derivations for CLOB accounts

For Operators

1. Deploy CLOB Program:
2. Initialize Configuration:
3. Update Environment: Set mainnet program IDs in production environment variables. 4. Verify Deployment:

CLOB Market Architecture

Account Structure

Instruction Flow

1. Initialize Config (one-time setup):
2. Initialize Match (per duel):
3. Initialize Order Book (per match):
4. Place Orders (users):
5. Resolve Match (keeper):

Testing

Local Testing:
Integration Tests:
E2E Tests:

Troubleshooting

Program deployment fails:
  • Ensure you have enough SOL for deployment (~5 SOL)
  • Check program size: ls -lh target/deploy/*.so
  • Verify keypair: solana address --keypair <keypair-path>
Order matching fails:
  • Check order book account exists
  • Verify match is not resolved
  • Ensure sufficient token balance
  • Check price/amount validity
Keeper bot errors:
  • Verify authority keypair is set: SOLANA_ARENA_AUTHORITY_SECRET
  • Check RPC endpoint is responsive
  • Ensure program accounts are initialized

References

  • Commits: dba3e03, 35c14f9
  • Author: lalalune (Shaw)
  • Date: Feb 22, 2026
  • Files Changed:
    • packages/gold-betting-demo/anchor/programs/fight_oracle/src/lib.rs
    • packages/gold-betting-demo/anchor/programs/gold_clob_market/src/lib.rs
    • packages/gold-betting-demo/keeper/src/bot.ts
    • packages/gold-betting-demo/keeper/src/common.ts
    • packages/gold-betting-demo/app/src/idl/fight_oracle.json
    • packages/gold-betting-demo/app/src/idl/gold_clob_market.json
    • packages/server/src/arena/config.ts
    • packages/gold-betting-demo/app/.env.mainnet