We have received a grant from Uniswap Foundation to accelerate development and minimize risk with the Uniswap Hooks Library. As a leader in blockchain security, OpenZeppelin is developing a contracts library that empowers developers to build on top of secure and efficient code.
Uniswap v4 features
Uniswap v4 is the next version of the Uniswap decentralized exchange (DEX) protocol, building on the innovations introduced in the previous version. One of the key features of this version are the Hooks that allow developers to attach custom logic before and after major operations, including:
- Pool creation
- Liquidity addition and removal
- Swaps
- Donations
This release also introduces dynamic fees, allowing developers to define custom logic for calculating and updating fees, providing more flexibility in optimizing trading and liquidity management.
Other key aspects:
- Consolidated pool state and operations into a single contract, reducing gas costs for users.
- Support for EIP-1153, users only pay the final balance change, minimizing gas fees by avoiding intermediate calculations.
- Native support for ETH eliminates the need for wrapping/unwrapping into WETH9 (Wrapped Ether), simplifying interactions.
- Custom accounting features allow developers to adjust token amounts for swaps and liquidity modifications, enabling innovations like custom fee models or bypassing the concentrated liquidity structure.
Library roadmap
The development will be structured into three key milestones:
Abstract Hooks
The first milestone will focus on creating flexible abstractions that allow developers to easily design hooks with custom accounting. These hooks will enable advanced use cases, such as custom fee structures, dynamic curves, impermanent loss hedging, and Liquidity Value at Risk (LVR) minimization. Additionally, developers will have access to a robust testing suite, ensuring that any modifications maintain the required invariants for each hook.
Accounting Improvement Hooks
In the second milestone, the library will introduce pre-built implementation hooks designed to address some of the limitations of traditional Automated Market Makers (AMMs). For instance, one of the hooks will mitigate atomic sandwich attacks. Developers can extend these hooks or combine multiple hooks to tailor them to their specific use cases.
User Experience Hooks
The third milestone will provide additional tools, such as new order types and hooks for improved handling of large trades. However, the primary focus will be enhancing the user experience through a wizard-style interface that streamlines the process of combining multiple hooks. This interface will also simplify integration with development environments like Hardhat and Foundry, making it easier for developers to get started quickly.
Be the First to Build on Next-Gen AMMs
Hooks are a crucial feature for the next generation of Automated Market Makers (AMMs), unlocking a wide range of new use cases. By building on top of Uniswap Hooks, the developers have the opportunity to create innovative and secure decentralized applications (dApps) that push what is currently possible with DeFi.
Stay tuned to learn more about Uniswap v4
Don’t miss Juan Bautista Carpanelli, our Head of Blockchain Security Research, presenting at this major event:
- Building Hooks in Uniswap v4 at the DeFi Security Summit
What features would you like to see in the library? Let us know in the Forum. We’d love to hear from you!