The function canRemoveCollateral() compares two variables in different units, which prevents users from withdrawing collateral.
The canRemoveCollateral() function checks if the vault still has enough collateral if it removes _amount of _token. It compares the current maximum mintable with the value of the removed token.
However, these two variables are in different units. currentMintable is the value of the collateral token scaled by collateralRate, while eurValueToRemove is just the value of the removed token.
This issue may prevent users from withdrawing their collateral when they should be allowed to.
Consider the following scenario:
The vault has minted only 1 EURO, and the collateral value in the vault is 1,000,000 EUROs. Assume the collateralRate is 120%.
Since the vault only minted 1 EURO, it should only need a collateral value of 1.2 EUROs to cover it, so the user should be allowed to withdraw 999998.8 EUROs worth of collateral.
However, in function canRemoveCollateral(), we will have currentMintable = 1e6 / 120% = 833333.333.
As eurValueToRemove isn't scaled to collateralRate, any attempt to withdraw more than 833334 EUROs worth of collateral would fail.
Manual Review
Correct the implementation by scaling eurValueToRemove with collateralRate before performing the check.
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.