Alphix

Alphix

Uniswap v4 Dynamic Fee Hook - Volume/TVL

Created on 15th May 2025

Alphix

Alphix

Uniswap v4 Dynamic Fee Hook - Volume/TVL

The problem Alphix solves

The website's password is: base-batch-europe-2025

TLDR
Our submission includes a Uniswap v4 Hook (Alphix) and a user-friendly frontend for exploration. Alphix dynamically adjusts fees based solely on Volume and TVL, computed entirely on-chain using a backtested adaptive algorithm. This enhances capital efficiency, consolidates liquidity, and improves LP and Trader experience.
Note: The current Hook implementation remains centralized due to ongoing testing. Please watch the attached Demo Video for an introduction to the frontend.

Deployments
YUSD (ERC-20)
https://sepolia.basescan.org/address/0x663cF82e49419A3Dc88EEc65c2155b4B2D0fA335
BTCRL (ERC-20)
https://sepolia.basescan.org/address/0x13c26fb69d48ED5a72Ce3302FC795082E2427F4D
HOOK V0 https://sepolia.basescan.org/address/0x94ba380a340E020Dc29D7883f01628caBC975000
FAUCET
https://sepolia.basescan.org/address/0x0e99563bC3412bF64B0d0913E0777e8d97ee8756

General Information
The Alphix Hook is a sophisticated smart contract designed to enhance the efficiency of AMMs.
Current dynamic fee explorations overlook the full context of pools and fall short of DeFi's decentralized, trustless standards. Built on Uniswap v4, Alphix leverages existing infrastructure while pushing innovation forward in financial primitives.

Base presents itself as the ideal deployment environment for Alphix. Its reliability, security, low fees, and a rapidly evolving DeFi ecosystem make it the optimal blockchain for testing and scaling innovative smart contract primitives. As active users of Base, we are deeply aligned with its mission to onboard the next generation of DeFi builders and users.

We are two co-founders who combine extensive smart contract development expertise with deep crypto-specific experience in marketing, design, and product research. We started working on Alphix shortly before Base Batch Europe kicked off, after realising the unique opportunity presented by Uniswap v4.

Alphix: The Hook
AMMs are critical infrastructure at the core of the expanding DeFi sector. The future looks bright with over $240 billion in monthly volume being facilitated on-chain, a staggering $19 billion in locked value across pools, and a steadily increasing DEX to CEX ratio. You know that already, of course.

image

The evolution of AMMs - from democratizing yield generation in Uniswap v2, over concentrated liquidity in v3, to the extensive modularity introduced by v4 - has significantly introduced capital efficiency and the ability to innovate. Yet, some improvements came at the cost of Liquidity Provider UX, changing the public image of 'LPing' from a simple yield-generating strategy to a more complex, on-hand experience, and others created persistent issues such as fragmented liquidity and inefficient fee tier selection.

Existing AMM designs use multiple fixed fee tiers, forcing liquidity providers to rebalance between pools to be constantly exposed efficiently. This is evident when looking at the competing TVL count between ETH/USDC pools with different fee tiers on Uniswap. The market's optimal fee level is situated between existing tiers.

Alphix solves this inefficiency with Unified Pools.

image

Unified Pools

Alphix replaces traditional fee tiers with a single dynamic fee determined by an on-chain adaptive algorithm. This combats liquidity fragmentation, reduces LP overhead, and enhances trading conditions under certain market conditions - all while maintaining trustlessness.

At a high level, our algorithm sets fees according to a Volume/TVL ratio:

  • When the Volume/TVL ratio is low, it signals a lack of trading activity relative to liquidity; fees are reduced to attract more volume.
  • When the Volume/TVL ratio is high, it suggests a relative scarcity of liquidity; fees are increased to incentivize LPs.

Alphix recalculates the target ratio dynamically using an Exponential Moving Average (EMA), effectively adapting to user behaviour and broader market shifts.

