Liquidity Hook (Uniswap)
Uniswap liquidity hooks are external smart contracts in Uniswap v4 that customize liquidity addition and removal in pools, enabling developers to inject logic before or after these actions for enhanced DeFi features.
What is Uniswap Liquidity Hook?
Uniswap liquidity hooks form part of the broader hooks system in Uniswap v4, launched in early 2024, where external smart contracts attach to individual liquidity pools to modify behaviors at key lifecycle points, including liquidity modifications. These hooks are optional and specified during pool initialization via the PoolManager’s initialize function, with permissions encoded in the hook contract’s address to dictate callable functions. As of September 2025, Uniswap v4 pools with hooks manage over $2 billion in total value locked (TVL) across Ethereum and layer-2 networks like Arbitrum, per DeFiLlama data, powering innovations like dynamic yield distribution.
For liquidity-specific hooks, four granular functions allow customization: beforeAddLiquidity and afterAddLiquidity for deposits, and beforeRemoveLiquidity and afterRemoveLiquidity for withdrawals. These receive parameters like the PoolKey (identifying the pool via token pair, fee tier, and hook address), ModifyLiquidityParams (specifying liquidity amounts and tick ranges), and hookData (arbitrary bytes for custom logic). For instance, in a beforeAddLiquidity hook, a developer might increment a counter via transient storage (EIP-1153) to track deposits, as in Uniswap’s example code: beforeAddLiquidityCount[key.toId()]++;, enabling features like capped liquidity for exclusive pools. An afterAddLiquidity hook could then distribute rewards, such as allocating 0.1% of added USDC (valued at $1,000) as airdrop tokens to providers in a yield farming setup.
Concrete examples include lending hooks that integrate with protocols like Aave, where adding 1 ETH (~$3,000) liquidity triggers an automatic collateral deposit, earning 4% APY alongside Uniswap’s 0.3% swap fees, processing $100 million in volume monthly in integrated pools. Risks involve smart contract vulnerabilities, as hooks expand the attack surface—e.g., a 2024 exploit in a third-party hook drained $5 million by manipulating afterRemoveLiquidity deltas—and require audits, with Uniswap recommending tools like Slither for permission checks. Gas costs for hooked liquidity actions average $5-$15 on Ethereum mainnet but drop to $0.50 on Optimism, making them efficient for high-volume DeFi applications.
Related Terms
Liquid Staking
A staking mechanism on Ethereum where users receive derivative tokens representing their staked ETH, allowing them to use these tokens in DeFi activities while earning staking rewards.
Virtual AMM (vAMM)
A mechanism mimicking automated market makers for perpetual swaps without holding actual assets.
Based Rollup (L1-sequenced)
A based rollup is a layer-2 scaling solution for Ethereum that uses the layer-1 blockchain's validators for transaction sequencing, enhancing decentralization and alignment with Ethereum's security model.
Oracle (Prediction Market)
A trusted source that provides off-chain data to resolve the outcome of a prediction market contract on a blockchain.
Fraud Proof of Ethereum Rollup
A fraud proof in Ethereum rollups is an interactive on-chain challenge mechanism that disputes invalid off-chain transaction states in optimistic rollups, enforcing correctness through economic penalties.
Oracle
A mechanism that provides real-world data to blockchains for use in smart contracts.