Open apbendi opened 2 years ago
I do not think this is quite right. Reimbursement tokens are like zero-coupon bonds, and you can calculate their interest rate using the Yield-to-Maturity formula: https://www.investopedia.com/terms/y/yieldtomaturity.asp
// the relative return is the maturity value divided by the current value of the riToken
const relativeReturn = maturityValue / currentValue;
// Number of seconds over which that value increase will occur
const timeRemaining = riToken.maturity - (new Date().getTime() / 1000);
// Convert that interest rate into an APR (pretty sure this gives APR, not APY,
// since there's no compounding considered here)
const effectiveInterestRateAPR = Math.pow(relativeReturn, secondsPerYear / timeRemaining) - 1
For the configure ReimbursementToken, display the 'effective interest rate', i.e. the interest rate earned if the user buys the riToken at the Pool's spot price using the treasury token, then holds to maturity, assuming the face value debt is paid in full. Display this interest rate as an APR. Note that the naming here could serve to be improved— "effective" implies guaranteed. Maybe "Target interest rate" or something more descriptive?
Calculation
Needs to be confirmed w/ Yield team, but the algorithm should be:
If so, we get
maturityValue
based on theriToken
target exchange rate,currentValue
by getting a quote from the pool (what quote inputs?), and the riToken's maturity is read from its contract