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

preLiquidate may revert unexpectedly #49

Closed
colin-morpho opened this issue Oct 1, 2024 · 5 comments
Closed

preLiquidate may revert unexpectedly #49

colin-morpho opened this issue Oct 1, 2024 · 5 comments
Assignees
Labels

Comments

@colin-morpho
Copy link
Contributor

colin-morpho commented Oct 1, 2024

In the following line

uint256 collateralQuoted = uint256(position.collateral).mulDivDown(collateralPrice, ORACLE_PRICE_SCALE);

the value colateralQuoted may be equal to zero, thus resulting in a division by zero by zero error.

This is a very niche case and it's OK, it means that the liquidation is not healthy to pre-liquidate and must be done on Morpho. No need to patch the implementation.

However, we should provide some documentation. See related verification run.

@peyha
Copy link
Collaborator

peyha commented Oct 3, 2024

Two possibilities:

  • acknowledge this in the documentation
  • use an UncollateralizedPosition error in the code

I'm leaning for the second option as it seems more understandable for a user

@MathisGD
Copy link
Contributor

MathisGD commented Oct 3, 2024

I'm leaning towards the acknowledgment in the documentation (liquidators are technical), but not super strong opinion.

@colin-morpho
Copy link
Contributor Author

colin-morpho commented Oct 3, 2024

It's being tricky to handle in the verification. Using summaries trigger many divisions by zero 😞. I'll report on the PR when I have more results.

@peyha
Copy link
Collaborator

peyha commented Oct 4, 2024

I'll implement the second option today, if it eases FV we should do it

@MathisGD
Copy link
Contributor

MathisGD commented Oct 7, 2024

Fixed by #77

@MathisGD MathisGD closed this as completed Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants