Yield Protocol fyToken

Yield Protocol fyToken Oracle Implementation

šŸ”Ž High-level Overview

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.

šŸ£ Initialization

These parameters are needed in order to define a YieldValueProvider Oracle:

  • poolAddress - Address of the Yield Pool

  • maturity - Maturity date of the Pool

  • timeScale - A precomputed time scale in 18 digit precision

The timeScale is obtained from the Yield Pool time-stretch property ts by applying the following formula:

All of the initial parameters are immutable which means once they are set they can not be modified.

šŸŒˆ Execution Flow

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 ascumulativeBalanceRatioLast and blockTimestampLast. The last step is to scale the delta by timeScale and convert the rate to an 18-digit precision fixed-point number.

If getValue is 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.

For more information on working and building Uniswap V2 oracles, you can read this article and check this Oracle example.

šŸ“‘ Public Methods

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.

šŸ“˜ References

Last updated