Cheerful Taffy Dolphin - Vault Collateral Over-Reservation Bug Leads to 100% Capital Lockup Due to Zero-State Division Edge Case #42
Labels
Sponsor Disputed
The sponsor disputed this issue's validity
Cheerful Taffy Dolphin
Medium
Vault Collateral Over-Reservation Bug Leads to 100% Capital Lockup Due to Zero-State Division Edge Case
Summary
In the vault's allocation logic, there's a critical bug in how ineligible collateral is calculated during early vault states or after full redemptions. The issue stems from the
_ineligible()
function that determines how much collateral should be reserved vs made available for new allocations:https://github.com/sherlock-audit/2025-01-perennial-v2-4-update/blob/main/perennial-v2/packages/vault/contracts/Vault.sol#L459
The bug emerges in the edge case when there are no shares and no redemptions in the vault - a state that occurs at vault initialization or if all shares have been redeemed.
This is used in the ineligible calculation:
Consider what happens when the vault has no shares and no redemptions:
context.global.shares
is 0context.global.redemption
is 0context.global.shares.add(context.global.redemption)
is 0context.global.redemption
is also 0In this case, we hit the
0/0
condition inunsafeDiv
, which returnsONE
(1e6 in Fixed6 representation). This means:redemptionEligible.mul(ONE)
equalsredemptionEligible
redemptionEligible
amount as ineligible for allocationThe current fallback to
ONE
effectively reserves 100% of redeemable collateral even when there are no redemptions pending, which is overly conservative and could unnecessarily restrict capital efficiency.Fix
A more capital efficient approach would be to explicitly handle this edge case:
The text was updated successfully, but these errors were encountered: