> For the complete documentation index, see [llms.txt](https://intracloud.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://intracloud.gitbook.io/docs/agent/prediction-agent.md).

# Prediction Agent

IntraCloud Prediction Agent is a Cloudflare Worker that continuously selects the best Uniswap v3 pool for short prediction rounds and opens new rounds onchain.

## Network and contract

* Network: Sepolia (`11155111`)
* Prediction contract: `0xEf16C4d27859F5D6Ab2506F7c3a1C0f199C18d89`

## What the agent does

1. Discovers active Uniswap v3 pool candidates.
2. Pulls optional candidate/risk context from Uniswap subgraphs (v3 + v4) when configured.
3. Scores pools for round quality using:

* Stability (short/long TWAP drift)
* Manipulation resistance (liquidity + oracle observation depth)
* Profitability proxy (recent swap activity + fee tier)

4. Uses Uniswap Trade API quote probes (`V3` + `V4`) to refine confidence and timing.
5. Chooses the best pool and configures a short round:

* Round duration: `5-15` minutes
* TWAP window: `30-300` seconds (and always `<= duration`)

6. Creates a clear prediction statement using Llama-3.1, grounded with Uniswap AI context references.
7. Creates a new round onchain and resolves the previous round when it ends.

## Public API

Base URL: `<worker-url>`

* `GET /health`
  * Current agent status and active round state.
* `GET /analysis/latest`
  * Latest analysis record and selected pool decision.
* `GET /rounds/recent`
  * Recently ended rounds kept in temporary storage.
* `GET /stats`
  * Platform/agent counters plus onchain aggregate counters.

## Data retention

The agent stores only operational data required by the product:

* Latest analysis snapshot
* Active round tracking state
* Recent ended rounds list
* Aggregate run counters
