Yield Protocol fyToken
Yield Protocol fyToken Oracle Implementation
The Oracle is implemented as a simple Uniswap V2 Oracle. The discount rate is computed by taking the difference between the cumulative price at the beginning and end of the period and then divided by the elapsed time between them in seconds. The resulting price is converted to a per-second rate that is used by the Relayer to push values to Collybus.
These parameters are needed in order to define a
poolAddress- Address of the Yield Pool
maturity- Maturity date of the Pool
timeScale- A precomputed time scale in 18 digit precision
timeScaleis obtained from the Yield Pool time-stretch property
tsby applying the following formula:
All of the initial parameters are
immutablewhich means once they are set they can not be modified.
Each specific oracle implementation must define the
Oracle.getValue()function. This function is called when the global execution flow is triggered by the Relayer.
To obtain the new price we compute the delta between the current and the previous cumulative balance ratio which we keep in storage as
blockTimestampLast. The last step is to scale the delta by
timeScaleand convert the rate to an 18-digit precision fixed-point number.
getValueis called after the maturity date the call will revert. In this scenario, the
update()process will continue but the current value will be considered invalid.
These methods can be called by anyone:
Returns the last computed balance ratio.
Returns the timestamp at which the last balance ratio was computed
Returns the address of the Yield Pool
Returns the maturity of the Yield Pool
Returns the formatted time scale of the Yield Pool
Computes and returns the discount rate.