Under collaterized Vault trying to make a swap() will always fail, this is why they should the swap() function should check whether the loan is fully collaterized.
When performing a swap the amountOutMinimum is calculated based on the requiredCollateralValue - collateralValueMinusSwapValue
.
Which means that if a position is undercollaterized the swap cannot ever hope to be successful as the requested amountOutMinimum
will exceed the market value of the amountIn
.
Considering the fees from uniswap fee and the swapFees, we should expect the value of amountOutMinimum
to be in EUROs lower than the amountIn
value in EUROs. This is why attempting a swap() while not have the required collateral is just a waste of gas and should be avoided.
The impact is not severe as it is in the protocol design not to allow a position to go below the collaterization rate after a swap(), however if the loan is under collaterized then swaps shouldn't even be attempted, as they will always revert.
Manual review
Add a check that makes sure that no swap()
are attempted whilst the position is undercollaterized.
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.