Skip to content
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(repay/withdraw): edge case #149

Merged

Conversation

Rubilmax
Copy link
Collaborator

There were actually 2 issues with the feature. See PR comments.

@@ -121,18 +121,22 @@ contract Blue {
function withdraw(Market calldata market, uint256 amount, address onBehalf) external {
Id id = market.id();
require(lastUpdate[id] != 0, "unknown market");
if (amount == type(uint256).max) {
amount = supplyShare[id][msg.sender].toAssetsDown(totalSupply[id], totalSupplyShares[id]);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This calculation was performed before accruing interests.

require(isSenderOrIsApproved(onBehalf), "not approved");

accrueInterests(market, id);

uint256 shares = amount.toSharesUp(totalSupply[id], totalSupplyShares[id]);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shares <= supplyShare[id][onBehalf] was not guaranteed because of #123 (comment).

@Rubilmax Rubilmax marked this pull request as ready for review July 19, 2023 09:56
src/Blue.sol Outdated Show resolved Hide resolved
Co-authored-by: Jean-Grimal <[email protected]>
Signed-off-by: Romain Milon <[email protected]>
src/Blue.sol Outdated Show resolved Hide resolved
Signed-off-by: Romain Milon <[email protected]>
@Rubilmax Rubilmax merged commit 2e471cc into feat/repay-withdraw-all Jul 20, 2023
@Rubilmax Rubilmax deleted the refactor/repay-withdraw-all-roundings branch July 20, 2023 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants