The createMarketOrder function in the OrderBranch contract incorrectly handles the reduction of position sizes. This flaw forces traders to incur 100% of their losses when they attempt to reduce their position size, instead of the expected proportionate loss.
The createMarketOrder function allows users to create and update orders. When a trader running at a loss decides to reduce their position size by a certain percentage (e.g., 50%), the function should close only the corresponding percentage of the position and its losses. However, the function currently closes the entire position, forcing the trader to realize 100% of the losses at that time.
The function deductAccountMargin incorrectly deducts the full PnL for the entire position rather than proportionately based on the size reduction.
This vulnerability leads to incorrect financial outcomes for traders. When a trader attempts to reduce their position size, they are forced to incur the entire loss/profits of the position rather than just a proportionate amount. This can result in significant unexpected losses and incorrect trading behavior, impacting the trader's financial strategy.
Foundry
Zaros Website
Fix the Position Reduction Logic: Modify the createMarketOrder & fillMarketOrder function to ensure that it correctly handles partial position reductions. The function should only close the proportionate part of the position and realize corresponding losses.
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.