Submitted by 0xA5DF, also found by Jeiwan, KingNFT, and HollaDieWaldfee
The PairsContract registers the total long/short position thats open for a pair of assets, whenever a new position is created, the total grows accordingly.
However at executeLimitOrder() the position size thats added is wrongly calculated - it uses margin before fees, while the actual position is created after subtracting fees.
The OpenInterest would register wrong values (11% diff in the case of PoC), which will distort the balance between long and short positions (the whole point of the OpenInterest is to balance them to be about equal).
In the following test, an order is created with a x100 leverage, and the position size registered for OI is 11% greater than the actual position created.
Output:
Correct the calculation to use margin after fees.
TriHaz (Tigris Trade) confirmed and commented:
Alex the Entreprenerd (judge) commented:
GainsGoblin (Tigris Trade) resolved:
