Skip to content

V4 fee adapter#122

Draft
ccashwell wants to merge 4 commits intomainfrom
v4-fee-adapter
Draft

V4 fee adapter#122
ccashwell wants to merge 4 commits intomainfrom
v4-fee-adapter

Conversation

@ccashwell
Copy link
Member

This PR introduces tiered protocol fee support for Uniswap V4, enabling governance to collect protocol fees from V4 pools with a waterfall resolution pattern matching the V3 fee structure established in the UNIfication proposal.

Summary

  • V4FeeAdapter contract implementing tiered protocol fees with waterfall resolution: pool override → fee tier → default
  • Governance proposal script to activate V4 fees and set the adapter as protocol fee controller
  • Deployer contracts for Mainnet and Unichain
  • Comprehensive unit and fork tests with exact fee validation

Changes

New Contracts

  • src/feeAdapters/V4FeeAdapter.sol - Tiered fee controller with waterfall resolution
  • src/interfaces/IV4FeeAdapter.sol - Interface with comprehensive NatSpec

Scripts

  • script/05_V4FeeSwitchProposal.s.sol - Governance proposal to activate fees
  • script/06_DeployV4Mainnet.s.sol - Mainnet deployment script
  • script/07_DeployV4Unichain.s.sol - Unichain deployment script
  • script/deployers/V4MainnetDeployer.sol - Mainnet deployer contract
  • script/deployers/V4UnichainDeployer.sol - Unichain deployer contract

Tests

  • test/V4FeeAdapter.t.sol - unit tests covering all V4 fee adapter functionality
  • test/V4ProtocolFees.fork.t.sol - fork tests validating against real V4 pool interactions

Technical Notes

  • protocol fee values are packed (lower 12 bits for zeroForOne, upper 12 bits for oneForZero swaps)
  • The adapter stores single-direction fees and packs them symmetrically when queried
  • Uses uint24.max as sentinel for "explicitly zero fee" (distinct from "not set")
  • Fork tests validate exact fee collection with 1 wei tolerance for V4's internal rounding

@ccashwell ccashwell marked this pull request as draft February 6, 2026 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant