Deep Dive into Uniswap V4: A “Masterpiece” of Decentralized Exchange

Exploring Uniswap V4: A Masterpiece of Decentralized Exchange

Author: Jiang Haibo, BlockingNews

With the tightening of regulations in the United States, and centralised exchanges (CEX) such as Binance and Coinbase facing SEC crackdowns and market makers withdrawing from the US market, decentralised exchanges (DEX) are becoming increasingly important.

On June 13, Uniswap announced the upcoming release of Uniswap V4 and publicly released a draft version of the whitepaper. BlockingNews has analysed the whitepaper and updates to Uniswap V4.

Uniswap’s Evolution from V1 to V4

Since its launch in 2018, Uniswap has undergone multiple updates. Uniswap V1 introduced the constant product market maker model, supporting permissionless token exchange; Uniswap V2 added ERC-20/ERC-20 trading pairs (V1 only supported ERC-20/ETH trading pairs); Uniswap V3 introduced “concentrated liquidity” and allowed market makers to choose their own fee tier (V2 was fixed at 0.3%), greatly improving capital utilisation.

Uniswap V4, which is the subject of this update, is still a permissionless, trustless, upgradable AMM protocol that is based on Uniswap V3’s concentrated liquidity model. It updates the Hooks feature, Singleton contract, flash accounts, supports native ETH, supports ERC-1155 accounts, adds governance functionality and a donate() feature, thereby improving Uniswap’s flexibility and composability, and greatly reducing the gas fees required to provide liquidity and trade.

Details and Implications of the V4 Update

Implement TWAMM, limit orders, dynamic fees, internal MEV mechanism, custom oracles, etc. through hooks

In computing, a hook is a program that handles system messages by attaching itself to the system via a system call.

Uniswap V4’s hooks allow integrators to create more flexible and customisable concentrated liquidity pools. Hooks can modify pool parameters or add new features and capabilities, enabling functions including the weighted average market maker (TWAMM), limit orders, dynamic fees, internal MEV mechanism, storing excess liquidity in lending protocols, custom oracles and more, all of which can be dynamically managed by the hook contract.

Developers can build various DApps based on Uniswap’s hooks, which will make Uniswap V4 more feature-rich. The hook contract can also allocate a portion of the transaction fee to itself. However, users should also be more cautious in using it, as it may bring new challenges and risk management needs.

Replacing Factory Contract with Singleton Contract

Uniswap V4 made significant changes to its architecture by replacing the Factory/Pool pattern with a Singleton pattern. In the previous version, each liquidity pool was deployed independently through the Factory contract. This meant that in a multi-step transaction, multiple contracts would be involved (e.g. converting ETH to DAI might involve the ETH-USDC and USDC-DAI liquidity pool contracts).

In the new Singleton contract, all liquidity pools are contained within a single contract, allowing for a single contract interaction to complete the multi-step transaction, reducing gas fees.

Flash Accounting Significantly Reduces Gas Fees after the Cancun Upgrade

Flash Accounting is another architectural change. In previous versions of Uniswap, every step of an operation transferred tokens. In Uniswap V4, each operation updates an “internal net balance” and only performs an external transfer at the end, simplifying the complexity of multi-step transactions, adding liquidity, and atomic transactions, and reducing gas fees.

The next Cancun upgrade on Ethereum is confirmed to include EIP-1153, which introduces “transient” storage that does not require Flash Accounting to update storage on every balance change, further reducing gas fees.

Reintroduction of Native ETH Support

Uniswap V1 only supported ERC20/ETH transactions. Uniswap V2 removed this limitation, but due to concerns about code complexity and fragmentation of liquidity between WETH/ETH, Uniswap V2 and V3 wrap ETH into WETH before trading, and the transfer fees for WETH are higher than those for native ETH, resulting in additional gas fees.

Singleton and Flash Accounting have addressed liquidity complexity concerns through the redesign of the architecture, and Uniswap V4 will reintroduce support for native ETH to reduce gas fees.

Support for ERC-1155 Tokens

Uniswap V4 will support the minting and burning of ERC-1155 tokens (with values passed as arrays, only transferFrom, and no transfer), enabling users to hold tokens in Singleton without the need to transfer ERC-20 tokens in and out, which is valuable for liquidity providers and traders who operate frequently.

