Securely develop Uniswap V4 hooks with AI assistance. Benefits developers by embedding security best practices, vulnerability patterns, and battle-tested code patterns. Integrates with Claude Code for automated, secure smart contract development.
git clone https://github.com/igoryuzo/uniswapV4-hooks-skill.gitThis skill integrates security expertise directly into Claude Code for Uniswap V4 hook development. It activates automatically when you mention V4 hooks or work with hook contracts, providing threat modeling guidance, warnings about dangerous patterns like NoOp rug pulls, and secure code templates based on 20+ pages of documentation including official Uniswap security frameworks and real audit reports. The skill covers access control, delta accounting, reentrancy protection, and known vulnerability patterns from Certora and ABDK audits. Developers benefit from pre-deployment checklists and risk assessment frameworks that help catch security issues before they reach production, reducing the risk of exploits that could drain user funds.
Install via `npx skills add https://github.com/igoryuzo/uniswapV4-hooks-skill`. The skill activates automatically when you mention Uniswap, V4, hooks, or PoolManager, or when working with hook contract files. You can also explicitly invoke it with prompts like 'Using the uniswap-v4-hooks skill, create a limit order hook.'
Create dynamic fee hooks with security best practices embedded
Review existing hook code for security vulnerabilities and attack vectors
Implement permission-controlled hooks with proper PoolManager verification
Build reward or points system hooks with reentrancy protection
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/igoryuzo/uniswapV4-hooks-skillCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
I'm developing a Uniswap V4 hook for [COMPANY], a [INDUSTRY] company. The hook should [DESCRIBE HOOK PURPOSE]. Generate secure Solidity code with comments explaining security best practices and potential vulnerabilities to avoid. Include test cases and integration guidance for Uniswap V4.
# Uniswap V4 Hook: Dynamic Fee Adjustment
## Solidity Implementation
```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {IHooks} from "@uniswap/v4-core/contracts/interfaces/IHooks.sol";
contract DynamicFeeHook is IHooks {
// Security: Use immutable variables for critical parameters
uint256 public constant MAX_FEE = 500;
uint256 public constant MIN_FEE = 100;
// Security: Use mapping to track fee adjustments
mapping(address => uint256) public lastFeeAdjustmentTime;
// Security: Use modifier to prevent reentrancy
modifier nonReentrant() {
require(lastFeeAdjustmentTime[msg.sender] == 0 || block.timestamp > lastFeeAdjustmentTime[msg.sender], "Fee adjustment too frequent");
_;
}
function onSwap(address sender, bool swappingForTokenX, uint256 amount0, uint256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int256 tick)
external
returns (uint160 newSqrtPriceX96, uint128 newLiquidity, int256 newTick)
{
// Security: Validate inputs
require(amount0 > 0 || amount1 > 0, "Invalid swap amount");
require(sqrtPriceX96 > 0, "Invalid price");
// Dynamic fee adjustment logic
uint256 currentFee = getCurrentFee();
newSqrtPriceX96 = adjustPriceForFee(sqrtPriceX96, currentFee);
newLiquidity = liquidity;
newTick = tick;
}
function getCurrentFee() internal view returns (uint256) {
// Security: Use safe math for calculations
return (MAX_FEE + MIN_FEE) / 2;
}
}
```
## Security Considerations
- **Reentrancy Protection**: The `nonReentrant` modifier prevents reentrancy attacks.
- **Input Validation**: All inputs are validated to prevent invalid operations.
- **Immutable Parameters**: Critical parameters are marked as immutable.
## Test Cases
```solidity
function testDynamicFeeHook() public {
address deployer = address(this);
DynamicFeeHook hook = new DynamicFeeHook();
// Test 1: Basic swap with dynamic fee
uint256 amount0 = 1000000;
uint256 amount1 = 500000;
uint160 sqrtPriceX96 = 1.157787806845480041e+15;
uint128 liquidity = 1000000;
int256 tick = 0;
(uint160 newSqrtPriceX96, uint128 newLiquidity, int256 newTick) = hook.onSwap(
deployer, true, amount0, amount1, sqrtPriceX96, liquidity, tick
);
assertEq(newSqrtPriceX96, 1.157787806845480041e+15); // Verify price adjustment
assertEq(newLiquidity, 1000000); // Verify liquidity remains unchanged
assertEq(newTick, 0); // Verify tick remains unchanged
}
```Agents that listen, think and act for you.
AI assistant built for thoughtful, nuanced conversation
Get more done every day with Microsoft Teams – powered by AI
Automate your spreadsheet tasks with AI power
Agentic AI Workflow platform
Connected workspace for docs, wikis, and projects
Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan