TokenFeeHook
EthereumTokenFeeHook is a Uniswap v4 hook on Ethereum. Runs code on every swap. Sets its own swap fee. Gates who can add liquidity.
- Contract name
- TokenFeeHook
How this hook works
Dynamic feeA dynamic fee hook. It sets its own trading fee and controls who adds or removes liquidity.
Sets its own trading fee
Instead of a fixed fee chosen by the pool creator, it decides the fee itself on each trade.
The code that does this (beforeSwap):function _beforeSwap(address, PoolKey calldata key, SwapParams calldata params, bytes calldata) internal view override returns (bytes4, BeforeSwapDelta, uint24) { uint24 fee = feeFor(key, params.zeroForOne); return ( BaseHook.beforeSwap.selector, BeforeSwapDeltaLibrary.ZERO_DELTA, fee | LPFeeLibrary.OVERRIDE_FEE_FLAG ); }Rules for adding or removing liquidity
It decides who can add or remove liquidity, or when.
The code that does this (beforeAddLiquidity):function _beforeAddLiquidity(address sender, PoolKey calldata, ModifyLiquidityParams calldata, bytes calldata) internal view override returns (bytes4) { require(sender == factory, "only factory"); return BaseHook.beforeAddLiquidity.selector; }
Who controls it: No admin functions: nobody can change its rules after deployment.
Based on the hook’s published code.
Hook history
- Fees set 1 time
Latest transactions
- 0xc2ccf512…9d109d block 26,376,881 · 1.00e-16 USAT
Counted from what the hook recorded on-chain across all its pools, for every action in its published code, plus token transfers in and out of it.
What it can do
Its code executes inside each trade in pools that use it.
Pools using it let the hook choose the swap fee instead of a fixed tier.
It checks every deposit before it goes in.