-
Notifications
You must be signed in to change notification settings - Fork 51
Description
Hello OpenZeppelin and Uniswap teams,
I would like to propose the inclusion of a new hook, VolumeBasedFeeHook, into the uniswap-hooks repository. This hook introduces a dynamic fee mechanism that adjusts swap fees based on the transaction volume, offering a tiered fee structure that can incentivize larger trades and provide more sophisticated fee strategies for liquidity providers.
Motivation
Dynamic fees are a cornerstone of Uniswap v4's flexibility. A volume-based fee structure is a common and effective model in both traditional and decentralized finance. Including a canonical implementation in this repository would be highly valuable for the ecosystem.
For Liquidity Providers:
- Attract Larger Trades: By offering lower fees for larger volumes, LPs can attract whales and arbitrageurs, increasing the total volume and fees generated in their pools.
- Increased Competitiveness: Pools with volume-based fees can be more competitive than those with static fees, particularly for high-volume trading pairs.
- Sophisticated Fee Strategies: It provides LPs with more granular control over their fee strategies, moving beyond a single static fee.
For Traders:
- Reduced Costs: Traders executing large orders can benefit from significantly lower fees, improving their execution price.
Functionality
The VolumeBasedFeeHook allows for the configuration of a tiered fee structure for each token in a pool. The fee calculation logic for different swap volumes is as follows:
- Below a minAmount threshold: A defaultFee is applied.
- Between minAmount and a maxAmount threshold: The fee is calculated using linear interpolation between a feeAtMinAmount and a feeAtMaxAmount.
- Above maxAmount: A flat feeAtMaxAmount is applied.
This logic is applied symmetrically for both tokens in the pool and correctly handles both exact input and exact output swaps.
Implementation Details
I have developed an implementation of this hook (VolumeBasedFeeHook.sol):
- Link to my fork of the uniswap-hooks repository
- Link to the VolumeBasedFeeHook contract
- Link to the test suite of the VolumeBasedFeeHook contract
Proposal
I believe the VolumeBasedFeeHook would be an excellent addition to the uniswap-hooks collection. It serves as a practical and powerful tool for developers and LPs building on Uniswap v4 and aligns perfectly with the goal of providing secure, reusable, and community-vetted smart contracts.
I am happy to open a pull request with the implementation for your review if this proposal is of interest.
Thank you for your time and consideration.