Overview
Fills an array of orders with the caller (msg.sender) as the taker. This is a batch version of fillOrder that allows operators to execute multiple orders efficiently in a single transaction.
Parameters
Array of orders to be filled. See Order Structure for details.Each order must:
- Have a valid signature from the maker
- Not be expired (if expiration is set)
- Not be cancelled or fully filled
- Have a valid nonce
- Have a fee rate below the maximum allowed
- Reference a registered token ID
Array of amounts to fill for each corresponding order, always denominated in terms of the maker amount.Requirements:
- Array length must match the
ordersarray length - Each fill amount must be less than or equal to the corresponding order’s remaining unfilled amount
Requirements
- Caller must be an authorized operator (
onlyOperator) - Trading must not be paused (
notPaused) - Function must not be re-entered (
nonReentrant) ordersandfillAmountsarrays must have the same length- Each order must pass all validation checks
- Caller must have sufficient balance of all required taker assets
- Order makers must have sufficient balance of their respective maker assets
Behavior
Execution Flow
The function iterates through the arrays and calls the internal_fillOrder function for each order-amount pair. All fills are executed atomically - if any order fails, the entire transaction reverts.
Order Processing
For each order in the array:- Order is validated (signature, expiration, nonce, etc.)
- Fees are calculated based on the order’s
feeRateBps - Assets are transferred between the operator and order maker
- Order status is updated on-chain
- Events are emitted
Gas Optimization
This function is more gas-efficient than callingfillOrder multiple times because:
- Only one transaction is submitted
- Shared setup costs are paid once
- Reentrancy guard is checked once
Events
Emitted for each order where a fee is charged (if fee > 0).
Errors
All errors from fillOrder can be thrown for any order in the array:Caller is not an authorized operator
Trading is currently paused
One or more orders have passed their expiration timestamp
One or more orders have already been fully filled or cancelled
One or more order signatures are invalid
One or more order nonces are invalid
One or more order fee rates exceed the maximum allowed
One or more fill amounts exceed the remaining unfilled amount
One or more orders specify a specific taker and caller is not that address
Example Usage
Use Cases
Multi-Order Fills
Perfect for filling multiple limit orders from different makers in a single transaction, reducing gas costs and ensuring atomic execution.Batch Processing
Operators can efficiently process batches of orders without worrying about partial failures - either all orders fill or none do.Order Book Sweeping
Fill multiple levels of the order book in one transaction to execute large trades efficiently.See Also
- fillOrder - Fill a single order
- matchOrders - Match a taker order against maker orders
- Order Structure - Details on the Order type