-
Notifications
You must be signed in to change notification settings - Fork 26
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
Fix rounding in max deposit #346
Conversation
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.
Ideally we should have a test for it
Hopefully it shouldn't be too difficult
Co-authored-by: Romain Milon <rmilon@gmail.com> Signed-off-by: Jean-Grimal <83286814+Jean-Grimal@users.noreply.github.com>
e543260
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.
The change in _maxDeposit
reimplements MorphoBalancesLib.expectedSupplyAssets
(rounding up), and the change in _supplyMorpho
reimplements MetaMorpho. _accruedSupplyBalance
(rounding up).
Not sure how to remember this but any future modification of those functions may have to be ported to these reimplementations.
|
||
totalSuppliable += supplyCap.zeroFloorSub(supplyAssets); | ||
totalSuppliable += supplyCap.zeroFloorSub(supplyShares.toAssetsUp(totalSupplyAssets, totalSupplyShares)); |
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.
Like you have done for _supplyMorpho
maybe would be good to also add a comment here. I know that this is more a "utility" function and not a "core" one like _supplyMorpho
but it will be probably used very much by integrators.
Consider also adding it as a natspec @dev
comment.
I was worried about Note that because of the rounding up that overestimates what has been already supplied to Morpho, it will underestimate what you can supply (compared to the cap). This means that there's the possibility that the cap is never reachable (because of rounding) |
Fixes https://cantina.xyz/code/8409a0ce-6c21-4cc9-8ef2-bd77ce7425af/findings/963a0dbd-fcf0-4882-9d07-ac6711667cd8
Fixes https://cantina.xyz/code/8409a0ce-6c21-4cc9-8ef2-bd77ce7425af/findings/52649f43-6794-4046-888e-ebaaa7e3d0a4