Part 2

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

Underflow in `_updateCreditDelegations()` when calculating credit delta

Summary

The credit delta calculation in _updateCreditDelegations() uses UD60x18 which causes underflow when vault's credit delegation decreases.

Vulnerability Details

In _updateCreditDelegations(), the credit delta is calculated using unsigned integers which will underflow when the new credit delegation value is less than the previous value:

File: Vault.sol
600: // calculate the delta applied to the market's total delegated credit
601: UD60x18 creditDeltaUsdX18 = newCreditDelegationUsdX18.sub(previousCreditDelegationUsdX18);

The credit delegation can decrease in several scenarios including LP redemptions, in this case, recalculateVaultsCreditCapacity() won't work as expected.

Impact

The underflow causes reverts in recalculateVaultsCreditCapacity() which breaks core protocol functionality like deposits, withdrawals, staking and rewards distribution.

Recommendations

Use SD59x18 instead of UD60x18 when calculating the credit delta to properly handle decreases in credit delegation.

Updates

Lead Judging Commences

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

Vault::_updateCreditDelegations uses unsigned UD60x18 for credit delegation delta calculation which will underflow on any decrease in credit delegation amount

Support

FAQs

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