Protocol overview
Context is a prediction market protocol on Base. Four core contracts handle the onchain layer: MarketFactory manages markets and outcome tokens, Settlement matches and settles signed orders, and Holdings custodies user balances. All orders are signed offchain using EIP-712 and settled onchain in batches.Contract addresses
| Contract | Mainnet (Base 8453) | Testnet (Base Sepolia 84532) |
|---|---|---|
| Settlement | 0x00000000008c286A2aaa99c6Be3b3D405A929500 | 0xa9b830f4496b88c2d3C103fB96Df8f413031eBDD |
| Holdings | 0x0000000000CcA5bC44912C63d63e1673FeE923f6 | 0xBed9a1A6CB168D60aD2C7770Be6B62bD9244D6d3 |
| Collateral token | USDC 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 | USDC 0xBbee2756d3169CF7065e5E9C4A5EA9b1D1Fd415e |
| Permit2 | 0x000000000022D473030F116dDEE9F6B43aC78BA3 | 0x000000000022D473030F116dDEE9F6B43aC78BA3 |
Architecture
Core contracts
MarketFactory
Creates prediction markets and manages outcome tokens. Each market has a set of ERC-1155 outcome tokens (e.g., Yes and No) backed by USDC collateral. Key operations:- Mint complete sets — deposit USDC, receive one of each outcome token
- Burn complete sets — return one of each outcome token, receive USDC back
- Redeem — after resolution, burn winning tokens for their payout
- Convert positions — in multi-binary markets, convert NO positions to YES positions (see negative risk)
MarketFactory reference
Full function signatures, read helpers, and events
Settlement
The execution layer. Receives matched orders from the fill signer and settles them onchain. Also provides Holdings-native mint/burn/redeem/conversion flows so users can perform token lifecycle operations without withdrawing from Holdings. Key operations:- Settle fills — execute matched orders (single or batch)
- Cancel nonces — invalidate orders by canceling their nonce
- Mint/burn/redeem from Holdings — perform token operations using Holdings balances
Settlement reference
Full function signatures, structs, and events
Holdings
A balance manager that custodies user ERC-20 tokens (USDC and outcome tokens). Users deposit funds, then authorize Settlement as an operator so it can transfer balances during order settlement. Key operations:- Deposit / withdraw — move tokens in and out
- Deposit with Permit2 — gasless deposits using a Permit2 signature
- Set operator — authorize Settlement to manage balances (required before trading)
- Transfer — move balances internally between users
Holdings reference
Full function signatures and events
Order signing
Orders are signed offchain using EIP-712 typed data. The API handles submission and matching — you only need to sign and submit.EIP-712 domain
Signed order (Settlement V2)
The unified order type for both limit and market orders.BUY (0)— budget-native: spend up tomaxCollateralIn, receive at leastminSharesOutSELL_INVENTORY (1)— sell from existing token inventorySELL_NO_INVENTORY (2)— sell by minting from collateral budget
Signatures
Both EOA wallets (ECDSA) and smart contract wallets (ERC-1271) are supported. The Context SDK handles signing automatically. See the Settlement contract reference for the full V2 struct definitions.Canceling orders
Orders are canceled by invalidating their nonce:- Direct — call
settlement.cancelOwnNonce(nonce)onchain - Via signature — sign a
CancelNonce(address trader, bytes32 nonce)message and anyone can submit it - Via API — use the API reference for the cancel order endpoints (recommended for most integrators)
Token mechanics
Outcome tokens are backed 1:1 by USDC collateral through a complete sets mechanism.| Operation | Input | Output | When |
|---|---|---|---|
| Mint | 1 USDC | 1 Yes + 1 No token | Anytime |
| Burn | 1 Yes + 1 No token | 1 USDC | Anytime |
| Redeem | Winning tokens | USDC payout | After resolution |
- Minting — deposit collateral, receive one of each outcome token. Settlement can do this automatically from Holdings balances during order matching.
- Burning — return a complete set (one of each token) to get your collateral back. Useful for exiting a position without selling on the orderbook.
- Redemption — after a market resolves, burn your outcome tokens to receive USDC based on the payout percentages. For a binary market, winning tokens pay out 1 USDC each.
Negative risk
In multi-binary markets, only one outcome can resolve YES. This means holding multiple NO positions has built-in redundancy — at most one of your NO tokens will lose value. The protocol lets you convert this redundancy into collateral or YES positions.Conversion formula
Conversion types
For a market with 4 outcomes:| Type | Input | Output | Description |
|---|---|---|---|
| Full exit | 4 NO | 0 YES + 3 USDC | Convert all NOs to pure collateral |
| Concentrate | 3 NO | 1 YES + 2 USDC | Bet on one outcome + take profit |
| Balanced | 2 NO | 2 YES + 1 USDC | Partial conversion |
| Swap only | 1 NO | 3 YES + 0 USDC | Trade 1 NO for multiple YES tokens |
How it works
Positions are specified using an indexSet bitmask where each bit represents an outcome. For example, in a 4-outcome market:indexSet = 7(binary0111) = convert NO positions for outcomes 0, 1, and 2indexSet = 3(binary0011) = convert NO positions for outcomes 0 and 1
Most integrators interact with negative risk through the API rather than calling contract functions directly. The
protocol handles conversions automatically when optimizing position management.
Common flows
Step-by-step examples for funding, trading, minting, redeeming, and converting positions