Skip to main content


A contract for executing a users' custom actions before and after settlement.


The main settlement contract for CoW Protocol allows for custom interactions to be executed before and after the settlement logic. This is primarily used by solvers to access on-chain liquidity for settling batch auctions, but it can also be made available to users to perform custom actions, hereafter referred to as hooks.

However, executing hooks from the settlement contract is not ideal for two reasons:

  1. Hooks may be malicious and drain the protocol fees
  2. Hooks may revert, causing the settlement contract to revert, disrupting the settlement process

To mitigate these risks, users' hooks are executed by a trampoline contract, HooksTrampoline, which insulates the settlement contract.

Therefore executing users' hooks can be visualized as follows:

Guarantees and Invariants

  1. The trampoline contract is not upgradable
  2. Hooks are only executed during the course of a settlement on CoW Protocol
  • Beware of leaving any funds in the trampoline contract. These are accessible to anyone.
  • Do NOT grant any permissions to the trampoline contract. These are accessible to anyone.

Data Types and Storage


Hooks are passed to the trampoline contract as a Hook struct:

struct Hook {
address target;
bytes callData;
uint256 gasLimit;
targetAddress of the contract to call
callDataData to pass to the contract
gasLimitMaximum amount of gas to use for the call


For settlement


This function is called by the settlement contract during the course of settlement as an interaction to execute the user's hooks.

function execute(Hook[] calldata hooks) external onlySettlement;
hooksArray of hooks to execute