code-423n4 / 2021-08-notional-findings

3 stars 0 forks source link

Idiosyncratic fCash valuation is incorrect #22

Open code423n4 opened 3 years ago

code423n4 commented 3 years ago

Handle

tensors

Vulnerability details

Impact

The docs say that:

"Markets may not always trade at the exact maturities of all fCash assets. fCash that does not fall on an exact maturity is called idiosyncratic fCash. To value these assets, Notional takes the linear interpolation of the rates of the two nearest markets. For example, an fCash asset at 9 months to maturity will be valued at a rate halfway between the current 6 month and 1 year markets. Idiosyncratic fCash cannot exist beyond the furthest on chain market by design."

Taking the average of the valuation of two market rates gives the wrong implied valuation since the formula used to value fCash assets is nonlinear in time:

Theoretical: valuation(time) = fCash notional e^(-(rate +/- haircut) time)

Lets say we know the market price for 1 unit of fCash notional at times t0 and t1 and we want to figure out the price at t' = (t0+t1)/2. Taking the average (linear interpolation) of the rates would give:

marketPrice(t') = (marketPrice(t0) + marketPrice(t1) ) /2

This disagrees with the theoretical model.

The correct formula is a geometric interpolation: marketPrice(t') = sqrt( marketPrice(t0) * marketPrice(t1) )

The result is that the entire protocol overvalues idiosyncratic cash assets. The further they are between any two trading market prices, the more they are overvalued.

Recommended Mitigation Steps

Make sure the implementation takes the geometric interpolation instead of linear interpolation for the rates, as well as updating the documentation to reflect this.

T-Woodward commented 3 years ago

This is not correct. You have misinterpreted the quoted lines in the docs. The value of a 9 month idiosyncratic fCash asset is not the average of the 6 month and one year fCash asset values. Rather, the interest rate used to derive the value of the 9 month idiosyncratic fCash asset is the average of the 6 month and one year interest rate. The 9 month idiosyncratic fCash asset value is determined by the valuation formula you have referenced just like all other fCash assets.

ghoul-sol commented 3 years ago

Per sponsor comment making this invalid.