Uniswap Evolution: A Thousand Miles Journey, Opportunities and Impact of V4

Author: Yilan, LD Capital

Uniswap V0

Uniswap V1 was launched in November 2018. However, in fact, the embryo of Uniswap had been formed in the previous year. In 2017, founder Hayden resigned from Siemens and his friend Karl, who worked at the Ethereum Foundation, comforted Hayden, “Mechanical engineering is a sunset industry, Ethereum is the future.” Guided by Karl, Hayden learned about Ethereum and Solidity, and in November 2017, created his Proof-of-something (Proof of concept AMM as they named it), which is Uniswap V0. This picture shows what Uniswap looked like at the very beginning.

Before V1 was officially launched, Hayden was working on V0 in the Balance and MakerDao offices. At the end of July 2018, Uniswap officially received a grant from the Ethereum Foundation.

Uniswap V1

On November 2, 2018, the Uniswap smart contract was deployed on the Ethereum mainnet, on the last day of Devcon 4. Only $30,000 of liquidity was deposited as the basic liquidity of three tokens, which could only guarantee a trading depth of $100. Next, uniswap.io and app.uniswap.org/# were also deployed online.

In September 2019, the first liquidity mining project based on ERC-20 tokens was launched on Uniswap V1. During V1, the trading volume and user base were relatively small. As the first version of the Uniswap protocol, V1 used a mechanism based on an automatic market maker (AMM), allowing users to trade tokens without an order book on the Ethereum blockchain. It adopts a constant product model, x*y=k, where x and y are the balances of the two tokens in the trading pair.

The innovative mechanism of Uniswap V1 enables users to quickly and conveniently trade tokens without relying on traditional centralized exchanges, laying the foundation for subsequent versions of Uniswap and becoming an inspiration for other AMM protocols. However, in fact, the Uniswap V1 version at that time did not attract many users.

Uniswap V2

Uniswap V2 was released in May 2020. Meanwhile, in September 2020, SushiSwap began to appear on the crypto community stage, attracting a lot of attention and users, which actually made Uniswap truly begin to attract user market attention.

The most significant change of Uniswap V2 on the basis of Uniswap V1 is the introduction of transactions with multiple token pairs, increasing the flexibility of trading pairs, and upgrading from ERC-20 to ETH exchanges to support ERC-20 to ERC-20 exchanges. In addition, Uniswap V2 introduced significant improvements to the time-weighted average price (TWAP) oracle.

The launch of Uniswap V2 consolidated Uniswap’s position in the decentralized trading field. It provides more features and flexibility, enabling users to better manage liquidity and conduct more types of transactions. Uniswap V2 has also made contributions to the rapid development of decentralized finance (DeFi) by providing important sources of liquidity for users.

Uniswap V3

Uniswap V3 was launched in May 2021, introducing the concept of “Concentrated Liquidity.” It allows liquidity providers to define specific price ranges in trading pairs to achieve more precise price control. This provides liquidity providers with greater trading fee revenue and reduces the opportunity for arbitrageurs to trade on price differentials.

Uniswap V3 also extends the Uniswap V2 oracle, optimizing the calculation method and gas efficiency of the TWAP oracle. The V3 oracle can extend the data availability period to 9 days or longer through one on-chain call, and reduces about 50% of the gas consumption compared to V2 through overall optimization of TWAP. Simple trades will be about 30% cheaper than V2 for the same functionality.

In addition, Uniswap V2 uses a standard 0.3% transaction fee, while V3 offers three independent fee levels: 0.05%, 0.3%, and 1%. This allows liquidity providers to choose the funding pool based on the risk they are willing to take. V3 introduces the use of NFTs as LPs to provide liquidity proof for the first time, that is, the provided liquidity is tracked by non-fungible ERC721 tokens.

The launch of Uniswap V3 has had a significant impact on the DeFi ecosystem. It provides liquidity providers with more choices and better revenue opportunities, while also improving transaction efficiency. Uniswap V3 also drives innovation in decentralized trading and leads other exchanges and protocols’ efforts to improve user experience and reduce transaction costs. However, passive liquidity providers have complained about being squeezed out of fee revenue by JIT and professional market makers.

Uniswap V4 — Hooks change everything

When the white paper for Uniswap V4 was released, the market gave it a thorough interpretation. The main innovation of V4, which includes Hook, Singleton, Flash Accounting, and native ETH, is the Hook. Uniswap V4’s Hook may become the most powerful tool for liquidity construction, and in the future, the cost of building a DeFi platform and combining liquidity will be greatly reduced.

Hooks

The Hooks contract, simply put, is a contract that calls other smart contracts. It executes logic during the transaction lifecycle. This logic can be implemented by user-defined contracts and called at critical moments.

Specifically, Hooks contracts can be called at the following key points:

· onSwap: Called when the exchange occurs, it can be used to implement custom logic, such as recording transaction information, executing specific operations, or modifying transaction fees.

· onMint: Called when liquidity providers add liquidity to the pool, it can be used to implement custom logic, such as recording relevant information about liquidity providers or executing specific operations.

