Skip to content

Hook examples

Choose a source-backed starting point for fees, eligibility, rewards, or a composed policy.

These programs live under examples/hooks/ in the protocol repository. They are optional, independently deployed examples. No allowlist, window, reward system, or launch fee is a built-in restriction on an unhooked pool.

Start withSource directoryWhat it demonstratesNext guide
Lifecycle probelifecycle/Authenticate and acknowledge all ten phases; reject a chosen phaseFirst hook
Dynamic feedynamic-fee/Choose a Clock-based trading fee within the pool capDynamic fees
Launch decaydecaying-fee/Reduce a configured 99% opening fee toward a floor over a durationDecaying fees
Trading windowtimelock/Include the opening instant and exclude the closing instantTrading windows
Membershipallowlist/Verify a Merkle proof bound to the authenticated actorAllowlist
Rewardsrewards/Issue bounded, non-transferable credits from eligible settled outputRewards
Shared supportshared/Authentication, policy account setup, and client encodingAuthentication

Pick the smallest suitable program

Use the lifecycle probe to learn the callback contract. Add one policy at a time, with explicit success and rejection cases. For fees, configure both a compatible hook profile and the pool's immutable fee cap. The 99% ceiling does not change another pool's fee or override a lower configured cap.

For membership and windows, evaluate the authenticated actor and runtime Clock. For rewards, wait for AfterSwap and use settled output. Any external mint or state write needs the declared program and account permissions; rewards do not borrow the trader's signature or vault authority.

Combine policies deliberately

A pool binds one hook program. Selecting several example directories does not stack them. A combined hook implements a single account contract and ordered evaluation: authenticate, check eligibility, choose permitted fees, settle through core, then apply bounded after-effects.

Follow compose a policy for a window plus membership, fee schedule, and rewards. Liquidity and donation policies describe other callback choices; they are not a separate default program.

Verify the complete integration

Test boundary values, substituted accounts, missing quote context, and rollback after every enabled phase. A locally successful callback is not proof of quote/execution parity. Pair validation with Metis integration, and use troubleshooting for common account and reply failures.