project screenshot 1
project screenshot 2
project screenshot 3

V4 Hook Fuzzer

The goal of our project is to create a framework to make it easier for UniswapV4 hook developers to test their hooks using stateful fuzz tests. The framework builds upon the fuzz testing capabilities of Woke , a Python package for testing Solidity smart contracts.

V4 Hook Fuzzer

Created At

ETHGlobal New York

Project Description

The project implements a framework for property based stateful fuzz testing of V4 hooks contracts. The developer implements details specific to the hook, such as invariants that should always hold and implements methods for public entry points that interact with the hook. Once these functions are defined, the fuzz testing engine can test the system over thousands of transactions and blocks, calling all available methods in randomized order, attempting to find edge cases where the hook invariants are violated.

How it's Made

This project builds upon the Woke Python based testing framework for Solidity smart contracts to create a framework for testing V4 hooks.

There is a class called V4Test that provides common functionality that will be useful for most hook developers.

Deploy a pool manager

Deploy test tokens

Deploy a swap router

Randomized Swaps

Randomized Pool Initialization

To test a hook, the user inherits from this class and implements functionality specific to that hook.

Deploy the hook inside _hook_deploy

Return the deployed hook inside get_hook_impl

Implement "flows", which are calls into the public interface of the hook. Full range has two methods on it's interface that need to be implemented addLiquidity and removeLiquidity

Define invariants that will be validated after each flow is called

Once this interface is implemented, the Woke fuzz testing engine will run a stateful fuzz test that will call the implemented flows on the hook and the common flows (swap, initialize pool) in a randomized order, with randomized inputs.

background image mobile

Join the mailing list

Get the latest news and updates