· onBurn: Called when liquidity providers withdraw liquidity from the pool, it can be used to implement custom logic, such as recording relevant information about liquidity providers or executing specific operations.

Previously, the liquidity pool developers could only customize LP and LP fees, but V4 Hooks allows developers to innovate more on the basis of Uniswap’s liquidity and security, allowing developers to set more customized behaviors. Uniswap Labs has demonstrated a series of possibilities, revealing the unique features of the product, including:

· Time-Weighted Average Market Maker (TWAMM)

· Dynamic fees based on volatility or other metrics

· On-chain limit orders

· Depositing liquidity outside the range into lending protocols

· Custom on-chain Oracle, such as geomean oracles

· Automatically reinvest LP fees into LP positions

· Built-in MEV (Miner Extractable Value) profit distribution to LP

The relationship between Uniswap V4’s optimization and impermanent loss (IL)

In fact, these optimizations further strengthen the capital efficiency while strengthening the position of Uniswap liquidity infrastructure. However, the problem of impermanent loss (IL) caused by concentrated liquidity is still prominent.

Impermanent loss (IL) is an endogenous problem with AMM, which occurs whenever there is a deviation in the price of the two assets relative to their initial price. For centralized liquidity mechanisms like Uni V3, V4 (and other similar liquidity management protocols), the IL problem itself is exacerbated by the high Gamma in narrow ranges, and may be more pronounced in certain scenarios, such as in high-volatility markets or when there is low correlation between the assets providing liquidity.

There are currently the following ways to address the IL problem, but they only indirectly alleviate it:

· For example, subsidies using protocol tokens. Liquidity providers can collateralize these tokens along with their liquidity. By collateralizing these tokens, liquidity providers can receive additional rewards or compensation to offset potential temporary losses. These rewards can be provided in the form of additional tokens or a portion of the protocol trading fee.

· Implementing dynamic fee structures that adjust fees based on market conditions and the level of temporary losses experienced by liquidity providers. Charge higher fees during periods of significant temporary loss and distribute these additional fees as compensation to liquidity providers.

· Platforms can establish insurance funds to compensate liquidity providers for any losses suffered due to temporary losses. These funds are typically raised through various income sources within the protocol or contributions from the platform itself.

· Hedging mechanisms (options, etc.), where liquidity providers can participate in derivative contracts or use other financial instruments to hedge their exposure to price fluctuations and mitigate the impact of temporary losses.

· Dynamic asset rebalancing, which aims to optimize liquidity providers’ exposure and reduce potential losses by continuously adjusting asset allocation based on price fluctuations and market conditions.

· Price oracle and time-weighted average price (TWAP): Price oracles and TWAP-based pricing mechanisms can be used to reduce the impact of price volatility on liquidity providers. By relying on more stable and reliable price data, liquidity providers can better understand market conditions and adjust their positions accordingly.

It can be seen that Uniswap V4’s dynamic fees, more optimized oracle prices, and more LP subsidies (MEV subsidies, automatic reinvestment of fees, etc.) all indirectly compensate for LP’s IL losses to some extent.

Regarding security and contract complexity, the core logic of Uniswap V4 is the same as V3 and is not upgradable. Although each pool can use its own Hooks smart contract, Hooks will check whether this part of the function needs to be called by an external contract, which enriches Uniswap V4’s functions and enables more combination possibilities, but only within specific permissions determined when the pool is created. If too many external contracts need to be called by the contract, additional gas fees will be incurred (so simple swaps may not be cheaper than V3/V2), which is a trade-off between complexity and combination.

Singleton

In Uniswap V3, deploying a separate contract for each liquidity pool added costs to creating liquidity pools and executing exchanges across multiple pools. In Uniswap V4, a “Singleton” contract is used to hold all liquidity pools, which greatly reduces gas fees because token trades no longer need to be transferred between different contracts. Preliminary estimates suggest that V4 reduces gas fees for creating liquidity pools by up to 99%.

Flash accounting

A rapid accounting system as a supplement to Singleton. In V4, this system no longer transfers assets in and out of liquidity pools at the end of each exchange, but only on the net balance. This design makes the system more efficient and allows for additional gas savings in Uniswap V4.

Native ETH

In previous versions, users actually traded with WETH, and ETH was not a Token Contract while WETH was a Token Contract. For Uniswap, ERC20 contracts are easier to integrate, so each time a user swaps, they need to package ETH into WETH, which causes gas waste. V4 restores support for native ETH, further saving gas costs.

Uniswap V4’s Potential Impact and Opportunities on Other Tracks

1) Aggregator Track

In terms of aggregator market, Uniswap V4 provides better rates, higher capital efficiency, and a huge liquidity pool with Singleton integration, which will attract more trading volume from the aggregator market (1inch, Cowswap) focusing on the trading volume.

2) Customized DEX and similar liquidity customization function protocols

