While swapping of token in SmartVault::swap, user can receive less token than expected because minimumAmountOut is set very low, if user have minted euros and collateralValueMinusSwapValue is less than requiredCollateralValue
Swapping of token takes minimumAmountOut, This is calculated in calculateMinimumAmountOut() which is calculating minimumAmountOut based on requiredCollateralValue & collateralValueMinusSwapValue. if collateralValueMinusSwapValue is less than requiredCollateralValue then minimumAmountOut is calculator.eurToToken(getToken(_outTokenSymbol), requiredCollateralValue - collateralValueMinusSwapValue)
Now this is an issue because if user have high collateral but minted less token and wanted to swap for a large amount, then in that case minimumAmountOut is very low as compare to amount that is being swapped for
// Here is the POC
Bob deposited 6000 euro worth of collateral
MaxMintable will be 5000 euros at 120% collateral rate
Bob minted 2000 euros and wanted to swap for his 5000 euro worth of collateral
minimumAmountOut will be only 1400 euro worth of collateral as collateralValueMinusSwapValue = 1000( 6000-5000 ) is less than requiredCollateralValue = 2400(2000*120/100). So minimumAmountOut is calculated based on calculator.eurToToken(getToken(_outTokenSymbol), requiredCollateralValue - collateralValueMinusSwapValue)
Now, this 1400 is very less than as compared to 5000(which is being swapped for) ie 72% less and this is just an example as this number can go up&down depending upon no. of minted euros and amount of collateral being swapped for
Users will receive less amount than expected
Manual Review
Take consideration of amount of token being swapped for while calculating minimumAmountOut
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.