Part 2

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

`getCreditCapacityUsd` should subtract the `totalDebtUsdX18`

Summary

The CreditDelegation.sol will fail to account for the credit capacity correctly since it will add the debt instead of subtracting it.

Vulnerability Details

function getCreditCapacityUsd(
UD60x18 delegatedCreditUsdX18,
SD59x18 totalDebtUsdX18
)
internal
pure
returns (SD59x18 creditCapacityUsdX18)
{
creditCapacityUsdX18 = delegatedCreditUsdX18.intoSD59x18().add(totalDebtUsdX18);
}

The credit capacity is used to represent the amount available for the market to give as credit. The totalDebt is the amount that was already given to the perp engine. In order to find the credit capacity it should subtract the totalDebtUsdX18 instead of adding it.

Impact

Wrong creditCapacityUsdX18 could result in the vault distributing more debt even if it does not have any capacity left.

Tools Used

Manual Review

Recommendations

Subtract instead of adding it.

Updates

Lead Judging Commences

inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Market::getCreditCapacityUsd overestimates the credit capacity (it adds instead of substracting)

Support

FAQs

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