DeFiFoundry
60,000 USDC
View results
Submission Details
Severity: medium
Invalid

Users could be unable to close their positions in a certain case

Summary

Users could be unable to close their positions in a certain case

Vulnerability Details

Whenever a user's order is filled, we have this function:

perpMarket.checkTradeSize(sizeDeltaX18);

The function checks whether the size delta of the order is high enough and reverts otherwise. Imagine the following scenario:

  1. Bob creates a long position of 15 tokens, exactly equal to the minimum trade size

  2. An admin changes the minimum trade size to 20 tokens

  3. Bob can't close his position as the minimum is 20 tokens and his position is of only 15 tokens

Even if we assume that admins would never do such a thing under any circumstances, it can still happen under normal conditions. Bob decides to create a position, an admin changes the minimum trade size and his transaction goes through before Bob's. Then, the issue above will occur. The admin didn't mean to do so however things like that can happen and there is no protection against it.

Impact

Users could be unable to close their positions in a certain case

Tools Used

Manual Review

Recommendations

Remove that check altogether as the function still checks for the actual new order size and it would revert if it is below the minimum and not 0.

Updates

Lead Judging Commences

inallhonesty Lead Judge
about 1 year ago
inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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