Part 2

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

Division by Zero in `_updateCreditDelegations()` Can Cause Vault Credit Allocation Failure

The _updateCreditDelegations() function calculates a vault’s share of credit delegation using the formula:

UD60x18 creditDelegationShareX18 = ud60x18(creditDelegation.weight).div(ud60x18(totalCreditDelegationWeightCache));

However, if totalCreditDelegationWeightCache == 0, the function attempts to divide by zero, causing a revert and preventing credit delegation updates. This scenario can occur when:

  1. A vault has no active credit delegations.

  2. The vault’s total credit delegation weight has been reset but _updateCreditDelegations() is still called.

  3. A market is removed, causing the total delegation weight to drop to zero.

Since this function plays a key role in recalculating credit allocations during vault updates, a single zero-weight scenario can halt the entire credit delegation process for the protocol.

Impact:

Credit delegation updates will fail, preventing vaults from properly redistributing credit, leading to stalled lending operations and potential financial inefficiencies across the system.

Mitigation:

Before performing division, explicitly check if totalCreditDelegationWeightCache == 0 and set creditDelegationShareX18 = UD60x18_ZERO to avoid division errors.

Updates

Lead Judging Commences

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

Support

FAQs

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