morpho-org / morpho-v1-optimizers-vaults

ERC4626 vaults to ease interaction with Morpho Optimizers.

Home Page:https://vaults.morpho.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[R&D review] Complex and duplicated computation

QGarchery opened this issue · comments

https://github.com/morpho-dao/morpho-tokenized-vaults/blob/6f182b04cf3326cf4244292f8533524236f0b773/src/aave-v3/SupplyVault.sol#L149-L154

This computation appears twice as is in this contract. This is a complex computation that computes the new index, compares it to the user index, and computes the user share of the reward. We could split this computation.

Also remark that this kind of computation appears a third time in _accrueUnclaimedRewards, although here it is splitted in two:

  • the computation of rewardsIndexMem
  • the computation of accruedRewards

One solution would be to define a function to take care of this computation at only one place

Yep good suggestion