RoutingDynamicFeeHook
RobinhoodHookRoutingDynamicFeeHook is a Uniswap v4 hook on Robinhood Chain. Brand new: its first pool went live today. Still in use: 34 trades in the last week, and 1 new pool this week.
- Contract name
- RoutingDynamicFeeHook
How this hook works
Smart feesA smart fees hook. It changes its fee with the market, keeps a price record and controls who adds liquidity.
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(address, PoolKey calldata key, SwapParams calldata, bytes calldata) external view onlyPoolManager returns (bytes4, BeforeSwapDelta, uint24) { uint24 fee = quoteFee(key.toId()).lpFeePips; return (IHooks.beforeSwap.selector, BeforeSwapDeltaLibrary.ZERO_DELTA, fee | LPFeeLibrary.OVERRIDE_FEE_FLAG); }Keeps a price record
It records the pool’s price over time, so other apps can read a fair average price.
The code that does this (afterSwap):function afterSwap(address, PoolKey calldata key, SwapParams calldata, BalanceDelta delta, bytes calldata) external onlyPoolManager returns (bytes4, int128) { if (delta.amount0() != 0 && delta.amount1() != 0) { PoolId poolId = key.toId(); PoolState storage pool = _configuredPool(poolId); (uint160 sqrtPriceX96,,,) = POOL_MANAGER.getSlot0(poolId); uint32 bucketSeconds = pool.config.bucketSeconds; uint256 bucket = block.timestamp / bucketSeconds; uint8 cursor = pool.cursor; uint8 count = pool.count; if (count == 0) { pool.count = 1; } else if (pool.observations[cursor].timestamp / bucketSeconds != bucket) { cursor = (cursor + 1) % OBSERVATION_CAPACITY; pool.cursor = cursor; if (count < OBSERVATION_CAPACITY) pool.count = count + 1; } // The fixed X96 and WAD factors cancel in differences between logs. int128 logPriceWad = (2 * wadLn(int256(uint256(sqrtPriceX96)))).toInt128(); pool.observations[cursor] = Observation({timestamp: uint64(block.timestamp), logPriceWad: logPriceWad}); } return (IHooks.afterSwap.selector, 0); }Rules for adding liquidity
It decides who can add liquidity, or when.
The code that does this (beforeAddLiquidity):function beforeAddLiquidity( address sender, PoolKey calldata key, ModifyLiquidityParams calldata params, bytes calldata ) external view onlyPoolManager returns (bytes4) { PoolId poolId = key.toId(); PoolState storage pool = _configuredPool(poolId); address provider = sender; if (sender == address(POSITION_MANAGER)) { address operator = POSITION_MANAGER.msgSender(); if (!pool.liquidityProviders[operator]) revert LiquidityProviderNotAllowed(poolId, operator); // The PositionManager uses the minted NFT's token ID as the pool position salt. provider = POSITION_MANAGER.ownerOf(uint256(params.salt)); } if (!pool.liquidityProviders[provider]) revert LiquidityProviderNotAllowed(poolId, provider); return IHooks.beforeAddLiquidity.selector; }Only approved callers create pools
New pools with this hook can only be created by approved callers, for example its own factory or launcher.
The code that does this (beforeInitialize):function beforeInitialize(address sender, PoolKey calldata key, uint160) external view onlyPoolManager returns (bytes4) { if (sender != owner) revert Unauthorized(); _configuredPool(key.toId()); return IHooks.beforeInitialize.selector; }
Who controls it: The hook developer can change the fee and the settings of its pools. The hook developer can also change: event windows, liquidity provider. The code never lets the fee go above 1%. 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 auditsetPoolConfigWhat 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.
It runs when a pool is created, often to lock in that pool’s settings.
Hook history
Nothing recorded yet.
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.