Skip to main content

Solana Mainnet Migration Guide

Overview

This guide documents the migration from binary market to CLOB (Central Limit Order Book) market program on Solana mainnet for Hyperscape’s duel betting system. Migration Commits:
  • dba3e03 / 35c14f9 - Adapt bot + IDLs for CLOB market program on mainnet
  • 2c17000 - Merge CLOB bot + IDL fixes for mainnet

Program Changes

Mainnet Program IDs

Fight Oracle (unchanged):
GOLD CLOB Market (new):
GOLD Token Mint:

IDL Updates

All IDL files updated with mainnet program addresses: Files Updated:
  • packages/gold-betting-demo/keeper/src/idl/fight_oracle.json
  • packages/gold-betting-demo/keeper/src/idl/gold_binary_market.json (deprecated)
  • packages/gold-betting-demo/app/src/idl/fight_oracle.json
  • packages/gold-betting-demo/app/src/idl/gold_clob_market.json (new)
IDL Address Field:

Bot Rewrite (Binary → CLOB)

Binary Market Instructions (Removed)

CLOB Market Instructions (New)

Keeper Bot Changes

File: packages/gold-betting-demo/keeper/src/bot.ts Removed:
  • Binary market vault logic
  • Seeding/liquidity provision
  • Binary outcome resolution
Added:
  • CLOB config initialization
  • Match + order book creation
  • CLOB-specific resolution flow

Server Configuration Updates

Arena Config Fallback

File: packages/server/src/arena/config.ts

Keeper Common Fallbacks

File: packages/gold-betting-demo/keeper/src/common.ts

Frontend Configuration

Mainnet Environment File

File: packages/gold-betting-demo/app/.env.mainnet All VITE_* variables updated for mainnet:

Migration Checklist

Pre-Migration

  • Deploy fight oracle program to mainnet
  • Deploy CLOB market program to mainnet
  • Update all IDL files with mainnet addresses
  • Test CLOB instructions on devnet
  • Verify keeper bot logic with CLOB flow

Migration Steps

  1. Update Program IDs:
  2. Rebuild Programs:
  3. Update IDLs:
  4. Update Environment Files:
  5. Deploy Programs:
  6. Initialize On-Chain State:
  7. Verify:

Post-Migration

  • Monitor keeper bot logs for errors
  • Verify first match creation succeeds
  • Test order book initialization
  • Confirm resolution flow works
  • Update frontend to point to mainnet

Breaking Changes

Removed APIs

Binary market instructions no longer available:
  • initializeVault
  • seedMarket
  • placeBet (replaced by CLOB order placement)
  • resolveBinaryMarket (replaced by resolveMatch)

New APIs

CLOB market instructions:
  • initializeConfig - One-time config setup
  • initializeMatch - Create new duel match
  • initializeOrderBook - Create order book for match
  • placeOrder - Place buy/sell order
  • cancelOrder - Cancel existing order
  • resolveMatch - Resolve match outcome
  • settleOrders - Settle matched orders

Testing

Devnet Testing

Mainnet Testing

⚠️ WARNING: Mainnet operations use real SOL. Test thoroughly on devnet first.

Rollback Plan

If mainnet migration fails:
  1. Revert Program IDs:
  2. Redeploy Binary Market:
  3. Update IDLs:
  4. Restart Keeper:

Monitoring

On-Chain Metrics

Monitor these accounts for health:
  • Config account (global settings)
  • Oracle account (fight outcomes)
  • Match accounts (per-duel state)
  • Order book accounts (CLOB state)

Keeper Bot Logs

Watch for:
  • [Bot] Initialized config - Config created successfully
  • [Bot] Created match - Match creation working
  • [Bot] Initialized order book - Order book ready
  • [Bot] Resolved match - Resolution successful

Error Patterns

Common issues:
  • Account not found - Program not deployed or wrong address
  • Invalid instruction data - IDL mismatch with deployed program
  • Insufficient funds - Keeper wallet needs SOL
  • Transaction simulation failed - Check program logs

References

  • Commit dba3e03: Adapt bot + IDLs for CLOB market program on mainnet
  • Commit 35c14f9: Adapt bot + configs for CLOB market program on mainnet
  • Commit 2c17000: Merge CLOB bot + IDL fixes for mainnet
  • Anchor Docs: https://www.anchor-lang.com/
  • Solana Cookbook: https://solanacookbook.com/