SOLEX

Integration Docs

Everything you need to embed Solex games into your casino platform — Prediction Markets and TraderHero.

API Endpoints

Prediction Markets

POST /api/v1/casino/markets — Create market (requires X-Casino-Key)
GET  /api/v1/casino/markets — List all markets
GET  /api/v1/casino/markets/:id — Get market details + prices
GET  /api/v1/casino/markets/:id/odds — Get current YES/NO prices
PUT  /api/v1/casino/markets/:id — Update market (requires X-Casino-Key)
PUT  /api/v1/casino/markets/:id/odds — Update manual bookmaker odds
POST /api/v1/casino/markets/:id/resolve — Resolve market
POST /api/v1/casino/markets/:id/cancel — Cancel market
POST /api/v1/casino/bets/calculate — Calculate bet (shares, cost, fees)
POST /api/v1/casino/bets/place — Place a bet (requires X-Casino-Key)
GET  /api/v1/casino/bets/:id — Get bet details
GET  /api/v1/casino/bets/market/:marketId — Get bets for a market
POST /api/v1/casino/bets/claim/:marketId — Claim payouts

Cash-Out

POST /api/v1/casino/bets/cash-out/preview — Preview cash-out value for a bet
POST /api/v1/casino/bets/cash-out/execute — Execute cash-out (full or partial)
POST /api/v1/casino/bets/cash-out/trigger — Set auto cash-out trigger (take-profit / stop-loss)
DEL  /api/v1/casino/bets/cash-out/trigger/:triggerId — Cancel an auto cash-out trigger

Risk Management

GET  /api/v1/casino/risk/dashboard — Risk dashboard (exposure, liability, high-risk markets)
POST /api/v1/casino/markets/admin/suspend-all — Emergency kill switch — suspend all active markets
POST /api/v1/casino/markets/admin/resume-all — Resume all suspended markets
PUT  /api/v1/casino/markets/:id/circuit-breaker/reset — Reset circuit breaker for oracle bookmaker market
POST /api/v1/casino/markets/:id/void — Void market with reason, refund all bets

TraderHero Jackpot

GET  /api/v1/jackpot/config — Get game config (public)
POST /api/v1/jackpot/rounds — Create round (requires X-Casino-Key)
POST /api/v1/jackpot/rounds/:id/settle — Settle round (requires X-Casino-Key)

Casino Admin

GET   /api/v1/casino/auth/me — Get current user session
POST  /api/v1/casino/auth/register — Register partner
POST  /api/v1/casino/auth/verify-jwt — Verify JWT token
POST  /api/v1/casino/auth/api-keys — Regenerate API keys
GET   /api/v1/casino/admin/config — Get partner config
PATCH /api/v1/casino/admin/config — Update config
GET   /api/v1/casino/admin/reports/summary — Financial summary
GET   /api/v1/casino/admin/reports/monthly — Monthly report
GET   /api/v1/casino/admin/reports/transactions — Transaction ledger
GET   /api/v1/casino/admin/webhooks — List webhook events
GET   /api/v1/casino/admin/webhooks/:id — Get webhook event
POST  /api/v1/casino/admin/webhooks/:id/retry — Retry failed webhook

IGSP Provider API

GET  /igsp/v1/providers — Provider metadata (HMAC auth)
GET  /igsp/v1/games — List available games (HMAC auth)
POST /igsp/v1/sessions — Create player session (HMAC auth)
GET  /igsp/v1/sessions/:id/state — Get session context (Public — call from embed with X-Casino-Key: igsp_<sid>)
GET  /igsp/v1/sessions/:id/balance — Real-time balance (Public — call from embed with X-Casino-Key: igsp_<sid>)
POST /igsp/v1/sessions/:id/bet — Process a bet (Public, ProcessBetDto body)
POST /igsp/v1/sessions/:id/cash-out/preview — Preview cash-out value (Public, {betId} body)
POST /igsp/v1/sessions/:id/cash-out — Execute cash-out (Public, {betId} body)
POST /igsp/v1/hooks — Inbound platform wallet webhook (HMAC, IgspWebhookDto body)
POST /igsp/v1/demo/sessions — Create demo session (Public, CreateSessionDto body)

User Data (Public)

GET /api/v1/casino/users/:userId/bets — Prediction market bet history
GET /api/v1/casino/users/:userId/positions — Market positions
GET /api/v1/casino/users/:userId/positions/:marketId — Position in specific market
GET /api/v1/casino/users/:userId/jackpot-rounds — Jackpot round history

Transaction Ledger

All financial activity is tracked in the transaction ledger. Each transaction has a unique ID and links back to the originating bet or jackpot round.

TypeDirectionGameWhen
bet_placedDebitPrediction MarketsPlayer places a market bet
payoutCreditPrediction MarketsMarket resolves in player's favor
bet_refundCreditPrediction MarketsMarket cancelled, bet returned
cash_outCreditPrediction MarketsPlayer cashes out (full or partial)
fee_collectionDebitPrediction MarketsCasino/platform fees collected
void_refundCreditPrediction MarketsMarket voided, all bets refunded
jackpot_betDebitTraderHeroPlayer enters a jackpot round
jackpot_payoutCreditTraderHeroPlayer wins a jackpot round

Query the ledger via GET /api/v1/casino/admin/reports/transactions with your API key. Both game types appear in the same ledger.

Cash-Out

