> For the complete documentation index, see [llms.txt](https://docs.artinals.com/artinals-protocol/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.artinals.com/artinals-protocol/trade-module/data-structures/priceoracle.md).

# PriceOracle

**PriceOracle** ensures fair pricing by storing historical prices and computing time-weighted average prices (TWAP).

**Key Fields**:

* `id`: Unique identifier for the oracle.
* `price_cumulative`: An accumulated total of historical prices used to compute averages.
* `last_update_time`: When the oracle last recorded a price sample.
* `price_samples`: A vector of recorded prices for computing TWAP.
* `sample_period`: The time interval between samples, e.g., hourly.

**Role**:

* Provides stable, manipulation-resistant price references.
* Helps detect abnormal price fluctuations or limit price impact, protecting traders.
* Integrates with TradingPools to adjust prices or verify trades against TWAP values.
