-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Function to cover lost assets #6
Conversation
Co-authored-by: Merlin Egalite <44097430+MerlinEgalite@users.noreply.github.com> Signed-off-by: MathisGD <74971347+MathisGD@users.noreply.github.com>
src/MetaMorpho.sol
Outdated
lostAssets -= assets; | ||
emit EventsLib.UpdateLostAssets(lostAssets); | ||
|
||
SafeERC20.safeTransferFrom(IERC20(asset()), msg.sender, address(this), assets); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the token is an ERC777, one can reenter to decrease the lostAssets
value further while transferring only once assets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the function is public this can be very problematic since we can't rely on the fact that the owner is trusted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the token is an ERC777, one can reenter to decrease the lostAssets value further while transferring only once assets
how can they skip the second token transfer?
src/MetaMorpho.sol
Outdated
|
||
SafeERC20.safeTransferFrom(IERC20(asset()), msg.sender, address(this), assets); | ||
|
||
_supplyMorpho(assets); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't it double count the deposited assets
into newLostAssets
?
Since lostAssets
is reduced by assets
and realTotalAssets
is increased by assets
at the next interaction using _accrueInterest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newTotalAssets = realTotalAsset + lostAssets
= prevRealTotalAssets + assets + prevLostAssets - assets
= prevRealTotalAssets - prevLostAssets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added an assertion in a test for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good tbh.
I don't have anything to see at first sight. It doesn't affect the share/asset conversion price or totalAssets
, just reduces lostAssets
. It looks safe.
But I agree with you that it could have implications that we don't see now, so it doesn't feel safe to add this feature. Reminds me a lot of the unfamous Euler donate
function that ruined their protocol.
Although it's cool to have it, I don't think having a function to cleat bad debt is a priority. I think we shouldn't take this risk
Yeah it seems Maybe we could even rename |
|
Nb: not super convinced about this against supplying on behalf of address zero