Function: cancel(byte[32] asset, address account, CancelArgs args)
The cancel
function allows an account or approved operator of an account to manually cancel previously submitted limit orders that are still active (not yet filled or expired).
Inputs
asset
Control: Full control.
Constraints: Market should exist.
Impact: Determines from which
asset
market the orders are canceled.
account
Control: Full control.
Constraints: Only the order owner (or authorized operator) can cancel the order.
Impact: Owner of the orders.
args.orderIds
Control: Full control.
Constraints: Active orders.
Impact: Orders to be canceled.
args.settlement
Control: Full control.
Constraints:
ACCOUNT
andINSTANT
.Impact: Settlement mode for the collateral refund.
Branches and code coverage
Intended branches
reduceOnly
order — no refund.Successfully cancels all active limit orders.
INSTANT
settlement.ACCOUNT
settlement.Refunds correct margin.
No orders exist. No margin is refunded.
orderIds
contains multiple valid orders and one invalid, and it is skipped.orderIds
contains duplicated orders, and they are all skipped, except the first one.Cancels the last order in the book.
Negative behavior
The caller is not an owner or approved operator.