User should not increase but because of incorrect conditions when user changes sign of the position size this condition is skipped.
Impact is difficult to determine as there is no specification of why market can be disabled.
When user creates order that is new or increases existing position size it checks whether market is enabled. If market is not enabled transaction will revert (this OrderBranch.createMarketOrder()
code part is the same as in SettlementBranch._fillOrder()
):
Let's take a look at what's inside Position.isIncreasing()
:
This function returns true if there is no existing position (self.size == 0
) or when position size is increased compared to existing position size, so if position size and sizeDelta have same sign. In case if signs are different this function would return false
. This allows user to decrease (close) position (and condition from OrderBranch.createMarketOrder()
so user can even close position for disabled market). But there is no condition that disallows user to flip position by changing position direction (from for example long to short). By doing so user can temporarily change position size, and then make same action and pass enough sizeDelta to flip position again and make new size bigger than initial. Here is steps example:
- user has existing buy position;
- owner closes market;
- user don't want to close position and want to increase this position size (maybe to get some profit from market price)
- user flips position by specifying sizeDelta.abs() > size
(and size + sizeDelta > minimum position size
), where sizeDelta
sign is -;
- after this order is filled user creates similar order but with initial sizeDelta sign (+) and specifies such sizeDelta that is bigger than current position size (which is negative), big enough to flip position again and additional sizeDelta to increase initial position.
If sign of initial size
and newSize
are different check whether market is enabled:
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.