-
Notifications
You must be signed in to change notification settings - Fork 0
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
Unhealthy troves with LTV > 90% cannot always be absorbed as intended #11
Comments
bytes032 marked the issue as duplicate of #13 |
bytes032 marked the issue as sufficient quality report |
alex-ppg marked the issue as not a duplicate |
The Warden has demonstrated how a contradiction between the documentation and the implementation of the project will cause certain troves to not be liquidate-able temporarily. I confirmed this submission as the documentation of the project states in the priority of liquidation methods chapter that a trove should be liquidate-able if its TVL exceeds 90% (i.e. the I consider a medium-risk severity apt for this finding as the DoS is temporary. |
alex-ppg marked the issue as satisfactory |
alex-ppg marked the issue as selected for report |
This is an error in the documentation. The correct wording should be:
|
The Sponsor has clarified that the documentation was incorrect and that the code behaves as expected, however, per C4 standards I will accept this submission as valid given that the documentation serves as the source of truth for the Wardens to validate. |
Dear Judge & Sponsor, First of all, thanks for keeping the issue valid due to the source of truth consideration. I can confirm that's how we handle such cases on C4 and the present case serves as good exmaple of fair judging. Anyways, I still want to provide further insights about this since it might be relevant for the sponsor. According to the sponsor's update:
The following would be true:
This is contradictory and the discrepancy starts arising for thresholds > 83% effectively creating an "absorption gap", see main report and graph. As far as I understood the mechanics of the protocol, the initially documented LTV criteria of absorption seemed to be the most reasonable while the code is subject to the above discrepancy. For anyone wanting to play around with threshold vs. LTV vs. max. penalty, I've created this graph which is based on the sponsor's initial graph from the docs. I hope I could provide further insights and value! Kind regards, |
To give some context, the alternative condition of "if its threshold exceeds 90% LTV and its LTV has exceeded the threshold" for absorption was added because:
IMO, the "absorption gap" for thresholds > 83%, while conceptually contradictory, is acceptable because searcher liquidations is already available once LTV > threshold. Of course, the contradiction is more jarring the closer we get to 90% e.g. 88% threshold as you pointed, but a line has to be drawn somewhere and 90% is a convenient round figure. |
milancermak (sponsor) confirmed |
Lines of code
https://github.com/code-423n4/2024-01-opus/blob/4720e9481a4fb20f4ab4140f9cc391a23ede3817/src/core/purger.cairo#L467
Vulnerability details
Impact
Unhealthy troves with
ltv > 90%
andthreshold < 90%
cannot always be absorbed due to a wrong if-condition.According to Priority of liquidation methods it should always be possible to absorb unhealthy troves with
ltv > 90%
:However, the purger::get_absorption_penalty_internal(...) method mistakenly checks the
threshold
instead of theltv
against theABSORPTION_THRESHOLD (90%)
in L467:As a consequence, unhealthy troves can only be absorbed if they reach the maximum possible penalty although the condition
ltv > 90%
is already satisfied. This is against the protocol's intended liquidation/absorption incentives and therefore endangers the solvency of the protocol.By observing the sponsor's graph for liquidation penalty it becomes evident that the
MAX_PENALTY
can only be achieved forltv
up to89%
. For even higherltv
up to100%
, the penalty approaches0%
due tomax_possible_penalty
(see code above), which lowers the incentives for liquidation and makes absorption a necessity.In case of
threshold > 83%
there is a window where90% < ltv < ltv@max_possible_penalty
causing absorptions to be impossible due to the present bug. This linked graph visualizes the present issue.Proof of Concept
In the following, a numerical example is provided to demonstrate the above claims.
Initial assumptions:
Let's do the math step-by-step:
We can see that the trove has not reached its maximum possible penalty yet, therefore it cannot be absorbed as expected, although
ltv > 90%
.Tools Used
Manual review
Recommended Mitigation Steps
Make sure the absorption threshold is checked against the
ltv
as intended:Assessed type
Math
The text was updated successfully, but these errors were encountered: