# PriceFeed

The `CentralizedOraclePriceFeed` contract utilizes a centralized oracle source to fetch the latest prices of assets. It introduces a delay in price updates to mitigate the risks associated with price manipulation and flash loan attacks. The delayed price update ensures that fetched prices do not immediately affect the system, providing a buffer to detect and react to potential price anomalies.

`CentralizedOraclePriceFeed` is named centralized because it utilizes Oracle data that can be fetched from off-chain centralized sources (like Chainlink, Supra, and other oracles), not from pure onchain (DEX) data. Oracles themselves can be decentralized, and `CentralizedOraclePriceFeed` isn't responsible for the quality of the data.

#### Storage Variables

* `oracle`: Address of the centralized oracle contract (`address`). This oracle provides the latest price data.
* `accessControlConfig`: Address of the access control contract (`IAccessControlConfig`). It is used to manage roles and permissions within the contract.
* `latestPrice`: Latest fetched price information stored as `PriceInfo`, which includes the price and the timestamp of the last update.
* `delayedPrice`: The price that is currently being used by the system, delayed by a certain period defined by `timeDelay`.
* `timeDelay`: The delay period (in seconds) that determines how long fetched price data must wait before being considered valid within the system.
* `priceLife`: The duration (in seconds) for which a price is considered valid after being updated.
* `poolId`: Identifier for the specific pool or asset that this price feed pertains to.

#### Functions

* `setOracle(address _oracle)`: Updates the oracle address. This function can only be called by the owner or governance role.
* `setTimeDelay(uint256 _seconds)`: Sets the time delay for the price update. This can only be adjusted by the owner or governance role.
* `setPriceLife(uint256 _seconds)`: Sets the duration for which a price is considered valid.
* `retrivePrice()`: Fetches the latest price from the oracle and updates the price information in the contract.

#### Events

* `LogSetTimeDelay(address indexed _caller, uint256 _seconds)`: Emitted when the time delay is updated.
* `LogSetPriceLife(address indexed _caller, uint256 _second)`: Emitted when the price life duration is updated.
* `LogPeekPriceFailed(address indexed _caller, string _reason)`: Emitted if fetching the latest price fails.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.fathom.fi/fxd-stablecoin/interfaces/pricefeed.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
