# OracleAggregator

It is the data layer of the Opium Protocol.

&#x20;The OracleAggregator is the contract responsible for providing the necessary data to settle a financial product in the Opium Protocol.&#x20;

It does not implement any specific oracle logic as it is designed to be more oracle-agnostic. This grants developers the freedom to choose the data source of their application - be it any oracle of their choosing or an off-chain API.

### Contract functions description

**`__callback(uint256 timestamp, uint256 data) public`**

The main OracleAggregator function that users and consumer contracts will use the most. It receives and caches the data from msg.sender based on the oracleId address and the provided timestamp - be it an oracle or an off-chain data source- so that it can be provided to the Core contract for the settlement of its related financial product. It takes as an argument the address of the oracle recipe’s oracleId and the uint256 timestamp

**`getData(address oracleId, uint256 timestamp) public view returns(uint256 dataResult)`**

If present, it returns the cached data associated with a given oracleId and timestamp. t takes as an argument the address of the oracle recipe’s oracleId and the uint256 timestamp

**`hasData(address oracleId, uint256 timestamp) public view returns(bool result)`**

It checks whether the OracleAggregator has already been provided with data for a given address oracleId and uint256 timestamp key pair

**`calculateFetchPrice(address oracleId) public returns(uint256 fetchPrice)`**

deprecated

**`registerQuery(address oracleId, uint256 timestamp)`**

deprecated

**`fetchData(address oracleId, uint256 timestamp) public`**

deprecated

**`recursivelyFetchData(address oracleId, uint256 timestamp, uint256 period, uint256 times) public`**

deprecated


---

# 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.opium.network/for-developers/protocol/oracle-aggregator.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.
