The isIncreasing()
function checks if the position is being increased and if yes there are checks if the market and the settlement are enabled, also it is used when checking which of the 2 margins (maintenance or initial) should be used when validating the margin requirement. The problem is that the function does not cover the case where the user is increasing his position but in the opposite direction
This is the current implementation of the isIncreasing()
The return covers only the cases when we are opening a new position or increasing it in the same direction. If we have the case where we have sizeDelta
-10 and then we increase our position with sizeDelta
+100 we are still increasing it but this statement will return false. This means that we are going to skip this check here
and also here we are going to get the wrong margin
We will get the maintenance margin instead the initial
And when this check here is performed
It will validate the wrong margin and it will not revert in some cases where it should because the maintenance margin is < initial margin
High because a functionality in the protocol does not work as intended. This will lead to unexpected behaviour and orders that should have reverted will be created and executed
Manual review
This check has to be changed. Perform a check using an abs() of the size delta to check if the new size delta is bigger than the previous one.
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.