Prediction Market·EVM (Optimism, Arbitrum, Polygon, Base)
Thales
Permissionless parimutuel and binary-options protocol. Lets users buy UP/DOWN positional tokens on crypto, commodity and stock prices using Chainlink data feeds — deployed on Optimism, Arbitrum, Polygon and Base.
- 01binary options frontends
- 02ranged-market price prediction apps
- 03speculation widgets on top of Chainlink feeds
- 04DeFi-native trading UIs
- 05thales-AMM-powered third-party products
- pnpm add ethers viem
| Variable | Scope | Description |
|---|---|---|
| NEXT_PUBLIC_THALES_NETWORK_ID | Client | Target network id: 10 (Optimism), 42161 (Arbitrum), 137 (Polygon) or 8453 (Base). Drives AMM and PositionalMarketManager addresses. |
| NEXT_PUBLIC_THALES_API_BASE | Client | Base URL for Thales market data API (e.g. https://api.thalesmarket.io). Used for listing live markets and historical PnL. |
Use Thales for binary options and ranged price markets. List active markets via `GET https://api.thalesmarket.io/markets/<network>` or query the `thales-protocol` subgraph (markets, ranged-markets, positions). Buy/sell positional tokens through `ThalesAMM` (binary UP/DOWN) or `RangedMarketsAMM` (IN/OUT) — call `buyFromAmmQuote(market, position, amount)` to price, then `buyFromAmm(market, position, amount, expectedPayout, additionalSlippage)` to execute. Markets reference Chainlink price feeds and resolve automatically at maturity; redeem winnings via `exerciseOptions` on the position contract. Use sUSD on Optimism or USDC/USDT on other chains as the quote token.
- ⚑Quote currency varies: sUSD on Optimism legacy markets, USDC on Arbitrum / Base / Polygon. Hardcoding sUSD across chains is the most common silent breakage — read it from `PositionalMarketManager.sUSD()` per chain.
- ⚑Markets resolve from Chainlink feeds at maturity — disputed/stale rounds can delay `resolveMarket`. Surface `market.resolved` and `market.phase` (Trading / Maturity / Expiry) so users know when to exercise.
- ⚑AMM pricing is non-linear — price impact grows with size against thin liquidity. Always call `buyFromAmmQuote` immediately before `buyFromAmm` and pass `additionalSlippage` (typically 1–3%).
- ⚑Position tokens are ERC-20 but only redeemable after maturity. Don't list them as tradable assets in a wallet UI without showing the `maturityDate`.
- ⚑Thales geofences certain jurisdictions at the frontend; the contracts are permissionless but if you ship a US-facing UI without disclaimers you inherit the regulatory risk yourself.
- ⚑Overtime (sports) is now a separate protocol — don't conflate `OvertimeAMMV2` calls with `ThalesAMM`. They diverged at v2.