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
Liquidity (DEX)
Liquidity on a decentralized exchange (DEX) refers to the pool of digital assets locked in smart contracts, enabling seamless token trading by ensuring sufficient supply and demand for transactions.
Grayscale
One of the world's largest digital asset investment platforms, offering regulated products for digital assets exposure including trusts and ETFs of Bitcoin and Ethereum.
Fiat-pegged Stablecoin
A digital asset tied 1:1 to a fiat currency, like USD or EUR, for price stability.
Limit Order
An order to buy or sell an asset at a specified price or better, which may rest in the order book if not immediately filled.
Cross-Chain Swap
A cross-chain swap is the exchange of digital assets between two different blockchain networks, facilitated by bridges or protocols to enable interoperability.
AML/CFT
Anti-Money Laundering and Countering the Financing of Terrorism regulations for financial integrity.