Part 2

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

`getAutoDeleverageFactor` Can Revert Wrongfully

Summary

In Market the function getAutoDeleverageFactor will revert instead of returning UD60x18_UNIT if autoDeleverageStartThresholdX18 and autoDeleverageEndThresholdX18 are equal.

Vulnerability Details

In Market the function getAutoDeleverageFactor will revert instead of returning UD60x18_UNIT if autoDeleverageStartThresholdX18 and autoDeleverageEndThresholdX18 are equal.

The auto deleverage factor is the y coordinate of the following polynomial regression curve:
x and y in [0, 1] ∈ R
y = x^z
z = Market.Data.autoDeleverageExponentZ
x = (Math.min(marketDebtRatio, autoDeleverageEndThreshold) - autoDeleverageStartThreshold) / (autoDeleverageEndThreshold - autoDeleverageStartThreshold)

When the start threshold and the end threshold are equal it will mean that the auto deleverage factor is basically disabled (which is a valid input). However, it will revert due to division by 0 here:

UD60x18 unscaledDeleverageFactor = Math.min(marketDebtRatio, autoDeleverageEndThresholdX18).sub(
autoDeleverageStartThresholdX18
).div(autoDeleverageEndThresholdX18.sub(autoDeleverageStartThresholdX18));

Impact

DoS in CreditDelegationBranch::withdrawUsdTokenFromMarket and CreditDelegationBranch::getAdjustedProfitForMarketId if auto deleverage is triggered which will call Market::getAutoDeleverageFactor.

Tools Used

Manual Review

Recommendations

Return UD60x18_UNIT if autoDeleverageStartThresholdX18 and autoDeleverageEndThresholdX18 are equal.

Updates

Lead Judging Commences

inallhonesty Lead Judge 6 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Appeal created

1337web3 Submitter
6 months ago
inallhonesty Lead Judge
6 months ago
inallhonesty Lead Judge 6 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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