CoW Hooks
CoW Hooks allow users to pair any Ethereum action (or set of actions) with an order on CoW Protocol, leveraging the solvers to execute the actions together in the sequence.
Hooks execute the entire sequence as a single transaction. True to the CoW Protocol model, users pay gas fees in their sell token if, and only if, the sequence of transactions succeeds. Under the hood, CoW Hooks are arbitrary Ethereum "calls" that attach to an order and execute before and/or after the order. Developers and advanced traders can use code to express an intent that performs some action before a swap (pre-hooks) and after a swap (post-hooks).
Pre-Hooks
These are actions that execute before the swap, allowing pre-hooks to be used to "set up" an order. Some examples including:
- Unstaking tokens just-in-time for trading
- Claiming an airdrop right before dumping
- Signing token approvals so that the approval and the trade itself are batched together as a single action
Post-Hooks
These are actions that execute after the swap, taking advantage of trade proceeds. Examples include:
- Bridging funds to L2s
- Staking funds
Getting started
To get started with writing a CoW Hook, check out our technical documentation. You can also read more about CoW Hooks on our blog or through our tutorials — here and here.