When total credit capacity of a vault is zero or even negative (more debt than assets), Vault::getLockedCreditCapacityUsd
returns 0
, signaling no credit capacity is locked. This allow depositors to redeem shares when Vault is in debt, increasing the vault's debt even more.
Users who provided liquidity to vaults can redeem their share by calling initiateWithdrawal
followed by redeem
.
First, the available credit capacity and the locked credit capacity are cached. Then the actual redeem takes places where shares are burnt and assets are transferred from Vault to user, decreasing the vault's credit capacity.
Lastly the code should checks if there's enough credit capacity left in the vault.
The total credit capacity of a vault is calculated as assetValue - debt
, a negative value meaning vault is insolvent.
When credit capacity is lower or equal to 0
, getLockedCreditCapacityUsd returns 0
.
In redeem
there's this check: if(ccBeforeRedeem - ccAfterRedeem < lockedCcBeforeRedeem) revert
Note: There's another issue related to "unlocked credit capacity" check reported in a separate submission. Solving that one as initially intended will not fix both problems without introducing new ones. Both fixes must be implemented as suggested to remove both issues.
Consideer the follwing example:
ccBeforeRedeem : - 100 (usd value)
lockedCcBeforeRedeem : 0
user wants to redeem 20 usd worth of assets => ccAfterRedeem = -100 - 20 = -120
With these values, when the locked credit capacity check is executed:
if(-100 - (-120) < 0)
<=> if(20 < 0)
which is false and the redeem doesn't revert as intended.
When the vault is insolvent LPs can withdraw their liquidity. Profitable traders will not be able to swap usdToken
for vault's assets, incurring a loss.
Update getLockedCreditCapacityUsd
to return type(uint256).max
when there's no credit capacity left in vault. In this way you notify the caller the entire credit capacity is locked.
Note: as mentioned earlier, both fixes, this and the one recommended in the second issue must be implemented to remove both problems.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.