Uniswap v4 Template
Foundry-based starter template for building, testing, and deploying Uniswap v4 hooks, maintained by the Uniswap Foundation.
The Uniswap v4 Template is a Foundry starter kit for hook development, maintained by the Uniswap Foundation. It comes pre-wired with v4 dependencies, an example hook, ready-to-run tests, and deploy scripts so you can focus on hook logic instead of project setup.
This template is maintained by the Uniswap Foundation. It is provided as is, so review and adapt it to your use case before deploying to production.
What's included
- Example hook.
Counter.soldemonstratesbeforeSwap()andafterSwap()so you can see how hooks intercept swap behavior. - Test framework.
Counter.t.solis preconfigured with the v4 pool manager, test tokens, and seeded liquidity, eliminating setup boilerplate. - Deploy scripts. Scripts in
script/cover deploying hooks (withHookMinerfor CREATE2 salt mining), creating pools, managing liquidity, and executing swaps on local Anvil and production networks. - Foundry config. Stable-branch dependency management via git submodules with sensible remappings.
Quick start
Click Use this template on GitHub to scaffold a new repository, then:
git clone https://github.com/<your-org>/<your-repo>.git
cd <your-repo>
forge install
forge testPull upstream improvements at any time with a git merge from uniswapfoundation/v4-template.
This template is provided as is, without warranties of any kind. Any hook, pool integration, or deploy script built or deployed using this template is the sole responsibility of the developer. Conduct an independent security review and audit before deploying to mainnet. Refer to the Uniswap v4 security guide for additional guidance.