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

nikhilx0111 - all attempts to repay will fail when borrow balance exceeds collateral amount #35

Open
sherlock-admin4 opened this issue Oct 21, 2024 · 0 comments

Comments

@sherlock-admin4
Copy link
Contributor

sherlock-admin4 commented Oct 21, 2024

nikhilx0111

Medium

all attempts to repay will fail when borrow balance exceeds collateral amount

Summary

The deleverToZeroBalance function pays down the borrow token to zero by selling off a specified amount of the collateral asset. The function first borrows collateral, then trades the collateral for borrow tokens, and finally repays the debt position. However, if, due to extreme market conditions, the borrow balance exceeds or is equal to the collateral balance, all attempts to withdraw and repay will fail. Currently, there is no function to account for this situation. As a result, whenever the borrow balance exceeds the collateral, the position will be liquidated, as all withdrawals for collateral will be blocked as a result the debt position will be liquidated

Root Cause

https://github.com/sherlock-audit/2024-10-morpho-x-index/blob/2f125406e0dd3b1fc029b9a47fe97bfbf906fce2/index-protocol/contracts/protocol/modules/v1/MorphoLeverageModule.sol#L247C3-L293C24

Internal pre-conditions

No response

External pre-conditions

borrowposition more than or equal to collateral

Attack Path

No response

Impact

The position will be liquidated every time the collateral is equal to or less than the borrow balance.

PoC

No response

Mitigation

Consider a design change to handle the case when the collateral drops to the liquidation threshold

@sherlock-admin2 sherlock-admin2 changed the title Breezy Basil Toad - all attempts to repay will fail when borrow balance exceeds collateral amount nikhilx0111 - all attempts to repay will fail when borrow balance exceeds collateral amount Oct 28, 2024
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

No branches or pull requests

1 participant