Users who take a loan can trade on uniswap with their locked up collateral. The protocol calculates the minimum amount of tokens that need to be returned to the vault to stay in a healthy CR. This calculation is done in the calculateMinimumAmountOut
function. But the protocol does not take into account the slippage of the swap. This enables MEV bots to sandwich the swap and steal funds from the vault.
Here we can see the swap function and how it calculates the amountOutMinimum
parameter passed to uniswap:
If more than enough collateral is in the vault it passes 0 as amountOutMinimum
to uniswap therefore no protection at all against sandwich attacks.
If this is not the case, it passes the amount which is needed so that the collateral rate is not broken to uniswap. This can potentially also be way to less. If a trade about 1000e18 tokens takes place and only 1e18 token is needed to not break the collateral rate than there is not much difference to passing 0 as amountOutMinimum
.
Therefore, swap are most likely not or insufficiently protected against sandwich attacks.
MEV bots can take opportunity of the vaults swaps.
Add a minAmtOut parameter to the swap function input as this should be calculated off chain and pass this parameter or the calculated parameter to uniswap depending on which is higher.
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.