Skill body
LBAMM Integration Generator
Generate router/aggregator/frontend contracts that integrate with LBAMM.
Project Setup
Before generating code, check the user’s project is configured:
- Foundry:
foundry.tomlmust exist. If not:forge init - LBAMM Core:
lib/lbamm-core/must exist. If not:forge install limitbreakinc/lbamm-core - Remappings:
remappings.txtneeds@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– seelbamm-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 integration requirements from
$ARGUMENTS -
Resolve ambiguities before generating – if $ARGUMENTS doesn’t specify key addresses (pool IDs, token addresses, router deployment target) or leaves the integration pattern unclear (single swap vs multi-hop, basic vs with handler), ask in a single message. If clear, proceed.
- Determine which LBAMM entry points are needed:
singleSwap– Single-pool swapsmultiSwap– Multi-hop routesdirectSwap– Peer-to-peer swaps (with transfer handlers)createPool– Pool deploymentaddLiquidity/removeLiquidity/collectFees– Liquidity management
- Generate complete integration contract with:
- Proper struct construction (
SwapOrder,BPSFeeWithRecipient,FlatFeeWithRecipient, etc.) - Token approval handling
- Native token (ETH) wrapping if needed
- Transfer handler data encoding if needed
- Hook data encoding if needed
- Proper struct construction (
- Handle key integration details:
- The router becomes the executor – hooks see it as
msg.sender - Token ordering:
token0 < token1always amountSpecified > 0= input swap,< 0= output swapdeadlinemust be in the futurerecipientcannot beaddress(0)
- The router becomes the executor – hooks see it as
- Note: The router is the executor for hook-policy purposes. If a token hook restricts executors, the router must be whitelisted.
Reference Files
references/swap-interface.md– singleSwap, multiSwap, directSwap details and struct constructionreferences/liquidity-interface.md– createPool, addLiquidity, removeLiquidity, collectFeesreferences/integration-patterns.md– Router, aggregator, liquidity manager examples- Protocol knowledge:
lbamm-protocol
Common Mistakes
- Not whitelisting LBAMM as an operator in the Transfer Validator for the token – swaps will revert
- Forgetting that the router contract is the executor – hooks see
msg.sender = router, not the end user - Using
amountSpecified = 0– this is invalid. Positive = input swap, negative = output swap. - Setting fee recipient to
address(0)when fee amount is non-zero – will revert withLBAMM__FeeRecipientCannotBeAddressZero
Dependencies
@limitbreak/lbamm-core/src/interfaces/core/ILimitBreakAMMSwap.sol
@limitbreak/lbamm-core/src/interfaces/core/ILimitBreakAMMLiquidity.sol
@limitbreak/lbamm-core/src/DataTypes.sol
Related Skills
- lbamm-handler-protocol – Transfer handler architecture and custom handler development
- lbamm-permit-handler – Generate PermitTransferHandler integration (gasless swaps via directSwap)
- lbamm-clob – Generate CLOBTransferHandler integration (limit orders via directSwap)
- lbamm-test – Generate Foundry test suites for integration contracts
Skill frontmatter
user-invocable: true
disable-model-invocation: true
argument-hint: [description of integration requirements]