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 with | Source directory | What it demonstrates | Next guide |
|---|---|---|---|
| Lifecycle probe | lifecycle/ | Authenticate and acknowledge all ten phases; reject a chosen phase | First hook |
| Dynamic fee | dynamic-fee/ | Choose a Clock-based trading fee within the pool cap | Dynamic fees |
| Launch decay | decaying-fee/ | Reduce a configured 99% opening fee toward a floor over a duration | Decaying fees |
| Trading window | timelock/ | Include the opening instant and exclude the closing instant | Trading windows |
| Membership | allowlist/ | Verify a Merkle proof bound to the authenticated actor | Allowlist |
| Rewards | rewards/ | Issue bounded, non-transferable credits from eligible settled output | Rewards |
| Shared support | shared/ | Authentication, policy account setup, and client encoding | Authentication |
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.