Protocol
Markets & order book
Every Thassa market is a binary YES/NO order book priced in cents. A share pays $1 to the winning side. Price is probability: YES at 62¢ is the book saying 62%.
The pricing model
- An order is always “buy
sideat limit pricepcents forsharesshares” — there is no separate sell verb; exiting a YES position means buying NO (or redeeming after settlement). - Limit prices are integers 1..99 cents.
- Escrow: a YES buyer at
pescrowsp × sharescents; a NO buyer atqescrowsq × sharescents (all in payment-token base units). - Crossing: buy YES @
pmatches resting buy NO @qwheneverp + q ≥ 100— together the pair fully collateralizes the $1 payout.
Matching rules
Matching happens at order placement: the incoming order takes the best crossing price levels first, then any remainder rests on the book as a maker order.
- Price-time priority. Better-priced resting orders fill first; within a price level, first in, first filled (FIFO).
- Execution at the maker’s price. The resting order’s level sets the execution price — a taker’s aggressive limit only widens what can cross; it never worsens the fill.
Resting (maker): buy NO @ 40¢ × 500 shares — the maker
Incoming (taker): buy YES @ 65¢ × 300 shares — crosses: 65 + 40 ≥ 100
Execution: 300 shares AT THE MAKER'S LEVEL — taker pays 100 − 40 = 60¢/share
taker escrow used: 300 × $0.60 = $180 (+ taker fee)
maker escrow used: 300 × $0.40 = $120
→ each matched pair holds $1.00/share, fully collateralizedUnder the hood the book is gas-friendly: per market and side, a uint128 price-level bitmap gives O(1) best-price discovery, and each level holds a FIFO queue of packed orders.
Market lifecycle
Markets move through six one-word states, used verbatim across the app, the API, and these docs:
| State | Meaning |
|---|---|
| PENDING | Creation or settlement transaction in flight. |
| OPEN | Live; the creator’s opening bet has not been taken yet. Creator-side microcopy: “You’re committed. Waiting for someone to take your bet.” |
| MATCHED | First fill against the creator’s opening liquidity landed (“Your bet was taken.”). Trading continues. |
| SETTLING | Settlement query running through the oracle pipeline. |
| SETTLEDYES | Outcome final, direction recorded (YES or NO). Winners redeem $1/share. |
| VOID | Invalidated via the owner-only escape hatch; all deposits refundable. |
Order states
| State | Meaning |
|---|---|
| SIGNING | Awaiting the user’s signature. |
| QUEUED | Accepted; waiting in a relayer batch. |
| RESTING | Open on the book as a maker order. |
| PARTIAL | Partially filled; remainder still resting. |
| FILLED | Fully filled. |
| CANCELED | Canceled by the maker (unfilled remainder refunded). |
Creating a market
Market creation is free — no protocol fee — but the creator’s initial order must deposit at least $1 of capital. That opening bet is the market’s first liquidity, and the creator is committed to it: the market shows OPEN until someone takes the other side, then MATCHED. Both the question and the structured settlement query are stored onchain as public strings at creation.
Fees
Kalshi-style, taker-side only. Makers pay nothing. The fee on each match, at execution price p (the maker’s price, in cents):
fee = ceil(7% × shares × p × (100 − p) / 10000) // dollars, p = execution price in cents
= ceil(takerFeeBps × shares × p × (100 − p) / 10000 / 10000) // takerFeeBps = 700The fee is quadratic in uncertainty — largest at 50¢, vanishing toward 1¢/99¢ — and is deducted from the taker’s escrow, rounded up at the token’s base unit.
Worked examples
| Fill | p × (100−p) / 10000 | Fee math | Taker fee |
|---|---|---|---|
| 100 shares @ 50¢ | 0.25 | 0.07 × 100 × 0.25 | $1.75 |
| 100 shares @ 62¢ | 0.2356 | 0.07 × 100 × 0.2356 | $1.6492 |
| 10 shares @ 95¢ | 0.0475 | 0.07 × 10 × 0.0475 | $0.03325 |
| 1 share @ 99¢ | 0.0099 | 0.07 × 1 × 0.0099 | $0.000693 (ceils to 693 base units at 6 decimals) |
Where fees go
- 10% of every collected fee accrues to the market creator (claimable via
claimCreatorFees). - 5% goes to the affiliate — the post whose market widget routed the order (
affiliatePostId;0= none, in which case the share goes to the protocol). - The remainder goes to the protocol vault.
Flat fees
| Action | Fee | Notes |
|---|---|---|
| Market creation | Free | Requires a ≥ $1 initial order. |
| Settlement trigger | $0.05 | Paid by whoever calls settleMarket; funds the hub bid. Re-triggerable if the bid is cancelled or expires. |
| Withdrawal | $0.10 flat (default, owner-configurable) | Charged on redeem/withdraw transfers out; sized ≈ market-creation gas. |
Settlement & redemption
- Anyone calls
settleMarket(marketId)and pays the $0.05 trigger. Status → SETTLING. - The oracle pipeline resolves the outcome — see Settlement & sources. Status → SETTLEDYES.
- Winners call
redeem(marketId)for $1/share, minus the flat withdrawal fee. Unmatched or resting deposits are refundable any time viawithdraw.
Fee constants (owner-settable)
takerFeeBps = 700 · creatorFeeShareBps = 1000 · affiliateFeeShareBps = 500 · withdrawalFlatFee default $0.10 · settlementFee default $0.05.