v4-security-foundations

Guide secure Uniswap v4 hook development with threat models and mitigation strategies.

2|2|Updated Dec 5, 2025
One-click install
npx skills add https://github.com/Mental-Wealth-Academy/platform --skill v4-security-foundations-mental-wealth-academy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: v4-security-foundations
Source: https://github.com/Mental-Wealth-Academy/platform/tree/main/.agents/skills/v4-security-foundations
Command: npx skills add https://github.com/Mental-Wealth-Academy/platform --skill v4-security-foundations-mental-wealth-academy

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides comprehensive guidance and best practices for developing secure Uniswap v4 hooks, mitigating risks of fund loss and exploits.

Core Features & Use Cases

  • Threat Modeling: Understand potential attack vectors specific to v4 hooks.
  • Permission Risk Analysis: Detailed breakdown of hook permission risks and mitigation strategies.
  • Vulnerability Patterns: Examples and solutions for common security pitfalls like NoOp attacks, reentrancy, and delta accounting errors.
  • Use Case: A developer building a custom v4 hook can use this Skill to understand the security implications of enabling beforeSwapReturnDelta and how to implement it safely, or to ensure their hook correctly verifies msg.sender against the PoolManager.

Quick Start

Review the "Permission Flags Risk Matrix" to understand the security implications of each v4 hook permission.

Frequently Asked Questions about v4-security-foundations

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I secure Uniswap v4 hooks against reentrancy and NoOp attacks?

To secure Uniswap v4 hooks against reentrancy and NoOp attacks, implement strict access control by verifying msg.sender against the PoolManager and adhere to delta accounting fundamentals to prevent state manipulation.

What are the security risks of enabling beforeSwapReturnDelta in Uniswap v4 hooks?

Enabling beforeSwapReturnDelta in Uniswap v4 hooks introduces specific permission flag risks related to token handling hazards and delta accounting errors. Review the Permission Flags Risk Matrix to understand and implement mitigation strategies for these vulnerabilities.

How do I implement access control patterns for Uniswap v4 hook development?

Implement access control for Uniswap v4 hook development by verifying msg.sender against the PoolManager address to prevent unauthorized contract calls and mitigate token handling hazards.

What is delta accounting in Uniswap v4 and how does it affect smart contract security?

Delta accounting in Uniswap v4 is a balance tracking mechanism that affects smart contract security by requiring precise settling of token amounts. Errors in delta accounting can lead to fund loss, requiring strict adherence to gas budget guidelines and mitigation strategies.

When do I need to audit Uniswap v4 hooks for vulnerability mitigation?

You need to audit Uniswap v4 hooks for vulnerability mitigation whenever enabling hook permission flags or implementing custom swap logic. Auditing identifies threat models, NoOp attack vectors, and reentrancy risks before deployment.

Does this security guide cover gas budget guidelines for v4 hook implementation?

Yes, this security guide covers gas budget guidelines for v4 hook implementation. It details how to manage gas consumption safely alongside delta accounting fundamentals and access control patterns to prevent out-of-gas exploits.