Single-file HTML dapps for prediction markets.
Start a local server from the repository root:
# Using npx serve (recommended)
npx serve .
# Or using Python
python3 -m http.server 3000
# Or using Node's http-server
npx http-server .Then open in your browser:
- Gas PM: http://localhost:3000/dapp/gasPM.html
- PNK PM: http://localhost:3000/dapp/pnkPM.html
- UNI PM: http://localhost:3000/dapp/uniPM.html
Once the page is loaded, you can interact with the contracts via the browser console:
// Get the ethers provider
const provider = new ethers.BrowserProvider(window.ethereum);
// Get a signer (requires wallet connection)
const signer = await provider.getSigner();
// Core contract addresses
const PAMM = '0x000000000044bfe6c2BBFeD8862973E0612f07C0';
const ZAMM = '0x000000000000040470635EB91b7CE4D132D616eD';
const Resolver = '0x00000000002205020E387b6a378c05639047BcFB';
// Router contracts
const MasterRouter = '0x000000000055CdB14b66f37B96a571108FFEeA5C';
const PMHookRouter = '0x0000000000BADa259Cb860c12ccD9500d9496B3e';
const PMHookQuoter = '0x0000000000f0bf4ea3a43560324376e62fe390bc';
// Example: Read market data
const pamm = new ethers.Contract(PAMM, ['function getMarket(bytes32) view returns (tuple)'], provider);gasPM.html- Ethereum gas price prediction marketspnkPM.html- PNKSTR CryptoPunks treasury prediction marketsuniPM.html- UNI-collateralized prediction markets
All dapps use a unified routing system:
-
MasterRouter: Primary router for trading and limit orders
buyWithSweep: Sweeps pooled orderbook asks, then falls back to AMMsellWithSweep: Sweeps pooled orderbook bids, then falls back to AMMmintAndPool/depositSharesToPool: Create limit orders in pooled orderbookwithdrawFromPool/withdrawFromBidPool: Cancel limit orders
-
PMHookRouter: Vault-based liquidity provision
provideLiquidity: Split collateral between vault bootstrap and AMM LP
-
PMHookQuoter: View contract for quotes and orderbook data
getActiveLevels: Get active price levels in the pooled orderbookgetUserActivePositions: Get user's limit order positionsgetQuote: Get expected output for a trade
Limit orders use a pooled orderbook model:
- Orders at the same price level are aggregated into pools
- No individual order hashes - positions tracked by (market, side, price)
- Efficient sweeping during market orders
- Buy/Sell: Trade YES/NO shares via pooled orderbook + AMM with smart routing
- Limit Orders: Place bids/asks at specific prices in pooled orderbook
- Swap: Exchange YES ↔ NO shares directly on ZAMM
- LP: Provide liquidity to vault + AMM via PMHookRouter
Markets can resolve in two ways:
-
Early Resolution: If a market has "early close" enabled, it can be resolved as soon as the condition is met. Anyone can trigger resolution once the condition passes.
-
Deadline Resolution: At the market's close time, the condition is checked and the market resolves based on whether the condition is met.
Outcome: If the condition is met (e.g., PNKSTR treasury balance >= 40 punks), YES wins. Otherwise, NO wins.
- Traders: Click "Claim Winnings" on resolved markets to redeem winning shares
- LPs: Withdraw liquidity via the trade modal - automatically claims any winning shares
Core:
- PAMM:
0x000000000044bfe6c2BBFeD8862973E0612f07C0 - ZAMM:
0x000000000000040470635EB91b7CE4D132D616eD - Resolver:
0x00000000002205020E387b6a378c05639047BcFB
Routers:
- MasterRouter:
0x000000000055CdB14b66f37B96a571108FFEeA5C - PMHookRouter:
0x0000000000BADa259Cb860c12ccD9500d9496B3e - PMHookQuoter:
0x0000000000f0bf4ea3a43560324376e62fe390bc