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.gitSecurely 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.
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
IronCalc is a spreadsheet engine and ecosystem
Customer feedback management made simple
Enterprise workflow automation and service management platform
Automate your spreadsheet tasks with AI power