Economics & AMM Math
Complete-Set FPMM equations, unbalanced seeding bounds, symmetric dynamic & opening fees, saturating position caps, and O(1) Leaky Bucket Vault.
All AMM formulas are implemented identically in Solidity (BinaryFpmmLib, FeeMathLib, LeakyBucketLib) and TypeScript (app/src/lib/math.ts), with every rounding step strictly favoring the pool or protocol.
Complete-Set Conservation & Spot Price
Let be the number of outcomes ( in BinaryEngine, in MultiEngine), the pool reserve of outcome , Vault shares, aggregate trader shares, and total market collateral.
Complete-set conservation holds after every operation (INV-2):
Marginal spot probability (PRICE_SCALE ):
Buy Formula (Collateral In → Shares Out)
Given gross collateral input MIN_TRADE_AMOUNT (1_000_000 units = 1.00 USDT):
- Compute fee with upward rounding (
ceilDiv) and net minted sets :
- Mint complete sets into every reserve () and solve the updated reserve rounding up:
- Update
collateral += x,feeAcc += fee,shares[i] += sharesOut, andnetCostBasis += a(enforcingnetCostBasis <= key.maxPosition).
Binary Sell Formula (Closed-Form Quadratic)
When a trader sells shares of outcome (with opposing reserve ), the pool burns complete sets preserving :
Net payout after symmetric fee is .
- Full-Exit Exemption (
INV-8): Selling 100% of remaining shares (sharesIn == type(uint40).max) bypassesMIN_TRADE_AMOUNT(1 USDT) so small dust balances are never stranded. - Saturating
netCostBasis(INV-7): Profitable sells clampnetCostBasisto0without underflow.
For (MultiEngine V1.1), sell() uses Verify-Don't-Compute: /quote supplies uint48 hintCollateralOut, verified on-chain in via with a bounded 48-iteration bisection fallback if stale.
Dynamic & Opening Fees
Effective fee is :
- Symmetric Dynamic Fee (
OD-3): Linear ramp from100 bps(1.0%) to300 bps(3.0%) over the final 15 minutes of 1h BTC markets and final 30 minutes of 4h BTC & trend markets—applied identically to buys and sells. - Opening Fee (Price Markets Only): Linear decay from
250 bps(2.5%) to100 bps(1.0%) over the first120safter launch to neutralize launch-second oracle latency arbitrage.
Unbalanced Seeding & Leaky Bucket Vault
- Adaptive Seeding Bounds (
OD-6):MIN_SEED = 30 USDT, hard reserve floorR_MIN >= 5 USDTon every outcome.- Lean seed (
< 100 USDT): initial probabilities constrained to[15%, 85%]. - Deep seed (
>= 100 USDT): initial probabilities constrained to[10%, 90%].
- Proportional Position Cap (
OD-5):maxPosition = min(1.5 * seed, 500 USDT). - Rolling 7-Day Leaky Bucket (
INV-10): Net Vault outflows over any rolling7dwindow (LEAK_WINDOW) are capped bymaxOutflowPerWindow(recommended25%of Active Float) using a single storage slot with continuous linear decay, guaranteeing net Vault loss on any single market never exceedskey.seed.
Smart Contracts (V5.0)
Immutable Dual Singletons, Commit-to-ID MarketKey, 6-decimal internal scaling, bit-packed storage, EIP-1153 reentrancy protection, and AdapterRegistry.
Resolution, Disputes & TWAP Void
Chainlink 2-call historical bracketing, symmetric 1% bonds, single-round disputes, N-1 packed TWAP Void, and permissionless liveness timeouts.