> For the complete documentation index, see [llms.txt](https://docs.predict.fun/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.predict.fun/developers/chainlink-price-markets.md).

# Chainlink Price Markets

For recurring up/down price-prediction market where each round settles based on whether an asset price moved up, down, or stayed flat, the protocol uses Chainlink Data Streams for tamper-resistant, low-latency price delivery.

**Streams Used**

[BTC/USDT](https://data.chain.link/streams/btc-usdt-topofbook-datalink)

**ChainlinkUpDownAdapter**

The `ChainlinkUpDownAdapter` runs continuous round-based markets on top of the CTF. Each round is a fixed-duration window with a known start price; it closes when a verified Chainlink Data Streams v3 report is delivered on-chain. The contract resolves the CTF condition as:

* **Up** - end price is higher than start price
* **Down** - end price is lower than start price
* **Flat** - end price equals start price

Rounds are pre-created in advance (typically 24 hours ahead) so that CTF conditional token markets are immediately tradeable even before the start price of a future round is known. When a round closes, its end price propagates automatically as the next round's start price.

**ChainlinkReceiverProxy**

The `ChainlinkReceiverProxy` sits in front of the adapter and routes incoming price reports from two sources:

* **Predict forwarder (backend)**: For single-timestamp reports, predict.fun's backend fetches the Data Streams v3 report and submits it directly. These reports must have `validFromTimestamp == observationsTimestamp`. No buffer window is permitted on this path.
* **Chainlink CRE forwarder**: For multi-second reports where `validFromTimestamp` and `observationsTimestamp` differ, reports are fetched and delivered via the Chainlink Compute Runtime Environment (CRE) through the Keystone forwarder. This path is used specifically to ensure trustlessness when an observation buffer is present. The protocol accepts a maximum buffer of 5s.

Reports arriving from the Chainlink forwarder are forwarded to the adapter as-is. Reports from Predict forwarders are first validated to enforce the zero-buffer constraint before being forwarded.

**Emergency Resolution**

If no reports can be retrieved within the 5s buffer, an account with `EMERGENCY_CLOSE_ROUND_ROLE` can call `emergencyCloseRounds` to settle rounds manually. This function is only callable when the contract is paused, ensuring it is a last-resort mechanism.
