The fillOffchainOrders function contains a comment explaining the logic for validating fill prices based on whether the order is a buy or sell order. However, the actual code logic contradicts the comment, which may lead to confusion and potential errors in the order validation process.
Comment:
Code:
Comment: For a buy order, the fill price should be less than or equal to the target price.
Code: For a buy order, the fill price is valid if it is greater than or equal to the target price (ctx.offchainOrder.targetPrice <= ctx.fillPriceX18.intoUint256()).
Comment: For a sell order, the fill price should be greater than or equal to the target price.
Code: For a sell order, the fill price is valid if it is less than or equal to the target price (ctx.offchainOrder.targetPrice >= ctx.fillPriceX18.intoUint256()).
This discrepancy between the comment and the code can lead to:
Incorrect validation of fill prices for both buy and sell orders.
Potential execution of trades at invalid prices, causing financial losses.
Confusion among developers and auditors, leading to difficulty in maintaining and auditing the code.
Manual code review
Correct the Comment or Code Logic: Align the comment with the actual code logic or update the code to match the intended logic described in the comment. For example, if the comment is correct, the code should be:
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.