-
Notifications
You must be signed in to change notification settings - Fork 66
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
Repay/Withdraw max #123
Repay/Withdraw max #123
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.
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.
It would also be nice to have a concrete example of a rounding error that is prevented by this PR.
In general, I think that we should first make sure that we know where all the rounding errors can come from before doing patches like this, and try to find a solution that applies globally
I don't understand your comment. The PR as it is, is not a patch of rounding but it allows to repay everything by passing type(uint256).max |
You're right. I was thinking of the issue highlighted by @Jean-Grimal and how this PR introduces another type of rounding error (going from shares to amounts in the withdraw function) |
I'm ok to put this PR on hold until we're clear about roundings, wdty? |
The rounding issue raised in this PR is actually introduced in this PR, and I believe I have a clear view over it, as described here: #123 (comment). |
Yes you can do a PR on top if you want. |
…nto feat/repay-withdraw-all
Co-authored-by: Jean-Grimal <[email protected]> Signed-off-by: Romain Milon <[email protected]>
Signed-off-by: Romain Milon <[email protected]>
…roundings fix(repay/withdraw): edge case
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 disadvantage of using a maxuint256 as exact value is that it complexity the implementation with a permit 2 into a Metamorpho vault where the amount is maximized by maxUint160.
You have to add a specific logic, such as
if(amount == type(uint160).max)
MORPHO.supply(market, type(uint256).max, address(this));
Why would the approval amount and the repay amount be equal? Can't we just approve |
I'm not even sure we can use permit2 into ERC4626 vaults because you can't pass the signature if you follow the standard. But this is a very good point though (and a bit annoying for the bulker). |
We can, this is a workaround. My point is that if your contract build onto Blue has amount limitation, it locks the max repay/withdraw. Permit2 is just an example. For example, on ma3 optimizer, the amount defined in repayWithPermit cannot be higher than maxUint128, since the amount is the same one as the permit2 signature one. My first take would be just to acknowledge that this is a blue specification. Btw for the Bulker, this is not blocking since the transferFrom2 and repay are handled separately. |
Indeed, it forces integrators to only use In any case, I don't think it's a big deal, so I'm ok with any solution, though I prefer the Reminder: this was also discussed in the corresponding issue. |
Oh so let's integrate this |
0b37029
fd93b63
to
6c3f418
Compare
Replaced by #194, now that we have the equivalent even with shares |
Fixes #40