Agent Skill · Limit Break
tokenmaster-hook
Generate TokenMaster hook contracts -- buy hooks, sell hooks, spend hooks for advanced order post-execution logic
Skill body
TokenMaster Hook Generator
Generate hook contracts for TokenMaster advanced order post-execution logic.
Project Setup
Before generating code, check the user’s project is configured:
- Foundry:
foundry.tomlmust exist. If not:forge init - TokenMaster:
lib/tm-tokenmaster/must exist. If not:forge install limitbreakinc/tm-tokenmaster - Remappings:
remappings.txtneeds@limitbreak/tm-tokenmaster/=lib/tm-tokenmaster/. Append if missing – do not overwrite existing entries. - Local testing: For local development, use
apptoken-devto bootstrap an Anvil node with all Apptoken protocols at their deterministic addresses – seeapptoken-general/references/project-setup.md.
Instructions
- Parse requirements from $ARGUMENTS
- Resolve ambiguities before generating – if $ARGUMENTS references external contracts (reward tokens, staking contracts, NFT collections) without addresses, ask whether to use existing deployments (get addresses) or generate placeholders. Clarify hook type if multiple could fit. Ask in a single message. If clear, proceed.
- Determine hook type(s): ITokenMasterBuyHook, ITokenMasterSellHook, ITokenMasterSpendHook
- Generate complete hook contract with: interface implementation, caller validation (must be Router), token/identifier validation, custom logic
- Hooks execute AFTER the core transaction completes
- hookExtraData decoding is the hook’s responsibility
Reference Files
references/hook-interfaces.md– ITokenMasterBuyHook, ITokenMasterSellHook, ITokenMasterSpendHook signaturesreferences/hook-patterns.md– Annotated hook implementation examples- Protocol knowledge:
tokenmaster-protocol
Common Mistakes
- Sell hooks are NOT optional for
sellTokensAdvanced– if the order specifiesaddress(0)as hook, the transaction reverts. Always deploy a sell hook contract even if it’s a no-op. - Hooks must validate
msg.sender == TOKENMASTER_ROUTER– anyone can call the hook function directly otherwise. - Hooks must validate the
tokenMasterTokenparameter matches the expected token – a single hook contract may serve multiple tokens, and without validation an attacker could invoke it with a different token.
When to Use This vs Other Skills
- This skill (tokenmaster-hook): Generate hook contracts that execute post-transaction logic for advanced orders. Use when you need custom behavior after buys, sells, or spends (e.g., reward distribution, staking, item delivery).
- tokenmaster-integrator: Generate transaction code that calls the Router. Use when building the frontend/backend that submits buy/sell/spend transactions.
- tokenmaster-deployer: Generate deployment scripts. Use before hooks – you need a deployed token first.
Related Skills
- tokenmaster-integrator – Generate transaction code that invokes hooks via advanced orders
- tokenmaster-deployer – Generate deployment scripts (hooks are configured post-deployment)
Skill frontmatter
user-invocable: true
disable-model-invocation: true
argument-hint: [description of hook requirements - what should happen after buy/sell/spend]