Working with the IPOR index
There are at least three ways to query IPOR Index. Each way to query an index has its intended use and has certain advantages.
From the oracle contract
- It's the most gas efficient, as reading the values on-chain does not require complex calculations or calls to external contracts.
- It provides additional params such as exponential moving average or exponential moving variance calculated on-chain
- It allows for calculating the average IPOR rate between 2 points in time, thanks to the IBT.
- IPOR swaps use this method to read the IPOR rate
getIndex(asset address) // pass address of ERC token for which to read IPOR
If you want to read the value of IPOR along with the most recent IBT value then use
getAccruedIndex(asset address, timestamp uint256)
// pass address of ERC token for which to read IPOR,
// and current timestamp
- It provides the real-time IPOR for a given block.
calculateIpor(asset address) // pass address of ERC token for which to calculate IPOR
From the API
- Does not require a connection to the blockchain
- It provides historical data.
- does not require any authentication and it's free to query.
Because the calculation of IPOR is done on-chain in the calculation index, it is possible for anyone to run on-chain update of the oracle contract. Albeit not the most gas efficient it may be beficial in some cases to force update of IPOR if you rely on the most recent data in our integration.