ReserveOracle
Reserve oracles are used to determine the LST provider exchange rate and is utilizated by Ion's liquidation module. Liquidations will only be triggered against this exchange rate and will be completely market-price agnostic. Importantly, this means that liquidations will only be triggered through lack of debt repayment or slashing events.
In order to protect against potential provider bugs or incorrect one-off values (malicious or accidental), the reserve oracle does not use live data. Instead it will query the exchange every intermittent period and persist the value and this value can only move up or down by a maximum percentage per query. If additional data sources are available, they can be involved as FEED
s. If other FEED
s are provided to the reserve oracle, a mean of all the FEED
s is compared to the protocol exchange rate and the minimum of the two is used as the new exchange rate. This final value is subject to the bounding rules.
State Variables
ILK_INDEX
QUORUM
MAX_CHANGE
FEED0
FEED1
FEED2
currentExchangeRate
lastUpdated
Functions
constructor
Creates a new ReserveOracle
instance.
Parameters
_ilkIndex
uint8
of the associated collateral.
_feeds
address[]
Alternative data sources to be used for the reserve oracle.
_quorum
uint8
The number of feeds to aggregate.
_maxChange
uint256
Maximum percent change between exchange rate updates. [RAY]
_getProtocolExchangeRate
Returns the protocol exchange rate.
Must be implemented in the child contract with LST-specific logic.
Returns
<none>
uint256
The protocol exchange rate.
getProtocolExchangeRate
Returns the protocol exchange rate.
Returns
<none>
uint256
The protocol exchange rate.
_aggregate
Queries values from whitelisted data feeds and calculates the mean. This does not include the protocol exchange rate.
Parameters
_ILK_INDEX
uint8
of the associated collateral.
_bound
Bounds the value between the min and the max.
Parameters
value
uint256
The value to be bounded.
min
uint256
The minimum bound.
max
uint256
The maximum bound.
_initializeExchangeRate
Initializes the currentExchangeRate
state variable.
Called once during construction.
updateExchangeRate
Updates the currentExchangeRate
state variable.
Takes the minimum between the aggregated values and the protocol exchange rate, then bounds it up to the maximum change and writes the bounded value to the state. NOTE: keepers should call this update to reflect recent values