No slippage on _redeemPositionToken, can cause users to get less than they should and break invariant
Users can redeem position token (long / short) by calling the redeemPositionToken function → _redeemPositionToken . The steps that will occur are:
Check whether the position token exists or not, if it does then continue.
Check how much will be redeemed, if the user enter type(uint256).max then all balance position token owned by the user will be redeemed.
Position token as many as the amount entered by the user are sent to the AaveDIVAWrapperCore contract.
Then the IDIVA(_diva).redeemPositionToken function will be called to redeem the position token and AaveDIVAWrapperCore received wToken
After that _redeemWTokenPrivate is called, wToken redeem against collateralToken (i.e USDT) and USDT send to user
The problem arises at step 4, during the process of redeeming position tokens to wToken on the DIVA protocol. Please note that the IDIVA(_diva).redeemPositionToken function does not have a slippage mechanism either and this causes users to receive less wToken than they should and may even receive 0 wToken.
Example :
Alice want to redeem all of her position token balance, assume the specs will be like this :
Based on the calculation above, Alice loses 1 wToken and the value of one wToken == collateralToken (i.e USDT).
Apart from that, there are invariants that are broken because the burn position token process does not have the same composition as the wToken that will be burned causing the total supply of long token =! wToken supply, the variants are:
Alice received less collateral token
Break invariant about total supply of position token and wToken
Manual Review
Consider adding slippage for redeem function
Consider use rounding up to calculate the number of wTokens received
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.