> For the complete documentation index, see [llms.txt](https://hydromancer.xyz/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hydromancer.xyz/docs/builder-guides/prediction-markets.md). Agents can also search and read this documentation through its [MCP server](https://hydromancer.xyz/docs/~gitbook/mcp).

# Prediction markets

List Hyperliquid HIP-4 outcome markets, show their prices and volume, follow settlements and compare venues.

Each HIP-4 outcome trades on Hyperliquid's order book under its own asset ID. Hydromancer adds the market list, trading stats per outcome, settlement results and venue data around those prices and trades.

Prediction market apps usually need to:

* list the open markets and the questions they belong to
* show prices, order books and volume for each outcome
* know when a market settles, and at what result
* compare venues

**At a glance**

| What you need                              | Use                                                                                                                                                                                                                                                                                                                                          |
| ------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Open markets with trading stats            | [registeredOutcomes](https://docs.hydromancer.xyz/readme/rest-api/outcomes/registeredoutcomes)                                                                                                                                                                                                                                               |
| Specific outcomes by ID                    | [registeredOutcomesById](https://docs.hydromancer.xyz/readme/rest-api/outcomes/registeredoutcomesbyid)                                                                                                                                                                                                                                       |
| A light list of every outcome and question | [outcomeMeta](https://docs.hydromancer.xyz/readme/rest-api/outcomes/outcomemeta)                                                                                                                                                                                                                                                             |
| Prices, order books, trades and candles    | [allMids](https://docs.hydromancer.xyz/readme/rest-api/asset-data/allmids), [l2Book](https://docs.hydromancer.xyz/readme/rest-api/market-data/l2book), [tradesByTime](https://docs.hydromancer.xyz/readme/rest-api/historical-data/tradesbytime), [candleSnapshot](https://docs.hydromancer.xyz/readme/rest-api/candlesticks/candlesnapshot) |
| Settlement results                         | [settledOutcomes](https://docs.hydromancer.xyz/readme/rest-api/outcomes/settledoutcomes), [settledOutcomesById](https://docs.hydromancer.xyz/readme/rest-api/outcomes/settledoutcomesbyid), [settledOutcome](https://docs.hydromancer.xyz/readme/rest-api/outcomes/settledoutcome)                                                           |
| Live registrations and settlements         | [hip4MarketEvents](https://docs.hydromancer.xyz/readme/websocket/hip4marketevents)                                                                                                                                                                                                                                                           |
| Venues and their activity                  | [outcomeVenuesOverview](https://docs.hydromancer.xyz/readme/rest-api/outcomes/outcomevenuesoverview), [outcomeVenueStats](https://docs.hydromancer.xyz/readme/rest-api/outcomes/outcomevenuestats)                                                                                                                                           |
| Who holds each side (add-on)               | [registeredOutcomesSnapshot](https://docs.hydromancer.xyz/readme/rest-api/outcomes/registeredoutcomessnapshot)                                                                                                                                                                                                                               |

**How markets are structured**

* An **outcome** is one Yes/No market. Its two sides trade as separate assets: Yes is `#` followed by the outcome ID times 10, and No is that number plus 1. Outcome `30164` trades as `#301640` (Yes) and `#301641` (No).
* A **question** groups several outcomes: its `namedOutcomes` plus one `fallbackOutcome`.
* An outcome's `name` points to a template, such as `template:sportsContestWinner`, and its `description` holds the values as `key:value` pairs separated by `|`. Fill the template's `name` pattern from [outcomeTemplates](https://docs.hydromancer.xyz/readme/rest-api/outcomes/outcometemplates) with those values to get a readable title.

**Listing open markets**

[registeredOutcomes](https://docs.hydromancer.xyz/readme/rest-api/outcomes/registeredoutcomes) returns the outcomes that are open for trading, newest first, up to 100 per page. Filter with `venue`, `kind` or `category`, or rank by a stat with `sortBy`, such as `volumeNotional24h` for the most traded markets of the last 24 hours.

Each outcome comes with its `outcomeId`, its Yes and No asset IDs (`yesAssetId`, `noAssetId`), the venue that deployed it (`deployerVenue`) and its trading stats:

* `yesStats` and `noStats` hold the stats of each side, including `lastPrice`, `vwap`, volume and open interest.
* `outcomeStats` aggregates both sides: `trades`, `uniqueTraders`, `volumeNotional`, `volumeNotional24h` and `openInterestNotional`.
* `sortBy` accepts `trades`, `uniqueTraders`, `volumeNotional`, `firstTrade`, `lastTrade`, `volumeNotional24h` and `openInterestNotional`.
* While `hasMore` is `true`, send the returned `cursor` to get the next page.

Use [registeredOutcomesById](https://docs.hydromancer.xyz/readme/rest-api/outcomes/registeredoutcomesbyid) to refresh the outcomes on screen, and [outcomeMeta](https://docs.hydromancer.xyz/readme/rest-api/outcomes/outcomemeta) when you only need IDs, names and the question structure.

**Showing prices, order books and trades**

Pass a side's asset ID as the `coin` to [l2Book](https://docs.hydromancer.xyz/readme/rest-api/market-data/l2book), [tradesByTime](https://docs.hydromancer.xyz/readme/rest-api/historical-data/tradesbytime) and [candleSnapshot](https://docs.hydromancer.xyz/readme/rest-api/candlesticks/candlesnapshot). [allMids](https://docs.hydromancer.xyz/readme/rest-api/asset-data/allmids) also returns the mid prices of outcome sides.

A trade on one side also appears on the other side's coin, at `1 - px`, with the side and the users swapped.

**Following settlements**

[settledOutcomes](https://docs.hydromancer.xyz/readme/rest-api/outcomes/settledoutcomes) lists recently settled outcomes. `settleFraction` is `"1"` for the outcome that won and `"0"` otherwise, and `settledAt` gives the time and block. Fetch one result with [settledOutcome](https://docs.hydromancer.xyz/readme/rest-api/outcomes/settledoutcome), or several with [settledOutcomesById](https://docs.hydromancer.xyz/readme/rest-api/outcomes/settledoutcomesbyid).

For live updates, subscribe to [hip4MarketEvents](https://docs.hydromancer.xyz/readme/websocket/hip4marketevents). Each event carries an `entity` (an outcome or a question) and an `action`: `register`, `associate`, `settle`, `changeDescription` or `registerTemplate`. Add `venue` to receive one venue only. Validator-registered markets carry no venue, so leave the filter out to receive them.

Short markets can register and settle between two polls, so use the stream, not a timer, when you need every market.

**Comparing venues**

[outcomeVenuesOverview](https://docs.hydromancer.xyz/readme/rest-api/outcomes/outcomevenuesoverview) lists each permissionless venue with its deployer, activation time, active status and sub-deployers. [outcomeVenueStats](https://docs.hydromancer.xyz/readme/rest-api/outcomes/outcomevenuestats) adds, per venue: open and settled outcome counts, trades, unique traders, lifetime and 24-hour volume, and open interest. Validator-deployed markets are reported as their own row.

If you run a venue, [outcomeDeployerLimits](https://docs.hydromancer.xyz/readme/rest-api/outcomes/outcomedeployerlimits) shows how many more outcomes you can deploy today and hold active.

**Seeing who holds each outcome**

The add-on [registeredOutcomesSnapshot](https://docs.hydromancer.xyz/readme/rest-api/outcomes/registeredoutcomessnapshot) returns every holder of each outcome side with their balance. Set `includeEntryValues` to also receive each holder's entry value. The response is compressed (zstd + MessagePack), so request `registeredOutcomesSnapshotTimestamp` first and download only when it changes.

**Putting it together**

1. Load the open markets with `registeredOutcomes`, and the templates once with `outcomeTemplates`.
2. Show prices from `allMids` or `l2Book`, using each outcome's `yesAssetId` and `noAssetId`.
3. Subscribe to `hip4MarketEvents` to add new markets and mark settled ones.
4. On a `settle` event, read the result from `settledOutcomesById`.

If your app routes outcome trades with a builder code, [Outcome Builder Analytics](https://docs.hydromancer.xyz/readme/outcome-analytics/outcome-builder-dashboard) reports its volume, fees and category breakdowns.
