> 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/working-with-price-oracles.md).

# Working with Price Oracles

**`initialize_oracle<CURRENCY>(...)`**, **`update_oracle(...)`**, and **`get_twap(...)`**\
**Purpose**: Integrate a price oracle to record price samples and compute a time-weighted average price (TWAP).\
**Process**:

1. Store historical prices during trades.
2. Update `price_cumulative` and `price_samples` periodically.
3. Compute TWAP for stable pricing signals and detect anomalies.

**Use Cases**:

* Avoiding price manipulation by referencing TWAP rather than spot prices.
* Informing traders and liquidity providers with more reliable pricing.

**Best Practices**:

* Configure appropriate `sample_period` to reflect market conditions.
* Use TWAP checks in large trades to prevent large deviations from fair value.