Players can exit positions early via full or partial cash-out. Supports all pricing models (LMSR sells shares back, bookmaker models use fair-value calculation with configurable margin). Rate limited to 10 cash-outs per user per 24 hours.

Preview Cash-Out

Returns the current cash-out value without executing. Use this to show the player what they would receive.

POST /api/v1/casino/bets/cash-out/preview
Request body:
{
  "betId": "uuid",        // Required — bet to preview
  "percent": 100           // Optional (1-100) — partial cash-out %
}
Response:
{
  "cashOutValue": 45.20,   // Amount player would receive
  "margin": 5.0,           // Cash-out margin applied (%)
  "originalStake": 50.00,
  "currentOdds": { "yesPrice": 0.65, "noPrice": 0.35 }
}

Execute Cash-Out

Executes the cash-out: credits the player wallet, updates bet status, and adjusts market liability. For partial cash-outs, the bet remains active with reduced shares.

POST /api/v1/casino/bets/cash-out/execute
Request body:
{
  "betId": "uuid",        // Required — bet to cash out
  "percent": 50            // Optional (1-100) — 50 = exit half the position
}

Wallet credit retries up to 3 times with idempotent transaction ID (cashout_{betId}). Full rollback if all retries fail.

Auto Cash-Out Triggers

Set automatic take-profit or stop-loss triggers. Evaluated on every oracle price update. When the cash-out value crosses the target, the system executes automatically.

POST /api/v1/casino/bets/cash-out/trigger
Request body:
{
  "betId": "uuid",
  "triggerType": "take_profit",  // "take_profit" or "stop_loss"
  "targetValue": 75.00           // Cash-out when value reaches this amount
}
DELETE /api/v1/casino/bets/cash-out/trigger/:triggerId
Cancel an active trigger. Returns 404 if already triggered or cancelled.

Partner Configuration

FieldTypeDescription
cash_out_enabledbooleanEnable/disable cash-out for this partner (default: true)
cash_out_margin_percentnumberMargin applied to cash-out value (default: 5%)
cash_out_fee_percentnumberFee deducted from cash-out amount (default: 0%)

Risk Management & Safety

Built-in safety controls protect against financial loss. All checks run inside the same database transaction as the bet placement (race-condition safe).

Risk Dashboard

GET /api/v1/casino/risk/dashboard
Response includes:
{
  "activeMarkets": 12,
  "totalVolume": 45000.00,
  "totalFeesCollected": 675.00,
  "totalOutstandingLiability": 12500.00,
  "exposureByModel": { "lmsr": 3200, "oracle_bookmaker": 9300 },
  "highRiskMarkets": [...],       // Markets at >80% exposure utilization
  "correlationGroups": [...],     // Grouped market exposure
  "recentCashOuts": { "count": 8, "totalAmount": 1200.00 }
}

Cached for 10 seconds to avoid heavy aggregate queries.

Emergency Kill Switch

Instantly suspend all betting across all markets. Resume respects per-market suspension reasons (circuit breaker trips are not auto-resumed).

POST /api/v1/casino/markets/admin/suspend-all
Suspends all active markets in a single query. Returns count of suspended markets.
POST /api/v1/casino/markets/admin/resume-all
Resumes all suspended markets. Markets suspended by circuit breaker require individual reset.

Oracle Circuit Breaker

Auto-suspends oracle bookmaker markets when a price update deviates more than 10% from the previous price. Requires manual admin reset after investigation.

PUT /api/v1/casino/markets/:id/circuit-breaker/reset
Resets the circuit breaker and resumes the market. Returns 400 if the market is not an oracle bookmaker type.

Void Market

Cancel a market with a reason and refund all confirmed bets. Used for disputed outcomes, cancelled events, or erroneous market creation.

POST /api/v1/casino/markets/:id/void
Request body:
{
  "reason": "Event cancelled due to weather"  // Required, max 1000 chars
}
Sets market status to CANCELLED, stores reason in resolution_notes, refunds all confirmed bets.

Safety Checks (automatic)

These checks run automatically on every bet placement. No additional API calls needed — configure via partner settings.

CheckConfigBehavior
Max payout capmax_payout_amountRejects bet if potential payout exceeds limit
Per-user-per-market limitmax_bet_per_user_per_marketRejects if cumulative user bets on market exceed limit
Market exposure limitmaxExposure (pricing_params)Rejects if market total liability exceeds limit
Correlated exposuremax_correlation_group_exposureRejects if aggregate exposure across correlated markets exceeds limit
Live oracle verificationAutomatic (oracle_bookmaker)Fetches live Polymarket price, rejects if >5% deviation from cached
Large bet delaylarge_bet_threshold + large_bet_delay_msDelays large bets 0-5000ms, re-verifies market state and exposure after wait
Betting close windowbetting_close_hours_before_resolutionBlocks bets N hours before scheduled resolution
Minimum marginsAutomaticOverround >= 5% (bookmaker), pool cut >= 5% (parimutuel)

Bettor Classification

Tracks closing-line value (CLV) per bettor to classify as recreational, sharp, or restricted. When auto_enforce_sharp_limits is enabled, sharp bettors automatically get reduced per-user limits. Otherwise classification is informational only.

Prometheus Metrics

Exposed at GET /metrics. Includes counters for safety-check rejections (by type), cash-outs executed, circuit breaker trips, kill switch activations, and per-market exposure utilization gauges.