docs: align Infinity hook code examples with CLBaseHook pattern (2026-04-20) — high-risk#80
Open
chef-eric wants to merge 1 commit into
Open
docs: align Infinity hook code examples with CLBaseHook pattern (2026-04-20) — high-risk#80chef-eric wants to merge 1 commit into
chef-eric wants to merge 1 commit into
Conversation
…-04-20) Deep-pass rescan of hook code examples. Inline examples in the doc pages diverged from the snippet files in docs/snippets/ and from CLBaseHook in the infinity-hooks-template repo. Four files updated: 1. Permissions struct field names: `beforeSwapReturnsDelta` (and the three siblings) → `beforeSwapReturnDelta`. The struct members in CLBaseHook are singular; only the bitmap OFFSET constants are plural. Affected: develop-a-hook.mdx, custom-layer-hook.mdx, overwriting-amm-curve.mdx, taking-fee-via-hook.mdx. 2. Hook method override visibility: examples showed `function beforeSwap(...) external override poolManagerOnly` (and likewise for _beforeAddLiquidity, afterRemoveLiquidity). The template pattern has `beforeSwap` as the external wrapper and `_beforeSwap` as the internal virtual that user hooks override. Updated to `function _beforeSwap(...) internal override` to match the canonical snippet files (VeCakeSwapDiscountHook.sol, LiquidityRemovalFeeHook.sol) that the same pages reference as "complete source code". Sources: - infinity-hooks-template/src/pool-cl/CLBaseHook.sol (struct Permissions and external/internal pattern) - infinity-hooks-template/src/pool-cl/CLCounterHook.sol - docs/snippets/VeCakeSwapDiscountHook.sol - docs/snippets/LiquidityRemovalFeeHook.sol Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Documentation Sync — 2026-04-20 (high-risk, needs review)
Force-rescan of Infinity hook code examples with a deeper manual verification pass. Supersedes closed PR #79 (which only caught the struct field names).
Drift found
The inline code examples in several hook pages diverged from two canonical sources in the same doc-site: the snippet files in
docs/snippets/(which the same pages reference as "complete source code") andCLBaseHook.solin theinfinity-hooks-templaterepo.1. Permissions struct field names —
ReturnsDelta→ReturnDeltaThe struct members in
CLBaseHook.Permissionsare singular:beforeSwapReturnDelta,afterSwapReturnDelta,afterAddLiquidityReturnDelta,afterRemoveLiquidityReturnDelta. Only the bitmap OFFSET constants (e.g.HOOKS_BEFORE_SWAP_RETURNS_DELTA_OFFSET) are plural. A developer copying the struct literal from the doc would hit "Member not found" at compile time.Affected:
guides/develop-a-hook.mdxlines 122–125 (VeCakeSwapDiscountHook)overview/custom-layer-hook.mdxlines 36–39 and 75–78guides/hook-examples/overwriting-amm-curve.mdxline 32 (inline code reference)guides/hook-examples/taking-fee-via-hook.mdxline 42 (inline code reference)2. Hook override pattern —
external override poolManagerOnly→internal overrideCLBaseHookexposes the external functions (beforeSwap,_beforeAddLiquidity's wrapper, etc.) and delegates tointernal virtualmethods named with an underscore (_beforeSwap,_beforeAddLiquidity, …). User hooks override the internal methods; the base handles thepoolManagerOnlycheck.The inline examples instead showed
function beforeSwap(...) external override poolManagerOnly/function afterRemoveLiquidity(...) external override poolManagerOnly/function _beforeAddLiquidity(...) external override poolManagerOnly, which doesn't match the snippet files the same pages cite._beforeAddLiquidity externalin particular is a compile error against the base'sinternal virtualdeclaration.Rewrote to:
Affected:
guides/develop-a-hook.mdxlines 58–62 (CLCounterHook example)guides/develop-a-hook.mdxlines 153–165 (VeCakeSwapDiscountHook beforeSwap)guides/hook-examples/taking-fee-via-hook.mdxlines 24–31 (afterRemoveLiquidity)Source verification
CLBaseHook.Permissionsstruct with singular field names: pancakeswap/infinity-hooks-template/src/pool-cl/CLBaseHook.solCLCounterHookuses_beforeAddLiquidity internal override: pancakeswap/infinity-hooks-template/src/pool-cl/CLCounterHook.solVeCakeSwapDiscountHooksnippet uses_beforeSwap internal override:docs/snippets/VeCakeSwapDiscountHook.sol(in this repo, line 61)LiquidityRemovalFeeHooksnippet uses_afterRemoveLiquidity:docs/snippets/LiquidityRemovalFeeHook.sol(line 40)Other things verified (no drift)
custom-layer-hook.mdxforbeforeSwap/afterSwap/afterAddLiquidity/afterRemoveLiquidity(lines 88–92, 125–128, 155–158, 170–173) — all matchICLHooks.sol.LPFeeLibrary.DYNAMIC_FEE_FLAG(0x800000) andOVERRIDE_FEE_FLAG(0x400000) — exist in infinity-core.BeforeSwapDeltaLibrary.ZERO_DELTA— exists.PoolKeystruct fields — matchsrc/types/PoolKey.sol.trade/pancakeswap-infinity/hooks/README.md,hooks/dynamic-fee-hook.md) — prose-only, no code drift.Auto-generated by doc-sync agent. Merge to apply; close to reject; comment to request changes. @cheferic @chef-miso please review.