Specification
There are two type of hooks available:pre and post. Pre hooks are executed before any order signature is checked (in particular, before any funds are taken from the order owner). Post hooks are executed after all orders in a batch are settled (that is, the proceeds of the orders have already been credited to the receiver).
Both pre and post hooks are specified as an array of hooks.
Each hook is described by three parameters:
-
target: the target address of the Ethereum call. Using implementing EIP-2612 approvals as an example, this would be the token contract. -
callData: the data of the Ethereum call. In the example above, the ABI-encoded function call topermit. -
gasLimit: a hard limit on the amount of gas needed by the call. An order quote uses this value to estimate the total fee needed to execute an order. The more gas needed, the higher fee will be needed for the order to be settled. If the call requires more gas than specified here, the Ethereum call in the hook will be internally reverting but the order will be executed regardless.
When placing partially fillable orders with hooks, pre-hooks will only be executed on the first fill. Therefore, your hook should ensure that the liquidity is sufficient for the entire order to be filled. On the other hand, post-hooks are executed on every fill.