An LP-focused behavioral security intelligence platform for Uniswap v4Hook.
HookLens is a Uniswap v4 LP Intelligence and Security Testing Platform designed to help liquidity providers understand the real risks and behaviours of programmable hooks before depositing liquidity. While Uniswap v4 hooks enable powerful custom functionality such as dynamic fees, custom accounting, and liquidity-related callbacks, they also introduce additional complexity and potential risks that are difficult for LPs to evaluate.
HookLens goes beyond basic hook permission scanners and static warnings by combining deterministic smart contract analysis, execution-based adversarial simulations, LP-specific exposure calculations, and evidence-grounded AI explanations. Users can analyze hook contracts, inspect callback permissions and administrative capabilities, investigate potential withdrawal restrictions, and execute real Foundry-based scenarios against forked blockchain environments. The platform evaluates how hook behaviour can affect liquidity positions, trading fees, accounting, and withdrawal operations under different conditions.
HookLens also provides an LP Exposure Engine that calculates concentrated liquidity position metrics, compares baseline conditions with simulation outcomes, and helps users understand potential changes in their position's composition and economics. Its AI-powered intelligence layer transforms technical findings, source references, execution traces, and simulation results into understandable explanations without inventing security conclusions.
By combining on-chain intelligence, reproducible testing, position-level analysis, and transparent evidence, HookLens aims to make Uniswap v4 liquidity provision more informed, measurable, and accessible. It complements existing hook warnings by helping users investigate not only what a hook is capable of doing, but also what its behaviour means for their liquidity.
HookLens is built around one shared Python analysis engine (hooklens) with two interfaces: a FastAPI backend for the web application and a CLI/GitHub Action for automated CI scans. Both import the same analyzers, ensuring consistent results across interactive and automated security analysis.
When a hook address is submitted, we resolve its contract through Ethereum JSON-RPC and pin the analysis to a specific block number and hash for reproducibility. We detect EIP-1967 and EIP-1167 proxies, retrieve verified source code through Etherscan, compile it with solc, and inspect its AST for access control, dynamic fees, oracle dependencies, external calls, withdrawal paths, return-delta accounting, and upgradeability. Hook permissions are decoded from the address bits using a flag table generated from the vendored Uniswap v4-core Hooks.sol, with CI checks to prevent protocol drift.
For execution-level testing, we built a Foundry harness that forks Ethereum Mainnet at the pinned block and runs six adversarial scenarios against the real Uniswap v4 PoolManager. LP, trader, and admin actor contracts exercise different behaviours. We use vm.mockCall to test oracle failures, zero values, and stale responses. Foundry traces are parsed into call trees, and v4 WrappedError values are decoded to identify the exact reverting hook call. Each result includes a reproducible command.
Our LP exposure engine is an exact-integer Python implementation of TickMath, SqrtPriceMath, and LiquidityAmounts, validated bit-for-bit against golden vectors generated by the Solidity libraries. Live pool state is read directly from PoolManager storage using extsload and Uniswap's StateLibrary slot layout. Results are block-aware and explicitly classified as live, historical, measured, hypothetical, or unavailable.
One particularly hacky challenge was pool discovery: Uniswap v4's Initialize event does not index the hook address, while free RPC providers limit eth_getLogs. We worked around this by paging through Etherscan's log API and maintaining a persistent index of over 47,000 mainnet pools across 11,000+ hooks. Initial indexing takes approximately 3.5 minutes; subsequent scans take around 18 seconds.
We also built position-aware withdrawal testing: if a hook rejects an LP deposit, subsequent withdrawals are marked "not tested" rather than incorrectly reported as blocked. Another important fix was enforcing PostgreSQL column-length constraints in SQLite tests after a database mismatch caused a production issue.
Our partner technologies are central to the implementation: Uniswap v4 provides the protocol and storage architecture, Foundry enables reproducible fork testing, Etherscan provides verified source and historical log access, and Anthropic Claude generates optional plain-language explanations validated against stored evidence. The frontend uses Next.js, TanStack Query, and Zod-validated types generated from OpenAPI. We generate versioned JSON reports with SHA-256 hashes, PDF reports, and SARIF output. The platform is deployed on Render with PostgreSQL, and CI gates every deployment.

