IPOR Protocol
Search
K

IPOR Oracle

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

Warren Buffet
Introducing IPOR Oracle. Besides providing IPOR rate to the blockchain community, IPOR Oracle is responsible for computing some simple yet important metrics that can be used by other smart contracts:
  • exponential moving variance (EMVar)
  • exponential moving average (EMA)
  • IBT (Interest Bearing Token) - a measure of interest rate over time

Oracle structure

Oracle structure consists of 2 contracts and an off-chain component.
  1. 1.
    This stateless contract fetches the data from all the protocols supported by IPOR Index and runs all the calculations to compute IPOR Rate.
  2. 2.
    Oracle contract This contract keeps the state of the IPOR rate and calculates all additional params - EMA, EMVar, 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.
  3. 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.

Public Functions

Function
Notes
getIndex (address asset)
It returns the most recently published IPOR value for a given asset.
getAccruedIndex(uint256 calcTimestamp, address asset)
It returns the structure with: - the most recent IPOR Index - exponential moving average - exponential moving variance (a measure of volatility) - IBT as calculated to the current timestamp. See calculateAccruedIbtPrice
calculateAccruedIbtPrice (address asset, uint256 calcTimestamp)
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.
updateIndex (address asset, uint256 value)
Function available only to whitelisted addresses. It allows for IPOR publication. This function will also trigger a recalculation of - exponential moving average (EMA), exponential moving variance (EMVAR), and IBT.
updateIndex (address asset)
Function available only to whitelisted addresses. When invoked, it will make a request to index-calculating smart contract (also used by the off-chain oracle) publish the index, and return value (same sa getIndex)
updateIndexes (address[] assets, uint256[] values)
Allows IPOR updating for multiple assets simultaneously.
addUpdater (address updater)
Available for Owner only. Adds address to whitelist of IPOR index updaters
removeUpdater (address updater)
Available for Owner only. Removes address from the whitelist of IPOR index updaters
addAsset (address asset, uint256 updateTimestamp, uint256 ema, uint256 ewmVar)
Available for Owner only. Adds asset for which IPOR can be compiled. This function allows for adding initial values of MVAR and EMA so that they can be to the real values quicker.
removeAsset (address asset)
Available for Owner only. It removes asset.