Router Hook
TransferHook program that chains multiple compliance hooks on a single token
Overview
The Router Hook enables a single Token-2022 mint to enforce multiple compliance features simultaneously. It reads each sub-hook's config account inline (raw byte deserialization) rather than using CPI calls, keeping compute usage within Solana's transaction limits.
Program ID: HHnt7Hfnp2fDftFNCFPqEhebgXGizuqubXqhiEi8C1of
Execution Order
When a transfer is executed, the Router checks sub-hooks in order:
- Allowlist Hook — validates source and destination are approved
- Tax Hook — logs the transfer for tax collection
- Hold Hook — verifies the source wallet's lock-up has expired
- Max Balance Hook — ensures destination balance + amount does not exceed the cap
Pass PublicKey.default for any hook you want to skip.
Accounts
RouterConfig PDA
Seeds: ["router-config", mint]
| Field | Type | Description |
|---|---|---|
authority | Pubkey | Admin who can manage the router |
mint | Pubkey | The token mint |
is_active | bool | Kill switch |
allowlist_hook_program | Pubkey | Allowlist Hook program ID |
tax_hook_program | Pubkey | Tax Hook program ID |
hold_hook_program | Pubkey | Hold Hook program ID |
max_balance_hook_program | Pubkey | Max Balance Hook program ID |
ExtraAccountMetas PDA
Seeds: ["extra-account-metas", mint]
Instructions
| Instruction | Description |
|---|---|
initialize | Create the router config PDA |
initialize_extra_account_metas | Create the ExtraAccountMetas PDA |
update_hooks | Change sub-hook program addresses |
update_authority | Transfer admin rights |
toggle_active | Emergency kill switch |
execute | TransferHook entry point |
Design Notes
- The Router reads sub-hook configs via raw byte deserialization, not CPI
- This avoids CPI depth limits and keeps compute usage low
- Each sub-hook must still have its own config and ExtraAccountMetas PDAs initialized
- The Router's ExtraAccountMetas PDA includes references to all sub-hook accounts