# IPOR Oracle

> ### “Someone’s sitting in the shade today because someone planted a tree a long time ago.”
>
> Warren Buffet

### Oracle structure

Oracle structure consists of 2 contracts and an off-chain component.&#x20;

1. Rate calculation contract: <https://etherscan.io/address/0x9D4BD8CB9DA419A9cA1343A5340eD4Ce07E85140>

   This stateless contract fetches the data from all the protocols supported by IPOR Index and runs all the calculations to compute IPOR Rate.&#x20;
2. Oracle contract \
   This contract keeps the state of the IPOR rate and IBT. Oracle contract allows for permissionless update of the IPOR rate (as long as requested is willing to cover the gas costs associated with the rate calculation) by invoking updateIndex(asset Address) function.&#x20;
3. Rate publication off-chain oracle service. \
   This service reads the value calculated in the rate calculation contract are publishes it to the IPOR Oracle contract. This is mainly done due to gas optimization reasons.&#x20;

#### Public Functions

<table><thead><tr><th width="340">Function</th><th>Notes</th></tr></thead><tbody><tr><td><a href="https://etherscan.io/address/0x421C69EAa54646294Db30026aeE80D01988a6876#readProxyContract#F3">getIndex</a> (address asset)</td><td>It returns the most recently published IPOR value for a given asset.</td></tr><tr><td><a href="https://etherscan.io/address/0x421C69EAa54646294Db30026aeE80D01988a6876#readProxyContract#F2">getAccruedIndex</a>(uint256 calcTimestamp, address asset)</td><td>It returns the structure with: <br>- the most recent IPOR Index<br>- IBT as calculated to the current timestamp. See calculateAccruedIbtPrice</td></tr><tr><td><a href="https://etherscan.io/address/0x421C69EAa54646294Db30026aeE80D01988a6876#readProxyContract#F1">calculateAccruedIbtPrice</a> (address asset, uint256 calcTimestamp)</td><td>For a given asset it calculates the current value of IBT considering the time passed from the last IPOR publication. Change in IBT is made based on the recently published IPOR. </td></tr><tr><td><a href="https://etherscan.io/address/0x421C69EAa54646294Db30026aeE80D01988a6876#writeProxyContract#F12">updateIndex</a> (address asset, uint256 value)</td><td>Function available only to whitelisted addresses. It allows for IPOR publication. This function will also trigger a recalculation of IBT. </td></tr><tr><td><a href="https://etherscan.io/address/0x421C69EAa54646294Db30026aeE80D01988a6876#writeProxyContract#F13">updateIndex</a> (address asset)</td><td>Function available only to whitelisted addresses. When invoked, it will make a request to <a href="https://etherscan.io/address/0x9D4BD8CB9DA419A9cA1343A5340eD4Ce07E85140">index-calculating smart contract</a> (also used by the off-chain oracle) publish the index, and return value (same sa getIndex)</td></tr><tr><td><a href="https://etherscan.io/address/0x421C69EAa54646294Db30026aeE80D01988a6876#writeProxyContract#F14">updateIndexes</a> (address[] assets, uint256[] values)</td><td>Allows IPOR updating for multiple assets simultaneously. </td></tr><tr><td><a href="https://etherscan.io/address/0x421C69EAa54646294Db30026aeE80D01988a6876#writeProxyContract#F2">addUpdater</a> (address updater)</td><td>Available for Owner only. Adds address to whitelist of IPOR index updaters</td></tr><tr><td><a href="https://etherscan.io/address/0x421C69EAa54646294Db30026aeE80D01988a6876#writeProxyContract#F7">removeUpdater</a> (address updater)</td><td>Available for Owner only. Removes address from the whitelist of IPOR index updaters</td></tr><tr><td><a href="https://etherscan.io/address/0x421C69EAa54646294Db30026aeE80D01988a6876#writeProxyContract#F1">addAsset</a> (address asset, uint256 updateTimestamp</td><td>Available for Owner only. Adds asset for which IPOR can be compiled. </td></tr><tr><td><a href="https://etherscan.io/address/0x421C69EAa54646294Db30026aeE80D01988a6876#writeProxyContract#F6">removeAsset</a> (address asset)</td><td>Available for Owner only. It removes asset.</td></tr></tbody></table>


---

# 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.ipor.io/ipor-derivatives/developers-docs/ipor-oracle.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.
