Overview
Fills an order with the caller (msg.sender) as the taker. This function allows an operator to execute a single order for a specified fill amount.
Parameters
The order to be filled. See Order Structure for details.The 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
The amount to be filled, always denominated in terms of the maker amount.Must be:
- Less than or equal to the remaining unfilled amount
- Greater than 0 for a meaningful fill
Requirements
- Caller must be an authorized operator (
onlyOperator) - Trading must not be paused (
notPaused) - Function must not be re-entered (
nonReentrant) - Order must pass all validation checks (signature, expiration, nonce, etc.)
- Caller must have sufficient balance of the taker asset
- Order maker must have sufficient balance of the maker asset
Behavior
Asset Transfer Flow
- Validation: The order is validated including signature verification, expiration check, and nonce validation
- Fee Calculation: Fees are calculated based on the order’s
feeRateBpsand the fill amounts - Asset Transfers:
- Taker asset (minus fees) is transferred from the operator to the order maker
- Maker asset is transferred from the order maker to the operator
- Fees are implicitly collected by the operator (deducted from assets paid by operator)
- State Update: Order status is updated with the new remaining amount
Partial Fills
Orders can be partially filled. The order’s remaining amount is tracked on-chain and updated with each fill. When fully filled, the order is marked asisFilledOrCancelled = true.
Events
Emitted when an order is successfully filled.
orderHash: Hash of the filled ordermaker: Address of the order makertaker: Address of the taker (operator calling fillOrder)makerAssetId: Token ID of the asset sold by maker (0 for collateral)takerAssetId: Token ID of the asset bought by maker (0 for collateral)makerAmountFilled: Amount of maker asset transferredtakerAmountFilled: Amount of taker asset transferredfee: Fee charged to the maker on their proceeds
Emitted when a fee is charged (if fee > 0).
Errors
Caller is not an authorized operator
Trading is currently paused
Order has passed its expiration timestamp
Order has already been fully filled or cancelled
Order signature is invalid
Order nonce is invalid (maker has incremented their nonce)
Order fee rate exceeds the maximum allowed
Fill amount exceeds the remaining unfilled amount
Order specifies a specific taker and caller is not that address
Example Usage
See Also
- fillOrders - Fill multiple orders in a single transaction
- matchOrders - Match a taker order against maker orders
- Order Structure - Details on the Order type