Product

Hooks

View as Markdown

Extension Point: Hooks

The protocol's core logic — pricing, settlement, liquidity management — behaves identically across every pool. In practice, though, individual pools often need their own rules: dynamic fees that rise only under heavy volume, access restrictions that permit trading only under certain conditions, or liquidity strategies that automatically rebalance around each settlement. Hooks are the extension point that lets this kind of pool-specific logic attach as a separate contract, without touching the protocol core.

A hook can intervene before and after each of the five actions a pool supports — initialization, adding liquidity, removing liquidity, swapping, and donating. Each action has a "before" and an "after" point, for ten intervention points in total. Which of these a pool uses is chosen when the pool is created; any point not chosen is simply never invoked.

beforeafterinitializeadd liquidityremove liquidityswapdonate

Take the swap points alone as an example: a pre-trade intervention can alter the amount that actually settles, while a post-trade intervention can require additional asset movement layered on top of an already-finalized result.

Permission Is Fixed When the Pool Is Created

What a hook is allowed to do is fixed the moment its pool is created — the pool is only created if the hook's self-declared capability list matches the pool's configuration exactly, and that scope never changes afterward.

A Hook's Settlement Is Recorded Separately

Any additional asset movement a hook generates is always kept separate from the trader's own settlement, and passes through the same transaction ledger check.

traderhookchecked0

This check only guarantees that a hook cannot break accounting integrity — not that its judgment is always fair. What logic a hook actually runs within its declared scope is outside the protocol's concern.

Properties and Trade-offs

  • Leaving the range stops yield immediately. A position earns nothing from subsequent trades until price re-enters its range — not a defect, but an inherent property of concentrating liquidity in a range.
  • A range with a single liquidity holder can have its cumulative fee counter artificially inflated. If the sole LP donates to itself, the cumulative value can rise abnormally.
  • The protocol's fee cut is not a fixed value. A portion of LP fees can be split off at a governance-set rate, which may change over time.
  • Using a pool with a hook means trusting that hook too. The protocol only prevents a hook from exceeding its declared scope — it makes no guarantee about the logic inside that scope.
Previous
Settlement