The impact of Onchain Limit Orders, customized liquidity distribution, dynamic fees and other similar functions on existing Dex, including the flow of liquidity-enhanced vault product protocols on Uni V3 being drawn away, seems to be a predictable result, and these protocols may face the situation of joining if they cannot beat Uniswap V4, ultimately becoming part of the Uniswap V4 ecosystem. For future Dex or other DeFi protocols, perhaps the liquidity building mode will be fundamentally changed, and Uniswap V4’s Hook may become the most powerful tool for liquidity building, greatly reducing the cost of building DeFi platforms and combining liquidity.

3) CEX

For centralized exchanges, Uniswap V4 may gain more market share from the battered CEX due to limit functions and decentralization legitimacy. However, in fact, the biggest problem that impedes users from entering DEX compared to CEX is that its speed and efficiency are inferior to CEX, and many times, for most people, the early threshold for using DEX and the contract security and other risks sacrificed for decentralization require users to bear relatively high costs. In short, low efficiency and usability need to be improved and solved by DeFi infrastructure, which cannot be effectively solved by V4 version at present. The path for DEX to replace CEX will be smoother after these two problems are solved.

4) MEV Track

MEV and protocols are at odds when they cannot bring benefits to the platform’s core stakeholders (LP&Swapper).

In previous versions, Uniswap V1 did not have built-in mechanisms specifically designed to prevent or mitigate MEV (miner-extractable value), which allowed miners or validators to manipulate the order of transactions in the blockchain network to gain extra profits at the expense of user interests.

Uniswap V2 introduced the “Price Oracle” feature to help mitigate MEV. The price oracle is an external price source that provides reliable and tamper-proof asset price information. By relying on the price oracle, Uniswap V2 aims to prevent front-running attacks, where traders manipulate prices to profit from time delays in block confirmations.

Uniswap V3 introduced several features to mitigate MEV, including the concepts of concentrated liquidity and non-fungible liquidity (NFT LP positions). Concentrated liquidity allows liquidity providers to specify price ranges for their liquidity, reducing the risk of price manipulation. Non-fungible liquidity positions give liquidity providers fine control over their liquidity, reducing the risk of being squeezed or exploited by arbitrageurs.

In Uniswap V4, the internal MEV allocation mechanism presents opportunities for MEV developers who want to occupy advantageous roles in V4 pools.

5) Oracle Track

UniswapV2’s TWAP is an on-chain oracle that can be used to obtain the price of any token already on Uniswap, with the main drawback being the need for off-chain programs to trigger price updates at regular intervals, which incurs maintenance costs.

UniswapV3’s TWAP solves this problem by eliminating the need for off-chain programs to trigger data storage updates, instead automatically triggering them when trades occur on Uniswap. In terms of calculating TWAP data sources, UniswapV2 only stores the latest price0CumulativeLast, price1CumulativeLast, and blockTimestampLast values. UniswapV3 supports multiple price observers (Oracle Observers), which can obtain price data from multiple sources. This design increases system fault tolerance and price reliability. For example, Uniswap v3 selects different fee-rate pools for the same currency pair, and the pool with non-zero liquidity and the highest liquidity becomes the target pool, where it finds price data in the pool with the best liquidity as the price source for the oracle.

Uniswap V4’s built-in oracle will be more customized, such as Geomean Oracles, which use different oracle price calculation methods for large-volume, deep-stable currency pairs (ETH-BTC) and tokens with poor liquidity like Blockingir.

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, the manipulation cost of Chainlink is to destroy enough nodes and manipulate the price of exchanges. Therefore, Chainlink belongs to the off-chain oracle, and the built-in oracle of Uniswap V4 will not pose a threat to Chainlink for the time being. For Uniswap’s ecological projects (such as lending, stablecoins, synthetic assets, etc.), participation of off-chain oracles similar to Chainlink is still needed.

Summary

Overall, the direction of Uniswap V4 is moving towards the true infrastructure of DeFi, and imaginative experiments can happen on Uniswap V4 for developers.

For LPs, adding liquidity will be more customized and convenient. For users, creating transaction pools will be cheaper, and there will be more options. For example, using V2, V3, and V4 each has its advantages. V2 has simple contracts and cheap transactions for single pools; V4 has complex structures, but can help users save a lot of gas fees when multiple pools need to be called.

The continuous development of DeFi will lead to the continuous optimization of liquidity management methods. For project parties, Uniswap V4’s Donate() function can help project parties bribe liquidity to achieve liquidity management goals. In addition, Uniswap V4’s Hook may become the most powerful tool for constructing liquidity, and the cost of building DeFi platforms and combining liquidity will be greatly reduced.

The future DeFi landscape will also undergo significant changes due to the appearance of V4. The V4 code has not yet been finalized and audited, so there is still some time before it is officially released, which is a window period for many protocols to develop their own liquidity and adjust their development directions.

Like what you're reading? Subscribe to our top stories.

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

Follow us on Twitter, Facebook, YouTube, and TikTok.

Share:

Was this article helpful?

93 out of 132 found this helpful

Gambling Chain Logo
Industry
Digital Asset Investment
Location
Real world, Metaverse and Network.
Goals
Build Daos that bring Decentralized finance to more and more persons Who love Web3.
Type
Website and other Media Daos

Products used

GC Wallet

Send targeted currencies to the right people at the right time.