In the SmartVaultV3 contract the condition for fully collateralized vault is that the current minted amount should be less than or equal to the max mintable amount on the basis of the collateral deposited by user.
But due to incorrect implementation of SmartVaultV3::canRemoveCollateral function this will affect the removal of collateral and will prevent user from withdrawing their collateral even if the vault remains fully collateralized after removal of collateral, thus affecting the functioning of removeCollateralNative, removeCollateral and removeAsset.
The vulnerability arose due to the incorrect implementation of SmartVaultV3::canRemoveCollateral function which returns false even if the vault will remain fully collateralized after removal of the desired collateral by user.
Here the implementation for deciding whether the collateral can be removed or not is incorrect.
It checks that the minted amount should be less than (currentMintable - eurValueToRemove).
It checks by subtracting eurValueToRemove from currentMintable, where currentMintable is the max amount of euros a user can mint.
But it is irrelevant to subtract the eurValueToRemove from max euros a user can mint as it is not their euro collateral balance.
The correct implementation should be that, the minted amount to be less than (euroCollateral - euroValueToRemove) * HUNDRED_PC / COLLATERAL_RATE
User can't remove their collateral even if the vault is fully collateralized as the eurValueToRemove is subtracted from maxMintable but their actual balance is euroCollateral.
Thus leading to locking of their collateral tokens inside SmartVaultV3
Add the test in the file: test/smartVaultManager.js
Run the test:
Manual Review
Correct the implementation of canRemoveCollateral as below:
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.