BunniHookLogic on Arbitrum

Uniswap v4 Hook Contract 0x0000fe59823933ac763611a69c88f91d45f81888 on Arbitrum · Dynamic fee · Verified contract

Volume (24h)
$0
Value locked (TVL)
$0
All-time volume
$0
Pools using this hook
18
Swaps (24h)
0 (0 traders)
Total swaps
4,066

What it does

BunniHook prices swaps off the pool's liquidity density function and charges a dynamic fee that goes up when the price moves away from its recent average and rises further during surge periods, with an optional am-AMM fee override.

This read was written for the hook 0x0010…1888 on Base and reused here: the two share a code shape, so constants such as fees, owners and addresses can differ.

How it works step by step

  • Acts as the hook for a Bunni liquidity pool: on every swap it reads the pool state from BunniHub and computes an output or input amount from the liquidity density function (LDF) and the pool's active balances.
  • Computes a dynamic swap fee from a TWAP-based price deviation term (feeMin, feeMax, feeQuadraticMultiplier) and adds a surge fee that decays after vault share price jumps or large swaps.
  • Maintains a TWAP oracle of the pool tick via observation writes and derives arithmeticMeanTick and feeMeanTick for pricing and fee calculation.
  • Optionally routes swap fee revenue to an am-AMM manager who bids for the right to set a swap fee for the pool, with the bid token being the BunniToken.
  • Can rebalance excess liquidity between tokens by creating FloodPlain rebalance orders and executing them through pre/post hooks that move claim tokens through the PoolManager.
  • Splits a hook fee off the swap fee and sends a referral reward share to the BunniToken, while the rest of the swap fee stays in the pool for LPs or goes to the am-AMM manager.
Swap behaviour
On every non-zero swap the hook can override the price (via hooklet), recompute the swap through the LDF, and return a custom beforeSwapDelta. Swaps revert if the requested output exceeds the active balance, the price would move the wrong way, or an exact-output swap cannot be fully filled. Fees are charged as a percentage of the output (exact-in) or added to the input (exact-out); the dynamic fee rises when price deviates from the TWAP and rises further during a surge.
Liquidity behaviour
No liquidity callbacks beyond beforeAddLiquidity, which is enabled (the decoded permission set includes beforeAddLiquidity); the add-liquidity path itself is handled by BunniHub rather than in this hook.
Fee behaviour
Fee is dynamic: computeDynamicSwapFee combines the TWAP-deviation quadratic term between feeMin and feeMax, a surge fee that decays with surgeFeeHalfLife after vault share price jumps or surges, and an am-AMM override when a manager with a valid bid is set. A hook fee (hookFeeModifier of the swap fee) is taken and the referral reward is paid to BunniToken holders. Hooklets can also override the fee for a given swap.
Owner & admin controls
Owner (set at construction via Ownable with two-step handover) can change hookFeeModifier and referralRewardModifier (capped at MODIFIER_BASE), change the hook fee recipient, and set the flood zone. The hub, PoolManager, FloodPlain, WETH and permit2 addresses are immutable. Pause or upgrade power is not visible in the BunniHook source, but the proxy means the implementation can be swapped by whoever controls the proxy admin, which is not verified from the input.

Enabled Uniswap v4 callbacks

afterInitialize, beforeAddLiquidity, beforeSwap, beforeSwapReturnDelta

afterInitialize: initializes slot0, the TWAP observation array and cardinality from the hub's pool init data. beforeSwap: runs the full swap logic, fee computation, oracle update, vault surge check, optional rebalance and am-AMM fee accrual. beforeSwapReturnDelta: lets beforeSwap return a custom delta so the hook dictates the amounts settled for the pool. beforeAddLiquidity: enabled in permissions; the decoded bytecode shows no custom add-liquidity logic in the hook itself.

Security & trust assessment

Risk level: medium (verified source, medium confidence).

Who controls it: The owner can change fee modifiers and the fee recipient immediately, and the proxy admin (not visible in input) could replace the implementation, so a privileged key could change how fees are taken or what the hook does with user swaps.

Risk to user funds: The hook takes in and pays out tokens via the PoolManager claim-token mechanism and return deltas, and it can rebalance pool reserves through FloodPlain orders. A compromised upgrade or owner key could divert hook fees or affect the amounts settled on swaps, but the hook does not hold user funds outside the pool accounting, and swaps can revert rather than trap funds.

Security findings

  • [medium] Return-delta swap control: beforeSwapReturnDelta lets the hook set the specified and unspecified amounts returned to the PoolManager, so the hook computes the trade result and decides how much input and output moves for every swap.
  • [medium] Upgradeable proxy: The hook address is a proxy that delegates every call to implementation 0x59f17b5b56a3e156becfdcf1f12298fc88e165b7; the proxy admin can replace the logic and so change swap, fee and fund-handling behaviour for all pools using it.
  • [low] Owner-set fee modifiers and recipient: The owner can change hookFeeModifier (up to 100% of the swap fee) and the hookFeeRecipient, redirecting protocol fees; the referral reward modifier is also owner-controlled.
  • [info] Oracle and fee depend on TWAP: Fee and rebalance pricing use a TWAP built from observations, so price manipulation over the TWAP window directly affects the dynamic fee and rebalance slippage checks.
  • [info] Reentrancy guard present: beforeSwap and the rebalance order hooks are protected by a transient-storage nonReentrant modifier, which limits reentrant swap paths.

Contract details

Verified source
Yes (BunniHookLogic)
Compiler
solc 0.8.25+commit.b61c2a91
Bytecode size
23,510 bytes
Upgradeable proxy
Yes
Detected patterns
liquidity-management, oracle, return-delta, upgradeable

Pools using BunniHookLogic