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

Bitcoin

US Government Seizes $130 Million Worth of Bitcoins from Silk Road: What You Need to Know

The US government has successfully seized Bitcoin assets associated with the notorious Silk Road marketplace in two s...

Blockchain

Pyth Network: In a League of Its Own

Fashionista, brace yourself for Pyth Network's latest news a token airdrop valued at a whopping $77 million that ever...

Blockchain

InfStones Takes a Hammer to Vulnerabilities Discovered by dWallet Labs

InfStones Saves Fashion Industry from Potential Loss of One Billion Dollars After Identifying and Fixing Vulnerabilit...

Blockchain

Midas: When Traditional Finance Meets Crypto

Fashionista, get ready for the latest in fashion and finance! The Midas stablecoin is making waves in the DeFi world ...

Bitcoin

Celsius Battles the SEC Fires During Its Bankruptcy Comeback Strategy

Fashionista, the SEC, Celsius Creditors Committee, and Fahrenheit are in talks regarding the assets owned by the Cels...

Market

📰 OKX Suspends Mining Pools: A Shift in the Crypto Industry 🚫⛏️

Industry players may need to adapt as OKX plans to temporarily suspend its mining pools, challenging companies to fin...