Part 2

Zaros
PerpetualsDEXFoundrySolidity
70,000 USDC
View results
Submission Details
Severity: medium
Invalid

Market::isAutoDeleverageTriggered reverts when market debt is negative

Summary

The function Market::isAutoDeleverageTriggered will revert when calculating marketDebtRatio if totalDebtUsdX18 is negative. Since totalDebtUsdX18 is of type SD59x18, it can hold negative values. When it is negative, the function attempts to divide by delegatedCreditUsdX18 and convert the result to UD60x18 (unsigned type), causing a reversion due to underflow.


Vulnerability Details

UD60x18 marketDebtRatio = totalDebtUsdX18.div(sdDelegatedCreditUsdX18).intoUD60x18();

totalDebtUsdX18 is of type SD59x18, which can be negative. The division operation totalDebtUsdX18 / sdDelegatedCreditUsdX18 can result in a negative value. The function then attempts to convert a negative value into UD60x18 (unsigned), which will cause a revert.


Impact

  • ADL cannot function properly if this function reverts unexpectedly

  • The engines will not be able to call withdrawUsdTokenFromMarket and mint usd token when totalDebtUsdX18 is negative creating a DoS situation


Recommendations

Convert the SD59x18 value to a positive value first before mathematical operation

Updates

Lead Judging Commences

inallhonesty Lead Judge
10 months ago
inallhonesty Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!