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

`previewMint` under-estimate the actual minted amount

Rubilmax opened this issue · comments

Because the current implementation of totalAssets uses the pool index stored on Morpho from the last update

There are 2 solutions:

  • add a dependency on the Lens to compute the updated pool & p2p indexes
  • add a getter on the Morpho contract for the pool & p2p indexes (morpho-org/morpho-optimizers#1325)

Tests breaking because of this are already part of the test suite

I know we already discussed that but I propose to use the lens and its updated indexes so that we fully comply to the ERC4626, wdyt?

There is also the possibility to copy the indexes logic and tests from the Lens rather than has the lens as dependency.
I'm not saying that this is the best solution but it isolates the Vault from other contracts.

I would be against that because it creates another code duplication and we should avoid it IMO

I have a preference for adding Lens as a dependency, because the other solutions would require duplicate the indexes view logic to elsewhere (either on Morpho or on the Vaults) which decreases the maintainability of our codebase: if the indexes view logic contains a bug, we'd rather have it in a single place

Considering we're only using the Lens for the indexes computation here and it is well tested, it's not a problem to me to depend on it