CoinFlip
docs + theme shell
VALLIS Home
Theme

A coin‑flip game that never lies about payouts.

This is a theme-first shippable docs shell inspired by that “cute‑but‑dark occult” vibe. Effects are modular, toggleable, and performance-safe. Logic comes later.

Disclosed odds Fee transparency Hard caps (α) Receipts-ready
Quick quote preview
what users see before flipping
Bet$5.00
Fee (1.00%)$0.05
Win return$9.70
Player win chance47.00%
Pool cap (α)0.25%

How it works

CoinFlip is designed around explicit bias + explicit fees, plus hard exposure caps so the pool can’t be drained in one streak. This page is theme-first; the terminal bot + pool adapters plug in next.

Pool‑adapter first

Your bot reads liquidity, fee rate, edge, and max payout fraction from a pool adapter. Today it can be mock data; later you swap in on‑chain or backend adapters.

getPoolInfo() → liquidity, fees, edge, caps
safe max bet auto‑calculated from pool liquidity
quotes always computed the same way

User‑facing transparency

Before any flip, users see: fee, bet-after-fee, win return, win profit, loss on lose, and safety locks. The UI never hides the math.

bet = user wager (1 / 5 / 10)
fee = bet × feeRate
betAfterFee = bet − fee
winProfit = betAfterFee × m
winReturn = betAfterFee + winProfit
loseLoss = bet

Pool safety caps

Let L be pool liquidity and α be max payout fraction. Then max payout is:

maxPayout = L × α
maxBet = maxPayout / ((1−feeRate) × (1+m))

The “safe ladder” can also require liquidity for N consecutive wins (optional strict mode).

Live tester

This live tester runs locally using preset pool profiles + disclosed odds. Later you’ll wire the same UI to your pool adapter + receipts engine — but the quote math and safety gating remain identical.

Simple flow
Detected: N/A • Volatility: N/A • TVL: N/A
TVL N/A
Safe max bet N/A
Starting balance
Choose bet
Pick side
Win chance ↔ reward
Win %
Profit ×
Higher win% lowers profit× (and vice‑versa) to keep the house edge stable.
Select a pool to unlock flip presets.
Player balance$0.00
Total flips0
Wins0
Losses0
Balance graph
Each flip appends a point. Wins are marked above the line, losses below.
Receipts
Select a pool, then press Quote / Flip.

Safety + solvency

The pool can’t be allowed to die. The bot uses hard caps + circuit breakers + conservative solvency checks.

Safe ladder

The UI offers $1/$5/$10, but the bot enforces what’s actually safe. If liquidity drops, higher bets lock automatically.

enabled(bet) if:
  winProfit ≤ L×α
  AND poolBalance ≥ winProfit×(1+buffer)

Streak reserve (optional)

If you want extra safety, require enough liquidity to survive N consecutive player wins before enabling a bet.

need = N × winProfit × (1+buffer)
poolBalance must exceed need

Circuit breakers

Pause flips if adapter fails, liquidity drops too fast, oracle is stale, or proof receipts fail verification.

pause if:
  adapter_error
  pool_drop_rate > threshold
  oracle_stale
  receipts_invalid

Provably fair (commit → reveal)

Proof prevents hidden manipulation of outcomes. Bias is intentional and disclosed; randomness is verifiable.

Commitment

Server generates a secret seed, publishes its hash before flips start.

commit = SHA256(serverSeed)
publish(commit)

Reveal

After an epoch closes, server reveals the seed. Anyone verifies the hash matches.

verify SHA256(serverSeed) == commit

Outcome (demo rule)

Use HMAC of serverSeed and clientSeed+nonce, parity determines Heads/Tails.

digest = HMAC_SHA256(serverSeed, `${clientSeed}:${nonce}`)
firstByte = hexToByte(digest[0..1])
outcome = (firstByte % 2 == 0) ? heads : tails

CLI usage (terminal bot)

Reference commands. Your shipped terminal bot should mirror these behaviors.

Commands

coinflip status
coinflip quote --bet 1  --side heads
coinflip quote --bet 5  --side tails
coinflip flip  --bet 10 --side heads --client-seed "myseed"
coinflip reveal
Quote output should always show: bet, fee, bet-after-fee, win return/profit, lose loss, pool liquidity, α cap, safe max bet, and disclosed win probability.