When checking if the fillprice is valid, the wrong comparison is made. This will lead to offchain orders being filled at unfavourable prices, causing significant losses for traders. Specifically:
Buy orders will be filled at prices higher than the trader's specified target price
Sell orders may be filled at prices lower than the trader's specified target price
This completely undermines the purpose of limit orders, exposing traders to unexpected losses and violating their trading intentions.
The fillOffchainOrders()
function is used for filling offchain orders placed by users. After some checks and calculations, the functions trys to verify if the calculated fill price is valid for the order and if the order should be executed:
The issue with this check is that it checks in the wrong direction resulting in a positive outcome if the fill price is bigger than the targetPrice for buy orders and the fillprice is smaller than the targetPrice for sell orders. This results in orders been filled at unfavourable prices and favourable prices to be rejected.
Alice places a buy limit order with a target price of 100 USDC
The market price rises to 110 USDC
A keeper calls fillOffchainOrders()
with a fill price of 110 USDC
The current logic incorrectly determines this as a valid fill price (100 <= 110)
Alice's order is filled at 110 USDC, 10% higher than her specified limit price
This scenario results in Alice paying more than she intended, potentially leading to unexpected losses.
Correct the price comparison logic in the fillOffchainOrders()
function:
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.