HardhatDeFi
15,000 USDC
View results
Submission Details
Severity: medium
Invalid

No slippage on redeemPositionToken, can cause users to get less than they should and break invariant

Summary

No slippage on _redeemPositionToken, can cause users to get less than they should and break invariant

Vulnerability Details

Users can redeem position token (long / short) by calling the redeemPositionToken function → _redeemPositionToken . The steps that will occur are:

  1. Check whether the position token exists or not, if it does then continue.

  2. 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.

  3. Position token as many as the amount entered by the user are sent to the AaveDIVAWrapperCore contract.

  4. Then the IDIVA(_diva).redeemPositionToken function will be called to redeem the position token and AaveDIVAWrapperCore received wToken

  5. 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 :

Alice redeem specs :
- address _positionToken : long token
- uint256 _positionTokenAmount : type(uint256).max
- address _recipient : Alice
- uint256 _pool.payoutLong : 0.2
- Alice long position token balance on her address : 104
- Assume all have same decimals for simplicity
The calculation for wTokens :
uint256 _amountToReturn = (_tokenPayoutAmount * _amount) /
(10**uint256(_decimals));
= (0.2 * 104) / decimals
= 20.8 -> this will rounding down to 20

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:

short token supply = long token supply = wToken supply

Impact

  1. Alice received less collateral token

  2. Break invariant about total supply of position token and wToken

Tools Used

Manual Review

Recommended Mitigation

  1. Consider adding slippage for redeem function

  2. Consider use rounding up to calculate the number of wTokens received

Updates

Lead Judging Commences

bube Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Appeal created

0xdemon Submitter
9 months ago
bube Lead Judge
9 months ago
bube Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.