ClearSwap

Adaptive Uniswap v4 fees powered by an on-chain agent that reacts to market volatility

ClearSwap

Created At

HackMoney 2026

Winner of

ENS

ENS - Integrate ENS

Prize Pool

Project Description

ClearSwap is a protocol-level DeFi primitive built on Uniswap v4 that introduces autonomous, volatility-aware fee adjustment for liquidity pools. Instead of charging a fixed swap fee at all times, ClearSwap uses an on-chain agent (implemented as a Uniswap v4 Hook) to observe real market activity and dynamically update fees per swap.

The hook measures realized price impact (the ratio of token amounts exchanged) and applies an exponential weighted moving average (EWMA) to detect changing market conditions. During calm markets, fees automatically drop to attract traders. During volatile periods, fees increase to better protect liquidity providers from adverse selection and impermanent loss. This happens fully on-chain, without governance, oracles, or off-chain computation.

ClearSwap also integrates ENS to make hook discovery human-readable, allowing protocol operators to reference hook configurations using ENS names instead of hardcoded addresses. The result is a more adaptive, transparent, and resilient fee mechanism that any Uniswap v4 pool can adopt.

How it's Made

ClearSwap is built using Uniswap v4's hook architecture and implemented entirely in Solidity with Foundry. The core component is a custom Uniswap v4 Hook that plugs into the pool lifecycle using beforeSwap and afterSwap callbacks. After each swap, the hook calculates realized price impact (deltaY/deltaX ratio) and updates an exponential weighted moving average (EWMA) stored on-chain. Before the next swap, this EWMA value is mapped to a dynamic fee range and applied using Uniswap v4's per-swap fee override flag.

The system is fully deterministic and runs without governance, price oracles, or external services. All behavior is validated through a comprehensive test suite covering calm markets, volatility shocks, sustained volatility, and recovery phases. Key test demonstrates 2.7x LP revenue increase during high-volatility scenarios compared to static fees.

A lightweight React dashboard built with wagmi and ethers.js visualizes live hook metrics, including current fees and volatility state. ENS integration is used for decentralized, human-readable hook discovery by resolving ENS names and reading text records in a read-only manner. The entire project is open source, deployed on Sepolia with verified contracts, and reproducible with simple Foundry scripts.

background image mobile

Join the mailing list

Get the latest news and updates

ClearSwap | ETHGlobal