v4-hook-permission-flags-mismatch
Detect Uniswap V4 hooks whose address-encoded permission flags don't match the callbacks the hook actually implements. In V4 the hook's permissions live in…
от iktok90-design★ 31 звезда на GitHub
Установить v4-hook-permission-flags-mismatch в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Uniswap V4 hook permission-flag mismatch detection
When this applies
Trigger on any of:
- Contracts inheriting
BaseHook/ implementingIHooks - An overridden
getHookPermissions()returning aHooks.Permissionsstruct - Implemented callbacks:
beforeSwap,afterSwap,beforeAddLiquidity,afterAddLiquidity,beforeRemoveLiquidity,afterRemoveLiquidity,beforeInitialize,afterInitialize,beforeDonate,afterDonate *ReturnDeltapermission flags (afterSwapReturnDelta,beforeSwapReturnDelta, etc.)- CREATE2 /
HookMiner.findsalt mining to encode flags into the hook address - Pool initialization that passes the hook address to
PoolManager.initialize
Detection patterns
Implemented callback whose flag bit is unset (HIGH)
function getHookPermissions() public pure override returns (Hooks.Permissions memory) {
return Hooks.Permissions({ beforeSwap: true, afterSwap: false, /* ...all else false */ });
}
function afterSwap(...) external override returns (bytes4, int128) {
_accrueFees(...); // ← real logic, but afterSwap flag is FALSE
return (this.afterSwap.selector, 0);
}
The pool reads permissions from the hook address bits, not from the function table. With the AFTER_SWAP bit unset, the PoolManager never calls afterSwap; _accrueFees silently never runs.
Signal: a callback is implemented (non-reverting body) but its corresponding permission is false / the address bit is unmined.
Flag set without implementation → init reverts (HIGH)
return Hooks.Permissions({ beforeAddLiquidity: true, /* ... */ });
// but beforeAddLiquidity is NOT overridden → BaseHook reverts HookNotImplemented
Hooks.validateHookPermissions checks that each set address bit corresponds to an implemented callback; a set flag with no override makes PoolManager.initialize revert, bricking the pool.
Signal: permission true (or address bit set) with no matching overridden function, or the default BaseHook stub left in place (reverts HookNotImplemented).
returnDelta flag mismatch (HIGH)
beforeSwapReturnDelta: false // but beforeSwap returns a non-zero BeforeSwapDelta
If beforeSwap returns a non-zero delta while BEFORE_SWAP_RETURNS_DELTA is unset, the manager ignores the delta (or reverts), stranding the accounting the hook tried to apply.
Signal: a callback returns a non-zero BeforeSwapDelta/int128 while its *ReturnDelta permission is false.
Address bits ≠ getHookPermissions (HIGH)
address hook = address(uint160(0x...0040)); // only BEFORE_SWAP bit
// getHookPermissions() also claims afterSwap → mismatch at validateHookPermissions
Signal: the mined deployment address low bits don't equal the getHookPermissions() struct.
Severity rubric
| Pattern | Severity | Notes |
|---|---|---|
| Implemented callback with unset flag → silently skipped | High | Fees/limits/guards never run |
| Flag set, no implementation → init reverts | High | Pool un-initializable (DoS) |
| returnDelta flag mismatch → delta ignored | High | Stranded accounting, see v4-hook-delta-accounting |
| Address bits disagree with getHookPermissions | High | Deterministic init revert |
| Cosmetic flag set but callback is a true no-op | Low | Wasted gas only |
Remediation patterns
- Single source of truth — derive the deploy salt from
getHookPermissions()(e.g.HookMiner.findwith the exact flag set) so address bits and the struct can't drift. - Assert at construction —
Hooks.validateHookPermissions(this, getHookPermissions())in the constructor to fail fast on a wrong address. - Implement exactly the flagged callbacks — every
truehas an override; every override has atrue. Remove dead callbacks or set their flag. - Set the matching
*ReturnDeltaflag whenever a callback can return a non-zero delta. - Test against the real PoolManager init path, not a mock that skips validation.
False-positive notes
- A callback present only to satisfy an interface but truly returning zero/no-op with its flag intentionally unset is fine — Info, confirm no side effects.
- Hooks deployed via the official
HookMinerwith asserted permissions are consistent by construction.
Related
- v4-hook-delta-accounting — returnDelta flags pair with settlement
- access-control
- initialization
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл v4-hook-permission-flags-mismatch?
Detect Uniswap V4 hooks whose address-encoded permission flags don't match the callbacks the hook actually implements. In V4 the hook's permissions live in the low bits of its deployed address (mined via CREATE2 salt) and must agree with getHookPermissions(); a callback the hook implements but whose flag bit is unset is never invoked, and a flag set without a real implementation makes pool initialization revert in Hooks.validateHookPermissions. Activate on any BaseHook/IHooks contract, getHookPermissions overrides, or hook address mining.
Как установить скилл v4-hook-permission-flags-mismatch?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл v4-hook-permission-flags-mismatch запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
AnthropicToolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
access
AnthropicManage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
configure
AnthropicSet up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
access
AnthropicManage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…