Skip to main content

Hooks Trampoline

A dedicated trampoline contract for executing user-specified hooks in CoW Protocol settlements safely and efficiently

Why Hooks Trampoline?

Hooks Trampoline protects CoW Protocol settlements from malicious or poorly configured user hooks

Security Isolation

Executes hooks from an unprivileged context, preventing malicious hooks from accessing settlement contract funds or state

Gas Protection

Enforces gas limits on hook execution to prevent INVALID opcodes from consuming excessive gas and making settlements expensive

Revert Tolerance

Allows individual hooks to revert without failing the entire settlement, preventing DoS attacks on other orders

Settlement Access Control

Only accepts calls from the CoW Protocol settlement contract, allowing hooks to verify they’re part of a valid settlement

Quick Start

Get started with Hooks Trampoline in minutes

1

Install Foundry dependencies

Clone the repository and install dependencies:
forge install
2

Deploy the contract

Deploy Hooks Trampoline with your settlement contract address:
HooksTrampoline trampoline = new HooksTrampoline(settlementAddress);
3

Create and execute hooks

Define hooks and execute them through the trampoline:
HooksTrampoline.Hook[] memory hooks = new HooksTrampoline.Hook[](1);
hooks[0] = HooksTrampoline.Hook({
    target: hookContract,
    callData: abi.encodeCall(MyHook.execute, ()),
    gasLimit: 100000
});

// Called from settlement contract
trampoline.execute(hooks);

Explore the Documentation

Learn more about Hooks Trampoline’s architecture and how to use it effectively

How It Works

Understand the architecture and design decisions behind Hooks Trampoline

Security Model

Learn about the security guarantees and protection mechanisms

Gas Management

Discover how gas limits are enforced and why they matter

Testing

Run the test suite and write tests for your own hooks

Ready to integrate Hooks Trampoline?

Follow our installation guide to deploy and integrate Hooks Trampoline into your CoW Protocol settlement workflow

Get Started