LendingHookV4 on Ethereum

Uniswap v4 Hook Contract 0xb5296cba81781f7ca83ac7b86ad2360b3410bacc on Ethereum · Liquidity management · Verified contract

Volume (24h)
$0
Value locked (TVL)
<$0.01
All-time volume
$150
Pools using this hook
1
Swaps (24h)
0 (0 traders)
Total swaps
28

What it does

A lending-AMM hook for an ETH/TOKEN pair where LPs deposit into a single full-range Uniswap v4 position for ERC20 shares, and borrowers lock TOKEN collateral to borrow ETH at 40 percent LTV with liquidation below 150 percent.

This read was written for the hook 0xfe89…7acc on Ethereum 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

  • LPs deposit ETH and TOKEN through deposit() into one full-range v4 position and receive transferable ERC20 share tokens.
  • Borrowers lock TOKEN as collateral and borrow ETH at 40 percent LTV, with a proportional withdrawal from the LP position to keep spot constant.
  • Interest accrues linearly on debt at a utilization-curve rate locked at borrow time, and a 1 percent origination fee is split between FeeCollector and LPs.
  • Anyone can liquidate a position below 150 percent collateral value, paying the debt in ETH and receiving collateral TOKEN at a 2.5 percent discount, with residual collateral refilled into the LP.
  • Protocol swap fee is skimmed on each swap via return deltas and sent to the hardcoded FeeCollector; LP swap fees accrue to the position.
Swap behaviour
Swaps pay a fixed total fee chosen at deploy; half accrues to LPs through the pool and half is taken by the hook into FeeCollector via before/after swap return deltas. Swaps are blocked in any block where a liquidation occurred, and each swap captures a price snapshot used for lending valuations.
Liquidity behaviour
Liquidity is added and removed only through deposit and withdraw (ERC20 share minting/burning, with a 2-block JIT cooldown and same-block liquidation lockout) and internally through borrow, repay and liquidate, which remove or add the hook's single full-range V4 position. beforeAddLiquidity and beforeRemoveLiquidity revert for any sender other than the hook itself, so third parties cannot add liquidity to this pool.
Fee behaviour
Total swap fee tier is chosen at deploy time from the constructor argument (even, at most 100000 pips) and is immutable. Half is the LP fee, set as the V4 pool fee and accrued by the PoolManager to the hook-held position. The other half (PROTOCOL_SWAP_FEE_PIPS) is skimmed in beforeSwap for buys or afterSwap for sells and sent to the hardcoded FeeCollector address. Borrowers pay a 1 percent origination fee on debt, of which 50 percent goes to FeeCollector and 50 percent is donated back to the LP position. Interest accrues on debt at a utilization-based rate locked at borrow time.
Owner & admin controls
Single deployer role set at construction (typically the factory). Its only power is setDeployer, which can hand the role to another address or burn it by passing address(0). No other function is gated by the deployer; initializePool is permissionless and guarded by a one-shot poolInitialized flag. There is no pause, no upgrade proxy and no parameter setter: fee tier and LTV/rate constants are immutable or constant.

Enabled Uniswap v4 callbacks

beforeInitialize, afterInitialize, beforeAddLiquidity, beforeRemoveLiquidity, beforeSwap, afterSwap, beforeSwapReturnDelta, afterSwapReturnDelta

beforeInitialize: enforces the canonical PoolKey (ETH/token, this hook) and that only the hook initializes. afterInitialize: returns selector only. beforeAddLiquidity / beforeRemoveLiquidity: block all external liquidity modifications. beforeSwap: captures snapshots, blocks swaps in liquidation blocks, and skims the protocol fee on ETH-in buys via a return delta. afterSwap: syncs realETH/realToken from the position and skims the protocol fee on sells via a return delta (afterSwapReturnDelta).

Security & trust assessment

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

Who controls it: The deployer key can only reassign or burn the deployer role; it cannot move funds, change fees, pause or upgrade. Its power is effectively nil beyond ownership of the role itself. Users rely on immutable code and the hardcoded PoolManager and FeeCollector addresses.

Risk to user funds: The hook holds all pooled ETH and TOKEN in its V4 position plus borrower collateral and loan reserves. Users can lose funds through bad debt if the pool spot is manipulated or lending losses exceed collateral, and LPs may be unable to withdraw while utilization is high. The hook cannot be paused or upgraded by an admin, and no admin path can seize user funds.

Security findings

  • [medium] Pool-spot oracle for lending: Lending is protected by a 40 percent LTV and a 150 percent liquidation threshold, but collateral and debt are priced off the pool's own spot ratio. Price is smoothed by a 2-block SAFE_LAG snapshot and a utilization cap, which limits but does not eliminate manipulation risk, especially for thin pools.
  • [medium] Bad debt socialized to LPs: Borrow and liquidation rely on prevSnap during swap activity and on realETH/realToken otherwise. An attacker sustaining price moves across 3+ blocks or exploiting thin depth could still mis-value collateral; bad debt is socialized to LPs since losses reduce realETH.
  • [info] Hook custodies pool reserves and takes fees via return deltas: Hook takes protocol fees through beforeSwapReturnDelta and afterSwapReturnDelta and sends them to a hardcoded FeeCollector; a hook-controlled ERC20 pool position holds all LP ETH and token reserves.
  • [info] Dust and excess routed to FeeCollector: Repay and liquidation send residual dust and excess tokens to the hardcoded FeeCollector; the contract accepts ETH via receive() and donates accrued swap fees back to the position.

Contract details

Verified source
Yes (LendingHookV4)
Compiler
solc 0.8.26+commit.8a97fa7a
Bytecode size
24,231 bytes
Upgradeable proxy
No
Detected patterns
donates, erc20, liquidity-management, moves-currency, return-delta, self-unlock

Pools using LendingHookV4