Offchain orders cannot be filled correctly
If multiple offchain orders are being filled in a single transaction and one of them fails in _fillOrder
function, all preceding successful orders in the same transaction will also be reverted.
The current implementation of fillOffchainOrders
can revert the entire transaction if the _fillOrder
function call fails. Multiple orders may need to be resubmitted, increasing gas costs and transaction times.
Here we can see the function call inside a loop (checking each order):
Now let's check _fillOrder
function. In some scenarios it is possible that the trader does not meet the margin requirement check here:
Furthermore the _fillOrder
function includes a call to revert Errors.InsufficientMargin
to handle insufficient margin scenarios. However, this call cannot emit the correct order details, as it only provides the trading account ID and margin-related values, without specific details about the failed order. This prevents the backend servce to retry the correct order of the account.
A trader places an off-chain order.
The trader attempts to cancel all of his active orders and open a new position.
_fillOrder
is called and reverts due to the trader not meeting the margin requirements.
The whole transaction reverts preventing further action on this order on the trader's end.
All of the prevoius trader's orders remain active.
This leads to an order management issue where legitimate orders cannot be fulfilled or cancelled correctly.
Traders may experience potential financial loss due to the inability to manage their orders accurately.
Manual review
Implement try-catch blocks to handle _fillOrder
calls individually. This approach allows each order to be processed independently, ensuring that a failure in one order does not revert the entire transaction.
If you send 1 cancel and 1 create it should still run the cancel, not revert everything.
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.