Due to a logic error in the canRemoveCollateral() function, the user cannot retrieve the maximum allowed collateral that corresponds with his borrowed amount of EUROs.
For a small borrowed amount, the user is forced to keep a fairly large amount of collateral. In the test scenario below, we can see that the collateral rate (which should be a factor of 1.2) goes up to a factor of 45.7
Let's take a simple example:
We provide 1 ETH of collateral
We borrow 100 EUROs (mint function)
We burn 95 EUROs (burn function)
At this stage, the minted amount = 100 EUROs - 95 EUROs + 0.5 EUROs (fee) = 5.5 EUROs
The collateral rate used in the unit tests is a factor of 1.2
This means, the minimum required collateral needs to be: 5.5 * 1.2 = 6.6 EUROs
In our test file, we use: 1ETH = 1509.43 EUROs => 6.6 EUROs = 0.00437ETH
So, the minimum collateral required in ETH is 0.00437ETH
This means, we should be able to retrieve up to: 1ETH - 0.00437ETH = 0.995ETH
The currently used logic forces the following conditions:
currentMintable >= eurValueToRemove
currentMintable is 1257.86 EUROs => this means we must leave at least 251.5 EUROs (or 0.1666ETH) as collateral and can retrieve only 1 - 0.1666 = 0.829 ETH
However, we only have a minted amount of 5.5 EUROs => so, this would be a collateral rate of: 251.5 / 5.5 = 45.7 instead of 1.2 !
The second condition is also incorrect:
minted <= currentMintable - eurValueToRemove
5.5 EUROs <= 1257.86 EUROs - eurValueToRemove => eurValueToRemove can be at most: 1257.86 EUROs - 5.5 EUROs = 1252.36 EUROs == 0.829ETH
To demonstrate the problem with the canRemoveCollateral() function, the following Test/POC can be used:
1: Add the following test to the smartVault.js file :
Depending on the amount of EUROs minted, the user may not be able to remove a sizeable portion of his collateral. Therefore, the protocol does not work as announced and users may be reluctant to use it.
Manual Review
Replace the current canRemoveCollateral() function:
With the following modified function:
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.