Addition of Governance Mechanism

Uniswap V4 adds a new governance mechanism that allows for fees to be charged on trades and withdrawals (funds taken out of liquidity pools) and allows the governance system to allocate these fees as rewards to users and developers who contribute to Uniswap.

This feature may have an effect on hook contracts, such as allowing the developer of a hook contract to charge a fee for LP. However, referring to Uniswap’s slow progress in charging for transactions, if the protocol charges for this, it may first charge the developer’s income, which is relatively low compared to the value of UNI tokens held by users.

donate() function

Uniswap V4 introduces a new donate() function, which allows others to pay liquidity providers within the trading range. This feature may be helpful for project parties and liquidity incentives in TWAMM orders.

The update of Uniswap V4 is significant for Uniswap itself. The introduction of hooks will greatly improve the flexibility of the protocol, and the support for Singleton contracts, instant accounts, ERC-1155 accounts, and native ETH will also help reduce Gas fees. The high Gas fees are currently affecting the use of Uniswap, and it is expected that Uniswap V4 will reduce the Gas cost of creating liquidity pools by 99%, which will further enhance Uniswap’s position in DEX.

Learn from others and adopt features already implemented in other DEX

Some of the features of this update have already been implemented in some existing DEXs. Uniswap v4 is also published under the BSL license, which is criticized for this.

For example, with the architecture adjustment of Singleton contracts and instant accounts, Balancer V2 has already used a single Vault to manage all assets in liquidity pools. In cross-liquidity pool transactions, Balancer V2 also directly transfers the final Token amount, saving Gas fees. Due to the various liquidity pools that will be brought by the hook function, the adjustment of accounts is more important in Uniswap V4. The creator of the hook contract can assign fees, which is similar to Balancer allowing liquidity pool creators to charge fees.

TWAMM implemented through hooks is also being built by multiple projects with similar solutions, such as Pulsar, Integral, etc. Since this function is precisely the characteristic of these projects, the update of the more strongly branded Uniswap may directly make these projects lose competitiveness.

Summary

The Uniswap V4 update may significantly improve Uniswap’s competitiveness, enabling functions such as TWAMM, limit orders, dynamic fees, depositing liquidity into lending protocols, and automatic fee reinvestment. The required Gas fees for liquidity providers and traders can also be greatly reduced due to the new architecture. Although some functions have already been implemented in DEXs such as Balancer and Integral, Uniswap’s brand effect may promote and enhance these functions as a comprehensive platform.

For the fee adjustment that UNI holders are expecting, although Uniswap V4 allows governance to extract transaction fees and redemption fees, the priority allocation target may also correspond to the developers. Considering the difficulty of charging fees to liquidity providers, if only a small portion of the fee is charged to developers, the value will not be too high.

We will continue to update Blocking; if you have any questions or suggestions, please contact us!

Share:

Was this article helpful?

93 out of 132 found this helpful

Discover more

Blockchain

Cardano (ADA) Price Breakout: History May Repeat Itself 🚀📈

According to an analyst, Cardano's price has the potential to surpass $8 based on historical patterns. This suggests ...

Blockchain

Big Updates, Big Things In Store: Cardano Soars with Bullish Momentum 🚀

A recent Essential Cardano report highlights the latest advancements from Input Output Global (IOG) in the ecosystem,...

Market

Analysis and Commentary: The Fate of Bitcoin ETFs and Cryptocurrency Performance

After a period of significant growth in the crypto market, traders were briefly shaken by a report causing a halt in ...

Blockchain

Cardano (ADA) Faces Price Dip Amid Crypto Sell-Off and Macro Headwinds

On Wednesday, Cardano (ADA) experienced a decrease of 7.5% in value. This cryptocurrency is the driving force behind ...

Blockchain

UAE adopts Cardano Blockchain to boost security in criminal investigations.

The UAE has taken the significant step of implementing Cardano's blockchain technology to enhance security in crimina...

Blockchain

Webster's rating is constantly changing, asserting that Cardano is far stronger than EOS

Source: Shallot blockchain Weiss Ratings, a cryptocurrency rating agency, recently said that Cardano (ADA) is far str...