BloomFeeHook
BaseBloomFeeHook is a Uniswap v4 hook on Base. Runs code on every swap. Can take tokens from swaps. Runs at pool creation.
- Contract name
- BloomFeeHook
How this hook works
Trading taxA trading tax hook. It takes a cut of every trade, keeps a price record and only lets approved callers create pools.
Takes a cut of every trade
On top of the normal pool fee, it keeps a share of each trade. The fee builds up in the hook until it is collected.
The code that does this (beforeSwap):function beforeSwap(address sender, PoolKey calldata key, SwapParams calldata params, bytes calldata) external onlyPoolManager returns (bytes4, BeforeSwapDelta, uint24) { PoolId id = key.toId(); Terms memory t = terms[id]; if (t.token == address(0)) revert InvalidPool(); _observe(id); bool exactInput = params.amountSpecified < 0; bool specifiedIs0 = exactInput == params.zeroForOne; if (specifiedIs0 != t.quoteIs0) return (IHooks.beforeSwap.selector, BeforeSwapDeltaLibrary.ZERO_DELTA, 0); // Quote is the specified leg: exact-input buy or exact-output sell. uint256 gross = exactInput ? uint256(-params.amountSpecified) : FeeMath.grossForNet(uint256(params.amountSpecified), t.creatorBps); uint256 fee = _collect(t, sender, gross); return (IHooks.beforeSwap.selector, toBeforeSwapDelta(int128(int256(fee)), 0), 0); }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 (beforeSwap):function beforeSwap(address sender, PoolKey calldata key, SwapParams calldata params, bytes calldata) external onlyPoolManager returns (bytes4, BeforeSwapDelta, uint24) { PoolId id = key.toId(); Terms memory t = terms[id]; if (t.token == address(0)) revert InvalidPool(); _observe(id); bool exactInput = params.amountSpecified < 0; bool specifiedIs0 = exactInput == params.zeroForOne; if (specifiedIs0 != t.quoteIs0) return (IHooks.beforeSwap.selector, BeforeSwapDeltaLibrary.ZERO_DELTA, 0); // Quote is the specified leg: exact-input buy or exact-output sell. uint256 gross = exactInput ? uint256(-params.amountSpecified) : FeeMath.grossForNet(uint256(params.amountSpecified), t.creatorBps); uint256 fee = _collect(t, sender, gross); return (IHooks.beforeSwap.selector, toBeforeSwapDelta(int128(int256(fee)), 0), 0); }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 sqrtPriceX96) external onlyPoolManager returns (bytes4) { if (key.fee != 0 || key.tickSpacing != TICK_SPACING || address(key.hooks) != address(this)) revert InvalidPool(); address c0 = Currency.unwrap(key.currency0); address c1 = Currency.unwrap(key.currency1); (address curve, address quote, address executor, bytes32 existing) = factory.launchRouting(c0); address token = c0; if (curve == address(0)) { (curve, quote, executor, existing) = factory.launchRouting(c1); token = c1; } if (curve == address(0) || quote != (token == c0 ? c1 : c0) || sender != executor || existing != bytes32(0) || IHookExecutor(executor).feeHook() != address(this) || address(keys[token].hooks) != address(0) || BondingCurve(curve).phase() != BondingCurve.Phase.PoolActive) revert InvalidPool(); (, , address escrow, address platform, , address vault, , , , uint16 creatorBps, uint16 holderShareBps, uint16 buybackShareBps,) = BondingCurve(curve).settings(); PoolId id = key.toId(); terms[id] = Terms(token, quote, curve, escrow, platform, vault, quote == c0, creatorBps, holderShareBps, buybackShareBps); keys[token] = key; IERC20(quote).forceApprove(escrow, type(uint256).max); IERC20(quote).forceApprove(token, type(uint256).max); IERC20(quote).forceApprove(vault, type(uint256).max); Oracle storage o = oracles[id]; o.lastUpdate = uint64(block.timestamp); o.observations[0] = Observation(uint64(block.timestamp), 0); o.count = 1; sqrtPriceX96; // Price itself is validated by the executor and factory guard. emit CanonicalPoolRegistered(token, id, quote); // …
Who controls it: Nobody. The hook has no admin functions, and the code cannot be changed.
Based on the hook’s published code.
What it can do
Its code executes inside each trade in pools that use it.
It can take or add tokens during a swap. Fees, burns and custom curves work this way, and so do scams.
It runs when a pool is created, often to lock in that pool’s settings.
Hook history
- Pool fees 2 times
Latest transactions
- 0x9288e0e1…2c9200 block 56,082,361 · 4.88e-9 TREE
- 0x1db018d2…f5619c block 56,081,554 · 4.70e-7 TREE
- Registered a new pool with its starting price 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.