Timeline - Future Plans
With this submission, we have launched the first experimental Private Alpha. The Private Beta with the tested but unaudited Alphix Hook V1 should be released in Q3 2025 with an accompanied social media push. Once enough data is been gathered showing the resilience of the algorithm, an audit will be contracted using raised funds. Following that is the Public Beta with a seeded TVL of yet undisclosed amount and a subsequent expansion phase.

Note: More information is available through the GitHub repository

Challenges we ran into

1. Dynamic Fee Algorithm

Developing the adaptive fee algorithm at the core of the Alphix Hook posed the first significant challenge. The inherent complexity of simulating stakeholder behaviour in a complex game-theoretical problem can only be achieved by setting assumptions. Using various data sourced through different subgraphs we were able to create initial Response Functions for LPs and Traders (image below) that were sufficiently accurate to start modelling simple simulations.

image
Image Description: (LP Response Function above, Trader Response Function below, both using 6 stable pools)

With these Response Functions, initial simulations were conducted to confirm our hypothesis: Dynamic Fee Pools using a Vol/TVL ratio outperform static fee pools. During this phase, the importance of adding an adaptive target ratio as well as parameters such as max_step and consecutive multipliers to said step was uncovered.

Note: We won't go into the following steps as the work does not apply to the Base Batch, and a paper will be publicly shared upon the Beta release in Q4 2025

2. Smart Contract Design & On-chain Computation

Another challenge was the creation of the actual Alphix v1 Hook (Note: not the one submitted).

To remain fully decentralized and avoid reliance on oracles - which introduce latency and increase attack vectors, Alphix computes necessary metrics directly on-chain.

Volume Tracking - Uniswap V4 does not expose pool-level volume data by default. To solve this, Alphix overrides the _afterSwap hook function and keeps track of the traded amounts using two state variables. This method adds negligible gas costs to traders and avoids storage bloat.

TVL Calculation - Active TVL estimation is more complex due to the absence of native relevant methods for scanning liquidity positions in Uniswap v4. Note that the 'getLiquidity' function does not allow to retrieve the TVL in the pool's tokens. Furthermore, since Uniswap V4 replaces multiple pool-specific contracts with a singleton contract, using contract balances would not work. Based on insights from the Uniswap Discord, this is a known limitation with no public solution yet.

Alphix implements a custom-designed data structure combining bitmaps and linked lists to manage active tick ranges and LP positions. The structure is optimized for:

  • O(1) removal of LP positions
  • O(n) insertion where n is the number of distinct active words (greatly reduced subset of active positions), only incurred for the first LP in a word. Subsequent insertions are O(1)
  • O(m) TVL computation, where m is the number of in-range, active positions

This results in efficient gas usage, memory safety, and accurate TVL readings crucial for the on-chain dynamic fee logic.

Testing - We always put security above all and strictly followed official smart contract testing guidelines. This approach is extremely time-consuming and made it impossible for us to submit the Alphix V1 Hook. We had to settle for a fully centralized, temporary version.

Auditing - The coming up Alphix V1 Hook will have to be audited which has an expensive cost.

3. Web Interface

Neither Carl nor Yanis had any prior experience in working on a complex Frontend/Backend that has to interact with web3, build transactions, read smart contract data and tap into substreams/subgraphs.

A major pain point was understanding the Uniswap v4 logic and how to use the UniversalRouter SDK together with the V4 SDK to successfully build Permit2 allowances and signatures, as well as UniversalRouter execute calls.

We overcame this with the help of the extensive documentation available through Uniswap, YouTube tutorials and by leveraging AI.

Tracks Applied (1)

DeFi

Alphix is a Uniswap v4 Hook that aims to increase capital efficiency while combating liquidity fragmentation and the poo...Read More

Cheer Project

Cheering for a project means supporting a project you like with as little as 0.0025 ETH. Right now, you can Cheer using ETH on Arbitrum, Optimism and Base.

Discussion

Builders also viewed

See more projects on Devfolio