Mandate
EthereumHookMandate is a Uniswap v4 hook on Ethereum. Brand new: its first pool went live today.
- Contract name
- Mandate
How this hook works
Trading taxA trading tax hook. It sets its own trading fee, takes a cut of every trade and manages liquidity for its providers.
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 (fee):function _fee(IPoolManager manager, PoolKey calldata key, SwapParams calldata params) private returns (uint24 fee, uint24 feeOverride, uint24 protocolFee, uint160 sqrtPriceX96) { PoolId id = key.toId(); Store.Layout storage s = Store.store(); Store.Book storage book = s.book[id]; uint256 since = _rule(manager, key, id, book, params); { // the tick before the swap, for afterSwap: transient, keyed by the pool, gone when the transaction ends int24 tickBefore; (sqrtPriceX96, tickBefore, protocolFee,) = StateLibrary.getSlot0(manager, id); assembly ("memory-safe") { tstore(id, tickBefore) } } Store.Settings storage set = s.settings[id]; if (set.feeCap == 0) return (key.fee, 0, protocolFee, sqrtPriceX96); fee = _curve(manager, key, set, book, since, params.zeroForOne); feeOverride = fee | LPFeeLibrary.OVERRIDE_FEE_FLAG; }Takes a cut of every trade
On top of the normal pool fee, it keeps a share of each trade. It can never be above 20%. 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) internal override returns (bytes4, BeforeSwapDelta, uint24) { // Static analysis 11-20: a swap that arrives while a hook action is under way (a pool's token calling the // PoolManager the hook unlocked, from inside a transfer) is refused, so no re-centre, wait match or order // fill ever runs in the middle of an action. The hook itself never swaps inside its own actions. assembly ("memory-safe") { if tload(0) { mstore(0, 0x0f2e5b6c) // Locked() revert(0x1c, 0x04) } } (BeforeSwapDelta delta, uint24 feeOverride) = Swapping.beforeSwap(poolManager, key, sender, params); return (IHooks.beforeSwap.selector, delta, feeOverride); }Manages liquidity for its providers
Liquidity providers deposit through the hook and it runs the pool position for them, tracking each one’s share.
The code that does this (fillOne):function _fillOne(IPoolManager manager, PoolKey calldata key, PoolId id, Store.Layout storage s, int24 tick, bool zeroForOne) private { bytes32 slot = keccak256(abi.encode(id, tick, zeroForOne)); uint256 epoch = s.orderEpoch[slot]; Store.Bucket storage bucket = s.buckets[keccak256(abi.encode(slot, epoch))]; uint128 liquidity = bucket.liquidity; if (liquidity == 0) return; (BalanceDelta total, BalanceDelta fees) = manager.modifyLiquidity( key, ModifyLiquidityParams(tick, tick + key.tickSpacing, -int256(uint256(liquidity)), slot), "" ); _accrue(manager, key, bucket, fees); BalanceDelta out = total - fees; bucket.amount0 = uint256(uint128(out.amount0())); bucket.amount1 = uint256(uint128(out.amount1())); bucket.filled = true; s.orderEpoch[slot] = epoch + 1; if (bucket.amount0 != 0) manager.mint(address(this), key.currency0.toId(), bucket.amount0); if (bucket.amount1 != 0) manager.mint(address(this), key.currency1.toId(), bucket.amount1); emit IMandate.OrderFilled(id, tick, zeroForOne, epoch, bucket.amount0, bucket.amount1); }Trades on its own
It makes trades itself, for example to convert the fees it collected.
The code that does this (reset):function _reset( IPoolManager manager, PoolKey memory key, PoolId id, uint160 sqrtRefX96, bool zeroForOne, uint160 limit ) private { (uint160 spot,,,) = StateLibrary.getSlot0(manager, id); if (spot == sqrtRefX96 || StateLibrary.getLiquidity(manager, id) != 0) return; if (zeroForOne ? limit >= sqrtRefX96 : limit <= sqrtRefX96) revert IMandate.PoolPriceOff(); BalanceDelta moved = manager.swap( key, SwapParams({zeroForOne: spot > sqrtRefX96, amountSpecified: -1, sqrtPriceLimitX96: sqrtRefX96}), "" ); if (BalanceDelta.unwrap(moved) != 0) revert IMandate.PoolPriceOff(); }Burns tokens
It destroys some tokens (or sends them to an address nobody controls), so there are fewer of them.
The code that does this (exit):function _exit(IPoolManager manager, Call memory c) private returns (uint256 out0, uint256 out1) { PoolId id = c.key.toId(); Store.Layout storage s = Store.store(); Store.Settings storage set = s.settings[id]; if (set.curator == address(0)) revert IMandate.UnknownPool(); if (c.shares == 0) revert IMandate.NothingPaid(); Store.Book storage book = s.book[id]; // fees are collected even when Chainlink's price is stale Range.collect(manager, c.key, id, book); // leaving never waits for a price, and nothing inside SETTLE UP can stop it. No gas floor: a try that // runs out of gas leaves 1/64 of it, too little to finish the exit, so SETTLE UP cannot be skipped // by choosing the gas (a test sweeps the gas limits) (bool live, uint160 sqrtRefX96) = Price.read(set.source, c.key.currency0, c.key.currency1, set.maxAge); uint256 before = 0; if (live) { try Curation.settle(manager, id, sqrtRefX96) returns (uint256 ratio) { before = ratio; } catch { emit IMandate.SettleSkipped(id); } } uint256 shareId = uint256(PoolId.unwrap(id)); uint256 supply = s.totalSupply[shareId]; Ledger.burn(c.actor, c.actor, shareId, c.shares); (out0, out1) = _pay(manager, c, id, book, supply); if (out0 < c.limit0 || out1 < c.limit1) revert IMandate.Slippage(); if (before != 0) { try Curation.carry(manager, id, sqrtRefX96, before) {} catch {} // …Needs a signed approval
Some actions need a message signed by an approved address.
The code that does this (steer):function _steer(IPoolManager manager, Signed memory c) private { PoolId id = c.key.toId(); Store.Layout storage s = Store.store(); Store.Settings storage set = s.settings[id]; Store.Book storage book = s.book[id]; if (set.curator == address(0)) revert IMandate.UnknownPool(); if (block.timestamp > c.deadline) revert IMandate.Expired(); if (book.movedBlock == block.number) revert IMandate.AlreadyMoved(); bytes32 digest = Intents.digest(address(this), id, c.width, c.sender, book.nonce, c.deadline); if (!SignatureChecker.isValidSignatureNow(set.curator, digest, c.signature)) revert IMandate.BadSignature(); book.nonce += 1; // a signed width is used once Compass.Bounds memory bounds = Compass.Bounds(set.widthMin, set.widthMax, set.offsetMax); if (!Compass.widthAllowed(bounds, c.width, c.key.tickSpacing)) revert IMandate.OutOfBounds(); _signedMove(manager, c.key, id, set, book, c.width); }
Who controls it: It has an admin address, but no admin-only settings in its own code. 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 audittakeForsource on every trade.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.
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
Across all its pools, the hook joined: $4.88.
- Joined 1 time, worth $4.88
- Opened a pool 1 time
Settings changes: set the split (1 time), set the share (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. Dollar values count the amounts paid in ETH, stablecoins, BNB and BTC, at today’s prices.