Skip to content

Conversation

@totomanov
Copy link
Contributor

@totomanov totomanov commented Apr 1, 2024

The sDAI oracle is presently incorrect as it will utilize the latest read-only IPot::chi value that the pot reports. The IPot::chi value represents the cumulative interest rate value that was stored during the last interaction with the pot. As such, the value may be outdated. The actual DSR implementation of MakerDAO accommodates for this by updating the IPot::chi value of the IPot if the IPot::rho value (last recorded update) is lower than the current block timestamp. This is done via the IPot::drip function which is state-mutating.
As we consider the SDaiOracle::_getQuote function remaining view a pre-requisite, we advise the state mutations that the IPot::drip would perform to be locally calculated in the SDaiOracle to acquire an up-to-date IPot::chi value. To achieve this, the following statements need to be incorporated: rmul(rpow(dsr, now - rho, ONE), chi)
Whereby the r prefixed arithmetic operations are using Ray accuracy under the WadRayMath system and the dsr, rho, and chi values can be queried from the IPot directly.

Instead of using Maker's WadRayMath::rpow, I used Solady's FixedPointMathLib::rpow. I didn't want to import more code or dependencies. I wrote a differential test to ensure both rpow's are equivalent, though maybe it's better to use theirs?

@totomanov totomanov merged commit f3874b9 into master Apr 3, 2024
@totomanov totomanov deleted the fix-sdai-oracle-omniscia branch April 23, 2024 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants