How Post-Hooks Work
Example 1: Swap → Stake (Lido stETH)
Swap USDC for WETH, then stake the WETH into Lido to receive stETH.Example 2: Swap → Bridge (Across Protocol)
Swap tokens on Ethereum, then bridge the received tokens to Arbitrum via Across.CoW Swap also supports native cross-chain swaps through the UI, which handles bridging automatically without custom hooks.
Example 3: Swap → Vault Deposit (ERC-4626)
Swap tokens and deposit into an ERC-4626 yield vault:Key Considerations
Gas Limits
| Post-hook operation | Recommended gas limit |
|---|---|
| ERC-20 approve | 50,000 |
| Lido wrap/unwrap | 100,000 |
| Bridge deposit (Across) | 200,000 |
| ERC-4626 deposit | 150,000 |
| CoW Shed multicall overhead | +50,000 |
Amount Handling
Post-hooks execute with a fixed amount — the exactcallData you sign. If the swap returns more tokens than expected (surplus), the extra tokens remain in the CoW Shed proxy.
To handle variable amounts, you can:
- Use the full balance in the CoW Shed proxy (if the protocol supports
type(uint256).max) - Set the post-hook amount to the order’s
buyAmount(guaranteed minimum)
Failure Modes
If a post-hook fails, the entire settlement transaction reverts — your swap doesn’t execute either. Ensure:- Sufficient gas limits for each hook operation
- Correct token approvals in the hook chain
- The target protocol accepts the deposit/stake/bridge at the time of execution
Next Steps
- Hooks: Getting Started — create your first hook step-by-step
- Hook Store — browse pre-built hooks or publish your own
- Hooks Guide — complete hooks reference
- Account Abstraction (CoW Shed) — CoW Shed setup and API
- Hook dApp Development — build hooks for the CoW Swap UI