Unpacking the headline features of Uniswap's next release.
Part 1
Uniswap's V4 iteration brings about significant advancements and structural shifts aimed at tackling some of the platform's most pressing issues, including gas fees and liquidity provision. The newly introduced features and changes primarily revolve around four key areas.
1 Novel Contract Structure
Those familiar with the previous versions of Uniswap will recognize the 'factory-pool' contract architecture, an extensively employed structure in the DeFi space since its inception in Uniswap V1. However, in V4, Uniswap has decided to move away from this legacy architecture, instead adopting a Singleton contract structure. This change aims to minimize gas consumption when creating liquidity pools and making cross-pool (or contract) calls.
Furthermore, notable changes have also been made to how liquidity position data is stored and encapsulated within contracts. In V2, homogeneous liquidity tokens (ERC-20) were used as certificates of liquidity share due to the evenly distributed liquidity across the range. With the introduction of limit order liquidity in V3, ERC-20 tokens were no longer a suitable representation of the position. Instead, non-fungible tokens (ERC-721) were employed, wrapped around the liquidity Id's associated data, and managed via the 'NonfungiblePositionManager' contract.
In contrast, V4 takes a surprisingly different approach, forgoing tokenization of liquidity positions and opting to use addresses for position management instead. This new approach can be seen as a significant simplification, as it directly binds liquidity data to addresses. While this may limit the composability associated with liquidity tokens, it provides substantial improvements in gas economics and reflects a streamlined engineering approach. The V4 core contract now consists of only the 'PoolManager' contract, which handles the core business logic of the protocol. The PoolManager will undertake all liquidity computations for the protocol, indexing corresponding currency pair markets using the 'PoolKey' field. The calculations for the AMM curve and liquidity-related parameters are abstracted into library contracts. Uniswap V4's novel structure and approach to liquidity positions showcase the platform's continual innovation. Although it remains to be seen how these changes will be received by the broader DeFi community, it is clear that Uniswap is committed to advancing its technology in response to the evolving needs and challenges of the DeFi ecosystem.
2 Unique Ledger Design
In Uniswap V4's design, an innovative concept known as "Flash Accounting" stands out. In traditional liquidity protocols, every transaction and liquidity-related activity necessitates token transfers. This process typically involves: security checks, calculating the amount of tokens to be converted based on pre-established goals, updating account records, and the actual token transfer. However, V4 challenges this conventional coding paradigm by leveraging the mechanism of callback functions, leading to the creation of an innovative double-entry bookkeeping system.
In Uniswap V4, every operation updates an internal net balance referred to as "delta", which can be seen as the aforementioned "assets". Every transaction, regardless of the number of trading pairs it involves, must ensure that the delta is zero at the end, or it will be rejected. The newly introduced take() and settle() functions in V4 can be used to lend or deposit funds into the pool. Through these functions, the protocol can enforce pool settlement and payment, ensuring that there are no outstanding tokens between the PoolManager and the caller at the end of the call.
Meanwhile, the protocol introduces ERC-1155, a semi-fungible token, and tokenizes the protocol's debt. This means that when a trader or liquidity provider incurs debt in any operation, they can choose not to use the take() function, but rather the mint() function, to create corresponding ERC-1155 tokens on a 1:1 basis, thus acquiring redeemable rights certificates. Based on this rights certificate, a variety of incentives or derivative products can be created. This, in turn, implies that more liquidity will be retained in the liquidity pool, providing traders with improved liquidity depth and trading experience. The combination of this singleton contract structure and flash accounting design enables efficient routing between multiple V4 pools, thereby reducing the cost of liquidity fragmentation.
3 Hooks in Uniswap V4
Uniswap V4's Hooks are poised to become a powerful tool for liquidity construction. In the future, the cost of setting up a DeFi platform and aggregating liquidity will significantly decrease.
Put simply, Hook contracts are contracts that execute logic during the lifecycle of a transaction, used to invoke other smart contracts. These logics can be implemented by contracts defined by the user and are called upon at critical moments Specifically, Hooks contracts can be invoked at the following key points:
on Swap: Called when a swap occurs, it can be used to implement custom logic, such as recording transaction information, executing specific operations, or modifying transaction fees.
on Mint: Called when a liquidity provider adds liquidity to the pool, it can be used to implement custom logic, such as recording relevant information provided by liquidity or executing specific operations.
on Burn: Called when a liquidity provider withdraws liquidity from the pool, it can be used to implement custom logic, such as recording relevant information provided by liquidity or executing specific operations.
4 More Incentives for Liquidity Providers
One of the persistent criticisms of v3, the lack of incentives and protections for LPs, has been addressed in v4. The built-in donate() method in PoolManager allows users, external integrators, and hooks to pay fees directly to LPs within the price range with any token in the pool. This new mechanism can internalize MEV into the returns of LPs, so that LPs can benefit from MEV.
Part 2 Shadows of Other Protocols
As the leader in the DEX track, Uniswap has always been at the forefront of AMM research. However, other AMM competitors have also made their own innovations, and we can see the shadows of other protocols in the Uniswap v4 update:
For example, Uniswap v4's Singleton and Flash Accounting structure is highly consistent with Balancer v2's Vault <-> Pool logic structure, both of which use virtual ledgers to account for multiple Pools to reduce gas consumption during transaction routing.
Dynamic fees, on-chain native limit orders, and the use of ERC-1155 to embody liquidity are features that have already been implemented in the recently launched Joe v2.1.
Meanwhile, as mentioned in previous paragraph, internalizing MEV allows LPs, who were originally the opponents of bots obtaining MEV, to incorporate them into their value circulation system due to the existence of hooks. By stacking Flashbot or Eden Network and other MEV auction/distribution protocols, incentives can be redistributed to LPs who have provided effective liquidity. In this regard, although Osmosis is not a product in the EVM ecosystem, ProtoRev developed by Skip Protocol for it also has many reference points.
Part 3 Potential Impacts and Opportunities of Uniswap V4 on Other Tracks
1)Aggregator Track
From the perspective of the aggregator market, Uniswap V4 offers superior fees, higher capital efficiency, and a massive liquidity pool integrated by Singleton. This will draw more transaction volume from the fee-rolling track, i.e., the aggregator market (1inch, Cowswap).
2)Customizable DEX and Similar Liquidity Customization Protocols
Onchain Limit Orders, customized liquidity distribution, dynamic fees, etc., will likely affect existing Dex's with similar features, including LP yield enhanced vault products on Uni V3. The outcome may be that these protocols will either join or be beaten, ultimately becoming part of the Uniswap V4 ecosystem. For future DEXs or other DeFi protocols, this may fundamentally change their liquidity construction model, and Uniswap V4's Hook may become the most powerful tool for building liquidity, greatly reducing the cost of building and combining liquidity for DeFi platforms.
3)CEX
For centralized exchanges, due to the limit order function and decentralized orthodoxy, Uniswap V4 may gain more market share from the impacted CEX. However, the biggest issue hindering user entry when comparing DEX with CEX is that DEXs are not as fast and efficient as CEXs, and often, for most people, the initial threshold for using DEX and the contract security and other risks sacrificed for decentralization make users bear higher costs. In short, the inefficiency and poor user experience need to be improved and solved by DEFI infrastructure, which V4 cannot effectively solve at present. After solving these two problems, the road to DEX replacing CEX will be smoother.
4)MEV Track
In the previous versions, Uniswap V1 did not have a specific design to prevent or mitigate MEV (Miner Extractable Value), resulting in miners or validators manipulating the order of transactions in the blockchain network to get extra profits at the expense of users. Uniswap V2 introduced the "Price Oracle" feature to help mitigate MEV. Uniswap V3 introduced several features to mitigate MEV, including Concentrated Liquidity and Non-fungible Liquidity (NFT LP position). In Uniswap V4, the internalized MEV allocation mechanism presents opportunities for MEV developers wanting to occupy advantageous roles in V4 pools.
5)Oracle Track
Uniswap V4's built-in oracle will be more customizable, like Geomean Oracles, which for instance use different oracle price calculation methods for token pairs with high trading volume and stable depth (ETH- BTC) and token pairs with poor liquidity. Regarding the impact on the Oracle track, the manipulation cost of Uniswap's TWAP oracle is to control the average price of the token over a period of time. In contrast, Chainlink's manipulation cost is to destroy enough nodes and manipulate the exchange price. Therefore, Chainlink belongs to the off-chain oracle, and Uniswap V4's built-in oracle will not pose a threat to Chainlink temporarily. For Uniswap's ecosystem projects (such as lending, stablecoins, synthetic assets, etc.), the participation of off-chain oracles like Chainlink is still needed.
Conclusion
Despite the current deep bear market and tightened SEC regulations shadowing the crypto market, Uniswap's trading volume has surpassed Coinbase's for four consecutive months, demonstrating the value of excellent DeFi products amidst regulatory pressure. Unabashedly, Uniswap remains one of the greatest use cases on Ethereum. As for the future, the advent of Uniswap V4 will significantly reshape the DeFi landscape. The V4 code is yet to be finalized and audited, so it will take some time before it is officially released, providing a window period for many protocols to develop their liquidity and adjust their development direction. While the V4 Hooks unleashes the imaginative potential of each pool and opens an interface for developers and project owners to co-create on Uniswap's liquidity, it might also bring some friction for users due to the non-standardization of multiple pools. In summary, Uniswap V4 is progressing towards being a genuine infrastructure of DeFi, and it could be a playground for all sorts of imaginative experiments for developers.
resources