Part 2

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

Market::getAutoDeleverageFactor does not apply deleverage factor when debt is more than delegated credit

Summary

The getAutoDeleverageFactor function in the Market contract is designed to calculate the adjustment to the USD Token minted based on the market's debt ratio. However, when the delegated credit is less than the market's debt, the function returns a factor of 1e18, which results in the full requested amount being minted, regardless of the current debt situation. This behavior can be problematic, especially in scenarios where the market has insufficient credit to cover the requested minting of USD tokens.

Vulnerability Details

  • When the delegatedCreditUsdX18 (delegated credit) is less than totalDebtUsdX18 (total market debt), the getAutoDeleverageFactor function returns a factor of 1e18, meaning no deleveraging is applied and the requested USD token amount is fully minted.

  • This can lead to a situation where the system continues to mint USD tokens, even when the market does not have enough credit

  • In the following snippet:

UD60x18 adjustedUsdTokenToMintX18 =
market.getAutoDeleverageFactor(delegatedCreditUsdX18, marketTotalDebtUsdX18).mul(amountX18);

If the deleverage factor is 1e18 (when delegatedCreditUsdX18 < marketTotalDebtUsdX18), the full requested USD token amount is minted, potentially violating the protocol's credit capacity. According to the function doc, when the market is in ADL state, the token amount must be multiplied. When delegated credit is less than debt, the market is in ADL state, but it is not handled correctly

Impact

  • If the system mints tokens based on this unadjusted factor (1e18), the market could exceed its credit capacity, potentially causing instability and risking the backing of USD tokens.

  • The market debt will keep increasing due to call to updateNetUsdTokenIssuance

Tools Used

  • Manual review

Recommendations

  • Modify the getAutoDeleverageFactor function to ensure that it always applies a deleverage factor when delegatedCreditUsdX18 < totalDebtUsdX18, rather than returning a factor of 1e18, which effectively disables the deleveraging mechanism

Updates

Lead Judging Commences

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!