Overview
The standard
Hooks that answer, not only approve: Uniswap v4’s hook idea, on Solana, at the token level.
Why a new standard#
Token-2022 made transfer hooks safe by making them powerless: over a transfer, a hook can let it stand or make it fail. A hook on this standard keeps the safety rule, never the user’s signature, and answers instead; the token program or the DEX applies the answer.
Venues treat hooks as a risk. Meteora’s DBC revokes a token’s hook when it graduates, and DAMM v2 accepts a hook mint permissionlessly only once its hook is revoked. Orca lists hook mints case by case, and its criteria forbid hooks that charge fees or move tokens. Raydium’s CPMM and CLMM refuse hook mints unless an admin registers them. 5678
What a hook on this standard does#
- Runs
- Token hooks on transfers, mints and burns. Pool hooks on pool creation, liquidity and every swap.
- Sees
- The whole operation. A pool hook sees the trade: direction, amounts in and out, reserves, both tokens, the trader and who receives.
- Answers
- Up to three cuts from the amount, each to an account it names. A pool hook can also burn part of a swap and set its LP fee. A
before_*callback’s answer is applied with the operation. - Keeps
- 64 bytes of state per holder, inside the holding. No extra account per holder.
- Bounds
- Never the user’s signature, never more than the amount moved. The token program or the DEX checks every answer before applying it.
Side by side#
A Token-2022 transfer hook, checked against Token-2022 v11.0.0 (the build on mainnet) and Solana’s documentation, against a hook on this standard.
| Aspect | Token-2022 transfer hook | This standard’s hook |
|---|---|---|
| Runs on | Transfers only. Mints and burns never call it. 14 | Transfers, mints and burns; pool creation, liquidity and every swap. |
| When | After the balances have changed. 14 | Before and after. What a before callback answers is applied with the operation. |
| Sees | The transfer, read-only. Not why: no buy or sell flag, no price, no pool. It can only guess. 12 | Owners, balances, supply, who signed. A pool hook sees the whole trade. |
| Signatures | No account reaches it as a signer. 14 | Never the user’s either. The calling program signs every call, so a hook knows who is calling. |
| Over the amount | Let it stand, or make the whole transaction fail. 1 | Up to three cuts, each to an account it names. Never more than the amount. |
| Burn | It can’t change an amount or burn. 1 | A pool hook can burn part of a swap. |
| A swap’s fee | It can’t set a pool’s fee. | before_swap can set that swap’s LP fee. |
| State per holder | An extra account per holder, created and funded first, carried by every transfer. 12 | 64 bytes inside every holding, written with the balances. |
| A fee from the tokens moved | Only the transfer-fee extension: one rate per mint, on every transfer alike. 13 | Cuts per operation: a trade can pay and a gift between wallets need not. |
| Refuse a transfer | Yes. | Yes. |
Sources#
- 1Solana docs: Transfer Hook extensionsolana.com/docs/tokens/extensions/transfer-hook
- 2Solana docs: Transfer Hook integrationsolana.com/docs/tokens/extensions/transfer-hook-integration
- 3Solana docs: Transfer Fees extensionsolana.com/docs/tokens/extensions/transfer-fees
- 4Token-2022 program v11.0.0github.com/solana-program/token-2022 · program/src/processor.rs
- 5Orca: Token extensionsdocs.orca.so/developers/architecture/token-extensions
- 6Raydium: Token-2022 supportdocs.raydium.io/reference/token-2022-support
- 7Meteora: DAMM v2 Token-2022 supportdocs.meteora.ag/core-products/damm-v2/token-2022-support
- 8Meteora: DBC transfer hook poolsdocs.meteora.ag/core-products/dbc/transfer-hook-pools