The createMarketOrder
function in the OrderBranch
contract incorrectly updates the entry price when reducing the position size. This behavior is not expected as the entry price should remain unchanged when only the position size is reduced.
When reducing a position size, the createMarketOrder
function incorrectly changes the entry price. The function should maintain the original entry price as it is only the position size being reduced, not a new position being opened.
When reducing a position, the oldPosition.update(...)
method is called within the fillMarketOrder
, which incorrectly resets the entry price to the current price.
This vulnerability causes the entry price to be incorrectly adjusted when a trader reduces their position size, which can result in inaccurate calculations of unrealized profit and loss (PnL) and affect the trader's financial decisions and strategies.
Foundry
Zaros Website
Preserve Entry Price on Position Reduction: Update the createMarketOrder
function to ensure that the entry price remains unchanged when only the position size is reduced. This can be achieved by modifying the update
function to avoid resetting the lastInteractionPrice
when reducing the position size.
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.