HyFi on Base
Uniswap v4 Hook Contract 0xb23f731949145e158e656e1abe128c5e617a6888 on Base · Custom pricing · Verified contract
- Volume (24h)
- $2.52K
- Value locked (TVL)
- $0
- All-time volume
- $2.52K
- Pools using this hook
- 6
- Swaps (24h)
- 165 (52 traders)
- Total swaps
- 442
What it does
A custom orderbook hook where deposited tokens are held by the contract and swaps are priced against an offchain-computed book pushed onchain by a permissioned updater.
How it works step by step
- Holds all LP liquidity as plain token balances in the contract via deposit() and withdraw() instead of Uniswap positions.
- Prices swaps by walking an orderbook of 68 ticks per side that a permissioned updater pushes onchain via updateBooks().
- Applies a staleness fee that grows per second since the book snapshot and is retained by the contract for market makers.
- Blocks direct liquidity provisioning through beforeAddLiquidity so that liquidity only enters through deposit().
- Supports direct swaps that bypass the PoolManager and carry no Uniswap protocol fee, plus routed swaps through beforeSwap with return deltas.
- Swap behaviour
- Swaps are priced by walking a compressed onchain book from its tip, with a per-second staleness fee in the output token. Trades either execute directly via swapExactInDirect/swapExactOutDirect or through the PoolManager's beforeSwap, which takes the input into the contract and returns a delta so the output is paid from the contract's balance.
- Liquidity behaviour
- Liquidity is not added through Uniswap v4; beforeAddLiquidity reverts with LiquidityNotAllowed, so LPs cannot deposit via the pool. Liquidity is deposited as plain token balances via deposit() and represented by an offchain-updated orderbook.
- Fee behaviour
- No pool LP fee (pools keyed with fee 0). A staleness fee accrues per second since the book snapshot timestamp at feePerSecond pips, capped at 100%, taken in the output token and retained by the contract for market makers. Base protocol fee from the PoolManager is applied on top for via-Uniswap swaps only.
- Owner & admin controls
- Owner (Ownable2Step) can set pair configs (tickWidth, baseLiqUnit, feePerSecond, baseIsCurrency0), set the updater and withdrawer addresses, and transfer or renounce ownership. Updater pushes all book state; withdrawer can withdraw any token balance held by the contract to any recipient. No pause or upgrade mechanism found.
Enabled Uniswap v4 callbacks
beforeInitialize, beforeAddLiquidity, beforeSwap, beforeSwapReturnDelta
beforeInitialize: only allows pools for configured pairs with the exact PoolKey. beforeAddLiquidity: blocks direct LP provisioning. beforeSwap with beforeSwapReturnDelta: prices the swap against the onchain book, takes the swapper's input into the contract and returns the delta so the base settles the output from the contract's balance.
Security & trust assessment
Risk level: high (verified source, high confidence).
Who controls it: The owner can change pair pricing parameters at any time, including tickWidth and feePerSecond, and can reassign the updater, which controls the entire book and thus swap prices. The withdrawer can drain all deposited token balances of the contract. A compromised updater can post arbitrary prices and drain liquidity; a compromised withdrawer can take all deposits.
Risk to user funds: The hook holds all deposited token balances directly and settles every swap by transferring tokens out of its own balance. The withdrawer can move all of these funds, and the updater can set prices that determine how much users receive. Users' deposits are therefore fully exposed to these privileged roles.
Security findings
- [high] Withdrawer can drain all deposited funds: The withdrawer role can call withdraw() to transfer any amount of any currency held by the contract to any recipient with no onchain link to the book or user balances.
- [high] Single updater controls all pricing: updateBooks is restricted to the updater address, which sets prices for every pair. A malicious or compromised updater can post book prices far off market and extract value from swappers.
- [medium] Owner can reconfigure pairs and fees: setPairConfig clears the stored book for a pair and the owner can change tickWidth and feePerSecond at any time, so the owner can reprice pairs or impose up to 100% staleness fees on swappers.
- [low] Staleness fee retained by contract: Trades walk a book whose timestamp may be old; the staleness fee grows linearly per second up to 100%, which is retained by the contract and attributed offchain to market makers rather than returned to the trader.
- [medium] Custody and accounting are offchain: Balances are held by the hook itself, not in the PoolManager, and the accounting of who owns the deposits is maintained offchain via events, so users depend on the operators' offchain reconciliation.
Contract details
- Verified source
- Yes (HyFi)
- Compiler
- solc 0.8.36+commit.8a079791
- Bytecode size
- 19,386 bytes
- Upgradeable proxy
- No
- Detected patterns
- moves-currency, ownable, return-delta
Pools using HyFi
- USDC / MSTRc (0.00% fee) — 24h volume $2.52K, TVL $0, 165 swaps today
- USDC / SPCXc (0.00% fee) — 24h volume $0, TVL $0, 0 swaps today
- USDC / cbBTC (0.00% fee) — 24h volume $0, TVL $0, 0 swaps today
- ETH / USDC (0.00% fee) — 24h volume $0, TVL $0, 0 swaps today
- USDC / GOOGLc (0.00% fee) — 24h volume $0, TVL $0, 0 swaps today
- USDC / NVDAc (0.00% fee) — 24h volume $0, TVL $0, 0 swaps today