DynamicFeeHook
BSCDynamicFeeHook is a Uniswap v4 hook on BSC. Live for 3 days. Still in use: 34 trades in the last week, and 1 new pool this week.
- Contract name
- DynamicFeeHook
How this hook works
Smart feesA smart fees hook. It changes its fee with the market.
Fee changes with the market
Instead of a fixed fee, it works out the fee on every trade from how the price is moving. The fee goes to liquidity providers; the hook keeps nothing for itself.
The code that does this (beforeSwap):function _beforeSwap(bytes32 id, bool zeroForOne) internal returns (uint24) { (, int24 tick) = _slot0(id); Oracle storage o = oracles[id]; if (!o.init) { // first swap of the pool: start the average at the current price o.ema = int64(int256(tick) * PRECISION); o.last = uint32(block.timestamp); o.init = true; } Params memory p = _getParams(id); uint32 blk = uint32(block.number); // Remember the price at the start of this block (the first swap we see in the block, pre-trade). if (p.blockSlope != 0 && o.blockStartBlock != blk) { o.blockStartTick = tick; o.blockStartBlock = blk; } Ctx memory c = Ctx({ tick: tick, ema: o.ema, zeroForOne: zeroForOne, firstInBlock: o.lastBlock != blk, startTick: o.blockStartBlock == blk ? o.blockStartTick : tick }); return _fee(id, p, c); }
Who controls it: The hook developer can change: params, venue. The hook developer can also call: clear venue. The code cannot be changed.
Based on the hook’s published code.What do these labels mean?
Safety report
Before you build on it. Automated checks, not an auditsetParamsWhat 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.
Hook history
Settings changes: set the settings (1 time).
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.