v4-security-foundations

v4-security-foundations is a skill for Claude Code from Uniswap/uniswap-ai. It costs 55 tokens per session (4,030 once invoked), scanned A, original, MIT.

A security guide for Uniswap v4 hooks, which are custom code extensions that run during swaps and other pool actions. It covers risks involving callers, user identity, permissions, state, and reentrancy.

In plain words
What is it for?
Use it when building or reviewing v4 hooks, including code that runs before or after swaps and pool initialization.
Why use it?
It helps developers identify ways a hook could be abused to interfere with trades or user funds before writing or auditing code.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: model in frontmatter.

Part of the uniswap-hooks plugin — 2 skills shipped together

not rated 230repo +1 today A scan Socket: passSnyk: warnSkillSpector: warn 55 tokens original MIT

Good fit Use it when building or reviewing v4 hooks, including code that runs before or after swaps and pool initialization.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/uniswap/uniswap-ai/v4-security-foundations
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add Uniswap/uniswap-ai --skill v4-security-foundations
Clone the repo
git clone --depth 1 https://github.com/Uniswap/uniswap-ai

Made for: Claude Code.

Or install uniswap-hooks, the plugin that ships this one along with the rest of its 2 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for v4-security-foundations

README.md
[![agentmods](https://agentmods.dev/badge/skills/uniswap/uniswap-ai/v4-security-foundations/github.svg)](https://agentmods.dev/skills/uniswap/uniswap-ai/v4-security-foundations)
Your own site
<a href="https://agentmods.dev/skills/uniswap/uniswap-ai/v4-security-foundations"><img src="https://agentmods.dev/badge/skills/uniswap/uniswap-ai/v4-security-foundations/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for v4-security-foundations

Your own site · 80×15
<a href="https://agentmods.dev/skills/uniswap/uniswap-ai/v4-security-foundations"><img src="https://agentmods.dev/badge/skills/uniswap/uniswap-ai/v4-security-foundations.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 55 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,030 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • Socket pass 18 Mar 2026
  • Snyk warn 11 Mar 2026
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 1 finding, up to medium

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • medium Excessive Agency · line 5
    Skill selects an external model or provider that may use a different account or billing plan than the operator expects. Undisclosed model switches can cause unexpected cost or quota consumption.
    Fix: Remove the model/provider override or disclose it prominently and require explicit operator approval before invoking an external coding CLI or billed model.
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00055 $0.04030
Opus 5 $0.00028 $0.02015
Sonnet 5 $0.00011 $0.00806
Haiku 4.5 $0.00006 $0.00403

Measured 11d ago against content hash 2d66ed0779a7, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

v4-security-foundations scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 11d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

packages/plugins/uniswap-hooks/skills/v4-security-foundations/SKILL.md · 433 lines

How it starts

The opening of the file, as written. The whole thing — 433 lines — stays where its author put it; the contents beside it link to each section on GitHub.

v4 Hook Security Foundations

Security-first guide for building Uniswap v4 hooks. Hook vulnerabilities can drain user funds—understand these concepts before writing any hook code.

Threat Model

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

Permission Flags Risk Matrix

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

Read the full file on GitHub · 433 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 11d ago First seen · 433 lines · 55 tokens per session scan A 2d66ed0779a7

Subscribe to this mod's changes

v4-security-foundations is a skill published in the GitHub repository Uniswap/uniswap-ai (230 stars, last pushed today), licensed MIT. It adds 55 tokens to every session and 4,030 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.