project screenshot 1
project screenshot 2
project screenshot 3
project screenshot 4
project screenshot 5

Hook up to AMM

Using Uniswap v4 Hooks to incentivize long-term liquidity with time-based rewards.

Hook up to AMM

Created At

ETHGlobal Taipei

Winner of

Uniswap Foundation

Uniswap Foundation - Uniswap v4 Hook Integrations Runner Up

Project Description

In the current Uniswap ecosystem, traders are required to pay a 0.3% transaction fee, which is distributed to liquidity providers (LPs) as an incentive for their participation. However, this incentive structure is solely based on the proportion of liquidity provided at the time of each swap, which leads to a significant shortcoming. Specifically, it encourages opportunistic behavior, where some LPs enter the pool only during periods of high trading volume to maximize short-term returns. When trading activity declines, these LPs tend to withdraw their funds immediately.

This pattern of behavior can undermine the stability and reliability of the liquidity pool, ultimately harming the health and sustainability of the ecosystem. More critically, it creates a disincentive for those loyal LPs who are committed to providing long-term support, as their efforts are not adequately rewarded under the current mechanism.

To address this issue, our project proposes a new incentive model that not only considers the share of liquidity provided but also takes into account the duration of time that liquidity remains staked. By incorporating with a time-based bonus, we aim to promote long-term participation and foster a more resilient and balanced liquidity environment within the decentralized exchange.

How it's Made

The foundation of our project lies in the implementation of a carefully designed hook contract, which plays a central role in achieving our goal of incentivizing long-term liquidity provision. This contract introduces new logic into the lifecycle of swaps and liquidity events, extending the traditional functionality of decentralized exchanges.

The hook contract delivers two key functionalities:

Swap-Time Bonus Collection (beforeSwap Hook) Whenever a trader initiates a swap, the beforeSwap hook is triggered. At this stage, an additional time-based bonus fee—calculated as a configured percentage x% of the transaction amount—is charged and stored within the hook contract. Simultaneously, the conventional transaction fee y% is applied and distributed directly to the liquidity providers (LPs) in proportion to their share of the pool. This dual-fee structure ensures backward compatibility while enabling future reward distribution based on stake duration.

Liquidity Provision Tracking (afterAddLiquidity and afterRemoveLiquidity Hooks) When an LP adds liquidity to the pool, the afterAddLiquidity hook is invoked. The contract records the timestamp and the amount of liquidity provided. Upon withdrawal, the afterRemoveLiquidity hook captures the exit time and calculates the duration and amount of the stake. Based on these variables, a formula—represented as a + b + c = d%—is used to compute the LP’s eligibility for the time-based bonus fee. This reward is then paid out from the fees accumulated in the beforeSwap phase.

This system effectively rewards LPs who commit their capital for longer periods, discouraging short-term, opportunistic behaviors that are currently prevalent. The end result is a healthier and more stable liquidity environment, benefiting both the ecosystem and its long-term participants.

Technical Highlights and Tools:

Core Mechanism: Custom Uniswap V4 hook that rewards long-term liquidity providers while maintaining compatibility with existing DEX architecture. Fee Structure:

Standard swap fees distributed normally to LPs Additional bonus fees collected and stored in the hook contract

Hooks Utilized:

beforeSwap: Triggered during swaps to calculate and collect the additional bonus fee afterAddLiquidity: Records timestamp and deposit amount when LP adds liquidity afterRemoveLiquidity: Captures exit time and calculates rewards based on duration and amount

Tracking System:

Records timestamp and amount when liquidity is added Calculates duration and amount when liquidity is removed or adjusted In other words, between the recorded timestamp and the next update, the liquidity amount provided by that LP is considered constant.

Reward Distribution:

Uses time-weighted approach to calculate each LP's share Rewards proportional to amount and duration of liquidity provision Discourages short-term deposit-withdraw cycles

Implementation Details:

Tracks individual LP positions and timestamps Maintains global variables (total liquidity, timestamps, accumulated shares) Calculates and rewards the LP's position changes, (including afterAddLiquidity and afterRemoveLiquidity) Tested with Foundry and Solidity simulations

background image mobile

Join the mailing list

Get the latest news and updates