BunniHook on Base

Uniswap v4 Hook Contract 0x0000fe59823933ac763611a69c88f91d45f81888 on Base · Liquidity management · Verified contract

Volume (24h)
$0
Value locked (TVL)
$0
All-time volume
$0
Pools using this hook
189
Swaps (24h)
0 (0 traders)
Total swaps
358,292

What it does

BunniHook is the Uniswap v4 hook behind Bunni liquidity pools: it rebalances pool liquidity through FloodPlain orders, applies dynamic and surge swap fees from an on-chain TWAP oracle, and runs an auction (am-AMM) that lets bidders capture swap fees in exchange for rent paid in BunniTokens.

How it works step by step

  • Runs afterInitialize to set up oracle observation state and pool state for each new Bunni pool, via BunniHookLogic.
  • Records a TWAP oracle with cardinality that can be grown by anyone through increaseCardinalityNext.
  • Runs an am-AMM auction: bidders submit bids (bid, depositIntoTopBid, increaseBidRent) denominated in BunniTokens and the top bidder can set the swap fee for the pool via a payload, with fees accrued to the manager.
  • Auto-rebalances excess liquidity by creating FloodPlain rebalance orders (rebalanceOrderPreHook / rebalanceOrderPostHook) that pull tokens from BunniHub and push output back.
  • Gates withdrawals via canWithdraw, which is false while a rebalance order is active unless the owner unblocks withdrawals for a pool.
  • Accrues protocol hook fees to the hook fee recipient and lets anyone trigger claimProtocolFees to send them out.
Swap behaviour
beforeSwap runs under a nonReentrant guard and is delegated to BunniHookLogic. It computes the dynamic fee from the TWAP and surge state, can return a BeforeSwapDelta (beforeSwapReturnDelta is enabled), and accrues the am-AMM manager's fee to the manager when the auction fee applies.
Liquidity behaviour
No liquidity callbacks are executed beyond beforeAddLiquidity being enabled as a permission. Hub-side liquidity accounting is handled by BunniHub; the hook recomputes idle balance after rebalances.
Fee behaviour
Swap fees are dynamic: a TWAP-based fee with a quadratic multiplier, a surge fee after large moves or vault share price changes, and an am-AMM manager fee capped by maxAmAmmFee (at most 10%). A protocol cut is taken as hookFeeModifier of the swap fee, and a referral reward share is derived from it.
Owner & admin controls
The owner (Solady Ownable, two-step handover available) can: set the FloodZone address (setZone), set the hook fee recipient (setHookFeeRecipient), set hook fee and referral reward modifiers up to 100% of base (setModifiers), and unblock withdrawals per pool (setWithdrawalUnblocked). The hub, floodPlain and poolManager addresses are immutable. No upgrade proxy or pause function was found in the ABI.

Enabled Uniswap v4 callbacks

afterInitialize, beforeAddLiquidity, beforeSwap, beforeSwapReturnDelta

afterInitialize sets up oracle and pool state for new pools. beforeAddLiquidity is enabled as a permission flag. beforeSwap computes dynamic fees, surge logic and am-AMM fee accrual. beforeSwapReturnDelta lets the hook return a delta that changes the amounts settled for the swap.

Security & trust assessment

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

Who controls it: Not stated.

Risk to user funds: Not stated.

Security findings

  • [medium] Owner can redirect protocol fees: setHookFeeRecipient lets the owner change where claimed protocol fees are sent, and setModifiers can raise hookFeeModifier up to 100% of the swap fee. This shifts value from LPs to the protocol or to the owner-controlled recipient, without a timelock in the code.
  • [medium] Owner can unblock withdrawals and set the Flood zone: setWithdrawalUnblocked forces canWithdraw to true during an active rebalance order, which can let LPs withdraw while a rebalance is in progress. setZone replaces the FloodZone contract used by rebalance orders, so the owner controls which zone validates orders.
  • [medium] Hook returns deltas and takes tokens: beforeSwapReturnDelta is enabled and beforeSwap returns a BeforeSwapDelta, so the hook can alter the amounts settled on each swap. The hook also holds claim tokens and performs take/settle during rebalances, so its accounting correctness is critical to pool funds.
  • [info] Rebalance orders depend on external FloodPlain and zone contracts: Rebalance execution relies on the FloodPlain and FloodZone contracts for authorization (isValidSignature checks a stored Permit2 hash). Bugs or misconfiguration in those dependencies could affect rebalancing funds.
  • [info] Non-upgradeable by design: The ABI and source show no proxy or upgrade mechanism; the contract logic is fixed at deployment, with the owner's powers limited to the parameters above.

Contract details

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

Pools using BunniHook