LBAMM Pool Hook Generator
Generate a complete ILimitBreakAMMPoolHook implementation based on the user's requirements.
Project Setup
Before generating code, check the user's project is configured:
- Foundry:
foundry.toml must exist. If not: forge init
- LBAMM Core:
lib/lbamm-core/ must exist. If not: forge install limitbreakinc/lbamm-core
- Remappings:
remappings.txt needs @limitbreak/lbamm-core/=lib/lbamm-core/. Append if missing -- do not overwrite existing entries.
- Local testing: LBAMM is in audit and not yet on public networks. For local testing, use
lbamm-examples -- see lbamm-protocol/references/local-dev.md. Generated scripts should read addresses from environment variables (vm.envAddress) so they work with the local Anvil deployment.
Instructions
Parse requirements from $ARGUMENTS -- identify the pool hook behavior (dynamic fees, pool creation gating, LP access control, oracle pricing for single provider pools, etc.)
Resolve ambiguities before generating -- if $ARGUMENTS mentions external contracts without addresses (e.g., "a price oracle", "a registry", "a token"), ask the user whether they have an existing contract (and get the address) or want a new one generated. Similarly, clarify pool type (Dynamic vs Single Provider) if not obvious, or specific configuration values that would change the implementation. Ask everything in a single message. If clear, proceed.
Determine capabilities needed:
- Dynamic fee calculation via
getPoolFeeForSwap() (pool must be created with fee = 55_555)
- Pool creation validation via
validatePoolCreation()
- Liquidity operation validation via
validatePoolAddLiquidity(), validatePoolRemoveLiquidity(), validatePoolCollectFees()
- If targeting Single Provider pools: implement
ISingleProviderPoolHook extension with getPoolPriceForSwap() and getPoolLiquidityProvider()
Generate a complete Solidity contract that:
- Uses
pragma solidity 0.8.24;
- Implements
ILimitBreakAMMPoolHook (or ISingleProviderPoolHook if targeting single provider pools)
- Implements
poolHookManifestUri()
- Includes appropriate state management and access control
Note fee bounds:
poolFeeBPS <= 10_000 for input-based swaps
poolFeeBPS < 10_000 (strictly less) for output-based swaps
- Hook fees on liquidity ops are capped by caller's
maxHookFee0/maxHookFee1
Reference Files
references/pool-hook-interface.md -- Full interface, ISingleProviderPoolHook extension, dynamic fee sentinel
references/pool-hook-patterns.md -- Dynamic fee hook, access-controlled pool, oracle pricing hook examples
- Protocol knowledge:
lbamm-protocol
When to Use This vs Other Hook Skills
- This skill (lbamm-pool-hook): Per-pool hooks set at pool creation. Use for dynamic fees (
55_555 sentinel), LP access control, or oracle pricing. Required for Single Provider pools (must implement ISingleProviderPoolHook).
- lbamm-token-hook: Per-token hooks set globally. Use when behavior should apply to ALL pools involving a token (swap gating, fee collection, flashloan control).
- lbamm-standard-hook: Configure the pre-deployed first-party hook. Use when built-in settings are sufficient.
Dependencies
@limitbreak/lbamm-core/src/interfaces/hooks/ILimitBreakAMMPoolHook.sol
lbamm-pool-type-single-provider/src/interfaces/ISingleProviderPoolHook.sol
@limitbreak/lbamm-core/src/DataTypes.sol
1---2name: lbamm-pool-hook3description: Generate complete ILimitBreakAMMPoolHook Solidity implementations4---56# LBAMM Pool Hook Generator78Generate a complete `ILimitBreakAMMPoolHook` implementation based on the user's requirements.910## Project Setup1112Before generating code, check the user's project is configured:131. **Foundry**: `foundry.toml` must exist. If not: `forge init`142. **LBAMM Core**: `lib/lbamm-core/` must exist. If not: `forge install limitbreakinc/lbamm-core`153. **Remappings**: `remappings.txt` needs `@limitbreak/lbamm-core/=lib/lbamm-core/`. Append if missing -- do not overwrite existing entries.164. **Local testing**: LBAMM is in audit and not yet on public networks. For local testing, use `lbamm-examples` -- see `lbamm-protocol/references/local-dev.md`. Generated scripts should read addresses from environment variables (`vm.envAddress`) so they work with the local Anvil deployment.1718## Instructions19201. **Parse requirements** from `$ARGUMENTS` -- identify the pool hook behavior (dynamic fees, pool creation gating, LP access control, oracle pricing for single provider pools, etc.)21222. **Resolve ambiguities before generating** -- if $ARGUMENTS mentions external contracts without addresses (e.g., "a price oracle", "a registry", "a token"), ask the user whether they have an existing contract (and get the address) or want a new one generated. Similarly, clarify pool type (Dynamic vs Single Provider) if not obvious, or specific configuration values that would change the implementation. Ask everything in a single message. If clear, proceed.23243. **Determine capabilities needed:**25 - Dynamic fee calculation via `getPoolFeeForSwap()` (pool must be created with fee = `55_555`)26 - Pool creation validation via `validatePoolCreation()`27 - Liquidity operation validation via `validatePoolAddLiquidity()`, `validatePoolRemoveLiquidity()`, `validatePoolCollectFees()`28 - If targeting Single Provider pools: implement `ISingleProviderPoolHook` extension with `getPoolPriceForSwap()` and `getPoolLiquidityProvider()`29304. **Generate a complete Solidity contract** that:31 - Uses `pragma solidity 0.8.24;`32 - Implements `ILimitBreakAMMPoolHook` (or `ISingleProviderPoolHook` if targeting single provider pools)33 - Implements `poolHookManifestUri()`34 - Includes appropriate state management and access control35365. **Note fee bounds:**37 - `poolFeeBPS <= 10_000` for input-based swaps38 - `poolFeeBPS < 10_000` (strictly less) for output-based swaps39 - Hook fees on liquidity ops are capped by caller's `maxHookFee0`/`maxHookFee1`4041## Reference Files4243- `references/pool-hook-interface.md` -- Full interface, `ISingleProviderPoolHook` extension, dynamic fee sentinel44- `references/pool-hook-patterns.md` -- Dynamic fee hook, access-controlled pool, oracle pricing hook examples45- Protocol knowledge: `lbamm-protocol`4647## When to Use This vs Other Hook Skills4849- **This skill (lbamm-pool-hook)**: Per-pool hooks set at pool creation. Use for dynamic fees (`55_555` sentinel), LP access control, or oracle pricing. **Required** for Single Provider pools (must implement `ISingleProviderPoolHook`).50- **lbamm-token-hook**: Per-token hooks set globally. Use when behavior should apply to ALL pools involving a token (swap gating, fee collection, flashloan control).51- **lbamm-standard-hook**: Configure the pre-deployed first-party hook. Use when built-in settings are sufficient.5253## Dependencies5455```56@limitbreak/lbamm-core/src/interfaces/hooks/ILimitBreakAMMPoolHook.sol57lbamm-pool-type-single-provider/src/interfaces/ISingleProviderPoolHook.sol58@limitbreak/lbamm-core/src/DataTypes.sol59```