configurator
Configure CCA (Continuous Clearing Auction) smart contract parameters through an interactive bulk form flow. Use when user says…
Security-first Uniswap v4 hook development. Use when user mentions "v4 hooks", "hook security", "PoolManager", "beforeSwap", "afterSwap", or asks about V4 hook best practices, vulnerabilities, or audit requirements.
$ npx -y skills add uniswap/uniswap-ai --skill v4-security-foundations --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/v4-security-foundationsContext preview
The summary Claude sees to decide when to auto-load this skill.
Security-first Uniswap v4 hook development. Use when user mentions "v4 hooks", "hook security", "PoolManager", "beforeSwap", "afterSwap", or asks about V4 hook best practices, vulnerabilities, or audit requirements.
name: v4-security-foundations description: Security-first Uniswap v4 hook development. Use when user mentions "v4 hooks", "hook security", "PoolManager", "beforeSwap", "afterSwap", or asks about V4 hook best practices, vulnerabilities, or audit requirements. allowed-tools: Read, Glob, Grep, WebFetch, Task(subagent_type:Explore) model: opus license: MIT metadata: author: uniswap version: '1.1.0'
Security-first guide for building Uniswap v4 hooks. Hook vulnerabilities can drain user funds—understand these concepts before writing any hook code.
Before writing code, understand the v4 security context:
| Threat Area | Description | Mitigation | | ----------------------- | ---------------------------------------------------------- | ---------------------------------------------- | | **Caller Verification** | Only `PoolManager` should invoke hook functions | Verify `msg.sender == address(poolManager)` | | **Sender Identity** | `msg.sender` always equals PoolManager, never the end user | Use `sender` parameter for user identity | | **Router Context** | The `sender` parameter identifies the router, not the user | Implement router allowlisting | | **State Exposure** | Hook state is readable during mid-transaction execution | Avoid storing sensitive data on-chain | | **Reentrancy Surface** | External calls from hooks can enable reentrancy | Use reentrancy guards; minimize external calls |
All 14 hook permissions with associated risk levels:
| Permission Flag | Risk Level | Description | Security Notes | | --------------------------------- | ---------- | --------------------------- | ----------------------------- | | `beforeInitialize` | LOW | Called before pool creation | Validate pool parameters | | `afterInitialize` | LOW | Called after pool creation | Safe for state initialization | | `beforeAddLiquidity` | MEDIUM | Before LP deposits | Can block legitimate LPs | | `afterAddLiquidity` | LOW | After LP deposits | Safe for tracking/rewards | | `beforeRemoveLiquidity` | HIGH | Before LP withdrawals | Can trap user funds | | `afterRemoveLiquidity` | LOW | After LP withdrawals | Safe for tracking | | `beforeSwap` | HIGH | Before swap execution | Can manipulate prices | | `afterSwap` | MEDIUM | After swap execution | Can observe final state | | `beforeDonate` | LOW | Before donations | Access control only | | `afterDonate` | LOW | After donations | Safe for tracking | | `beforeSwapReturnDelta` | CRITICAL | Returns custom swap amounts | **NoOp attack vector** | | `afterSwapReturnDelta` | HIGH | Modifies post-swap amounts | Can extract value | | `afterAddLiquidityReturnDelta` | HIGH | Modifies LP token amounts | Can shortchange LPs | | `afterRemoveLiquidityReturnDelta` | HIGH | Modifies withdrawal amounts | Can steal funds |
The `BEFORE_SWAP_RETURNS_DELTA` permission (bit 10) is the most dangerous hook permission. A malicious hook can:
1. Return a delta claiming it handled the entire swap 2. PoolManager accepts this and settles the trade 3. Hook keeps all input tokens without providing output 4. User loses entire swap amount
// MALICIOUS - DO NOT USE
function beforeSwap(
address,
PoolKey calldata,
IPoolManager.SwapParams calldata params,
bytes calldata
) external override returns (bytes4, BeforeSwapDelta, uint24) {
// Claim to handle the swap but steal tokens
int128 amountSpecified = int128(params.amountSpecified);
BeforeSwapDelta delta = toBeforeSwapDelta(amountSpecified, 0);
return (BaseHook.beforeSwap.selector, delta, 0);
}Before interacting with ANY hook that has `beforeSwapReturnDelta: true`:
1. **Audit the hook code** - Verify legitimate use case 2. **Check ownership** - Is it upgradeable? By whom? 3. **Verify track record** - Has it been audited by reputable firms? 4. **Start small** - Test with minimal amounts first
NoOp patterns are valid for:
But each requires careful implementation and audit.
v4 uses a credit/debit system through the PoolManager:
For every transaction: sum(deltas) == 0
The PoolManager tracks what each address owes or is owed. At transaction end, all debts must be settled.
| Function | Purpose | Direction | | ---------------------------- | ----------------------------------- | ---------------------- | | `take(currency, to, amount)` | Withdraw tokens from PoolManager | You receive tokens | | `settle(currency)` | Pay tokens to PoolManager | You send tokens | | `sync(currency)` | Update PoolManager balance tracking | Preparation for settle |
// Correct pattern: sync before settle poolManager.sync(currency); currency.transfer(address(poolManager),
Uniswap-specific AI tools (skills, plugins, agents) for developers and AI agents integrating the Uniswap ecosystem.
Configure CCA (Continuous Clearing Auction) smart contract parameters through an interactive bulk form flow. Use when user says…
Deploy CCA (Continuous Clearing Auction) smart contracts using the Factory pattern. Use when user says "deploy auction", "deploy…
This skill should be used when the user asks to "provide liquidity", "create LP position", "add liquidity to pool", "become a…
This skill should be used when the user asks to "swap tokens", "trade ETH for USDC", "exchange tokens on Uniswap", "buy tokens",…
Generate Uniswap v4 hook contracts via OpenZeppelin MCP. Use when building custom swap logic, async swaps, hook-owned liquidity,…
Interactively collect and validate the parameters for a Uniswap v4 Permissioned Pool setup - chain, underlying token, allowlist…