morpho-org / morpho-optimizers

Core contracts of Morpho V1 Optimizers.
https://app.morpho.org
GNU Affero General Public License v3.0
137 stars 22 forks source link

Consider impact on pool rates when calculating future rates #1636

Closed Rubilmax closed 1 year ago

Rubilmax commented 1 year ago

Pull Request

Issue(s) fixed

This pull request fixes #1634 and serves as a demo for Yearn integration It implements the interest rates calculation from https://github.com/aave/protocol-v2/blob/0829f97c5463f22087cecbcb26e8ebe558592c16/contracts/protocol/libraries/logic/ReserveLogic.sol#L219-L232

The upgrade test added in this PR has a precision of 1e-9, given that rates are in RAY. Which implies that our predicted rates are very precise compared to rates actually experienced once supplied/borrowed

I had to externalize the rewards lens logic to the rewards manager to save bytecode for the Lens Please note that we've already chosen to upgrade the RewardsManager of Morpho-Compound

Rubilmax commented 1 year ago

What is the size now?

23.663kb, we still have 0.913kb to go

Rubilmax commented 1 year ago

I disagree with your point @QGarchery and writes the reasons here to keep every information:

it is new code that will need to be maintained it will need to be kept in sync with the lens

The code moved in this PR from Morpho-Compound's Lens to Morpho-Compound's RewardsManager is exclusively rewards-related getters which were formerly written to be exposed on the RewardsManager but were moved to the Lens for consistency and to ease integrators work So I can't agree that this code will need to be kept in sync with the Lens: it is no more no less the getters we wanted to expose from the RewardsManager, and should be independent from the Lens However, I agree that doing so would require us to upgrade the RewardsManager in case we've got an issue with our getters Though I'd like to highlight that it'd also be the case with any getter we expose in our protocol

it does not solve the main issue of the lens (being too big) in the long run

Agreed

EDIT: I'm pushing some changes to externalize the logic to some kind of LensExtension