is used to check whether the order will make the position grow in size. However this check can be easily bypassed by flipping a long position to short or short to long.
In the snippet below:
We can see that isIncreasing will return true if the current order is > 0 and the sizeDelta is also > 0. Similarly if the current order is < 0 and sizeDelta is also < 0, isIncreasing will be true.
However this doesn't account for orders that flip from short to long and long to short.
This could be illustrated by the following example:
initial position: long order 100.
size delta is -500.
the current position is now -400. The position is greatly increased, however isIncreasing will return negative.
This will effectively allow traders to increase trading positions in disabled Markets and when settlement are disabled. Which goes against the intended design, when settlements and markets are disabled positions should only be reduced or closed, not increased.
Furthermore it will allow the trader to pass order with maintenance margin only instead of initial margin .
This vulnerability endangers the protocol's especially when markets and settlements are disabled for security reasons.
The required margin a user has to use will also decrease greatly depending on the ratio difference between initial and maintenance margin
Manual review
In order mitigate this issue, consider making sure the trader doesn't flip orders in order to bypass the isIncreasing check.
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.