Original author: @poopmandefi
Translated by: BlockBeats
On June 13th, Uniswap released the Uniswap V4 code draft. The vision of Uniswap V4 is to allow anyone to make these trade-offs by introducing "hooks". Hooks are contracts that run at various points in the pool operation lifecycle, and pools can make the same trade-offs as v3 or add new features. In response to this version, DeFi researcher Poopman conducted a detailed analysis on his social platform, and BlockBeats compiled it as follows.
2 years ago, Uniswap V3 introduced concentrated liquidity to improve capital efficiency. Today, Uniswap V4 is bringing customization and optimization to the AMM space. If you care about DeFi and its future, you should read this article to gain a deeper understanding of Uniswap V4.
Since the birth of DeFi, Uniswap has always been at the forefront of AMM innovation. In its 5-year history, Uniswap has undergone 3 changes in total.
1. V1 = Innovative ERC20 for ETH liquidity pool and AMM;
2. V2 = Enable ERC20/ERC20 liquidity pool and flash exchange;
3. V3 = Concentrated Liquidity.
With the launch of Uniswap V4, Uniswap will completely change the DeFi field through three new concepts, including:
1. "Hooks"
2. "Singleton Pattern" (The Singleton)
3. "Flash Accounting"
First of all, we need to understand the necessity of Uniswap V4. The lack of customizability has always been a problem in versions V2/V3. Due to technical complexity, third-party developers have always been unable to implement features such as volatility oracles and limit orders in V2/V3.
And in V4, Uniswap attempts to solve this problem through a new feature called Hooks. Hooks are an external smart contract that can execute logic at different "key points" in the pool. Key points refer to operations before/after the swap, or when depositing/withdrawing LP, etc.
Through Hooks, liquidity pool creators can adjust pool parameters and introduce new features to AMMs. Moreover, the implementation of Hooks can also change the curve and allow for the construction of various strategies on top of Uniswap, ultimately benefiting LPs/swappers more.
Demonstration use cases include:
・Create limit orders with the smallest possible price change, known as the minimum price increment.
・Through Time-Weighted Average Market Making (TWAMM) market making, the order itself is decomposed into smaller parts.
・Implement dynamic fees during high volatility periods to encourage balanced liquidity pools.
Hooks even allow for customizing oracles and distributing internal MEV to LP holders. For more information on this, you can read the Cosmos ecosystem LSD protocol Stride co-founder Riley Edmunds' post.
In addition, V4 also has another feature called "Action Hooks", which can call logic during execution. Action Hooks are contracts that are triggered and run only when the "Flag" condition is met and becomes "True".
Before the Swap, the contract will check the Flag to evaluate the volatility of the fund pool; if the volatility is high, the Flag will become "True" and run the action hook; if the volatility is not very high, the Flag will become "False" and the Swap will be executed as usual.
By doing this, the action hook achieves a more gas-efficient way of determining which hook to execute. Now, V4 allows for action hooks to be implemented in 8 different scenarios:
On the other hand, the Singleton structure and Flash accounting will be implemented in V4 for cheaper transaction and deployment experience. How is it achieved?
In V3, every time a liquidity pool is created, a new contract must be deployed, and the deployment cost is very high. In V4, the singleton pattern saves all pools in one contract, which reduces the deployment cost of pools by 99% compared to V3.
In V3, each transaction or LP staking ends with a "Token transfer" action. In other words, every operation you perform requires a Token transfer. This may result in the exchange consuming a significant amount of gas fees during each operation.
translates to
Use the Lightning Accounting System in V4, where each operation (exchange/deployment) only results in updates to the internal balance, which is priced in "delta" units. At the end of the exchange, it will only exchange the net "delta" balance after a series of calculations.
Due to the fact that liquidity pool managers do not need to own any tokens at the end of the transfer, the Flash Accounting System ensures the solvency of the liquidity pool. Combined with the singleton pattern, this architecture can simplify multi-hop transactions and complex pool operations, making V4 more user-friendly.
Unfortunately, the lightning accounting model is still very expensive, as once the storage refund limit is exceeded, users need to pay Gas fees to update the internal balance. In order to reduce Gas fees, Uniswap needs to perform a temporary storage upgrade from EIP-1153.
In short, temporary storage is a method of providing a temporary storage area in the transaction execution environment, and this storage area will disappear after the transaction is completed.
Temporary storage not only helps reduce overall Gas costs, but also simplifies smart contracts and improves their interactions.
V4 Other noteworthy upgrades include:
恢复原生 ETH 交换;
Restore native ETH exchange;
Introducing donation function (giving tips to liquidity providers, etc.);
Governance update, control Swap fee upper limit.
In short, Uniswap V4 provides a more customizable, flexible, and efficient automated market maker, which is unprecedented. It is expected that more DApps will take advantage of the flexibility of V4 and design optimized strategies to benefit liquidity providers or improve capital efficiency.
Welcome to join the official BlockBeats community:
Telegram Subscription Group: https://t.me/theblockbeats
Telegram Discussion Group: https://t.me/BlockBeats_App
Official Twitter Account: https://twitter.com/BlockBeatsAsia