The Evolution of Uniswap: Opportunities and Impacts of V4

LD Capital
12 min readJun 22, 2023

--

Author:Yilan,LD Capital

Uniswap V0

Uniswap V1 was launched in November 2018. However, the prototype of Uniswap had already taken shape in the previous year. In 2017, founder Hayden resigned from Siemens, and his friend Karl, who was working at the Ethereum Foundation, comforted Hayden by saying, “Mechanical engineering is a sunset industry, Ethereum is the future.” Under Karl’s guidance, Hayden learned about Ethereum and Solidity, and in November 2017 he created his Proof-of-something (Proof of concept AMM as they named it), which is Uniswap V0. This image shows what Uniswap initially looked like.

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

Uniswap V1

On November 2, 2018, the last day of Devcon 4, Uniswap’s smart contract was deployed on the Ethereum mainnet. On that day, only $30,000 in liquidity was deposited as the base liquidity for three tokens, which could only guarantee a trade depth of $100. Subsequently, uniswap.io and app.uniswap.org/# were also deployed and went live.

In September 2019, Uniswap V1 launched its first liquidity mining project, which is liquidity mining based on ERC-20 tokens. During V1, the transaction volume was relatively small, and the user scale was relatively small. As the first version of the Uniswap protocol. V1 used an Automated Market Maker (AMM) mechanism that allows users to perform permissionless token trading on the Ethereum blockchain without the need for an order book. It adopted the Constant Product model, that is, x*y=k, where x and y are the balances of the two tokens in the trading pair.

The innovative mechanism of Uniswap V1 allowed users to perform token transactions quickly and conveniently without relying on traditional centralized exchanges; it laid the foundation for subsequent versions of Uniswap and became an inspiration for other AMM protocols. However, in reality, the Uniswap V1 version did not attract many users.

Uniswap V2

Uniswap V2 was released in May 2020. At the same time, in September 2020, SushiSwap began to appear on the stage of the crypto community, attracting a large amount of attention and users, which actually made Uniswap really start to gain market attention.

The most significant change that Uniswap V2 made on the basis of Uniswap V1 is the introduction of multiple token pair trading, increasing the flexibility of trading pairs, upgrading from ERC-20 only being able to exchange with ETH to supporting ERC-20 to ERC-20 exchange. In addition, Uniswap V2 introduced a major improvement in the Time Weighted Average Price (TWAP) oracle.

The launch of Uniswap V2 consolidated Uniswap’s position in the field of decentralized trading. It provides more features and flexibility, allowing users to better manage liquidity and conduct more types of transactions. Uniswap V2 also contributed to the rapid development of decentralized finance (DeFi) by providing an important source 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 within a trading pair for more precise price control. This offers liquidity providers greater transaction fee revenue and reduces the chance for arbitrageurs to exploit price differences for trading.

Uniswap V3 also expanded 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 a single on-chain call, while reducing gas consumption by about 50% through overall TWAP optimization, and simple transactions will be about 30% cheaper than the equivalent features of V2.

Furthermore, while Uniswap V2 adopts a standard 0.3% transaction fee, V3 provides three independent fee tiers: 0.05%, 0.3%, and 1%. This allows liquidity providers to choose the pool based on the risk they are willing to bear. For the first time, V3 introduced the use of NFTs as proof of LP providing liquidity, that is, the liquidity provided is tracked by non-fungible ERC721 tokens.

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

Uniswap V4 — “Hooks” Ushering in a New Era

With the advent of the Uniswap V4 whitepaper draft, the market was awash with comprehensive interpretations. Notable highlights include Hook, Singleton, Flash Accounting, and native ETH enhancements, among which Hook represents the most significant innovation of V4. Uniswap V4’s Hook could potentially become the most potent tool for building liquidity, thereby substantially reducing the cost of setting up a DeFi platform and combining liquidity in the future.

Hooks

In simple terms, a Hook contract is a contract that calls other smart contracts, executing logic throughout the transaction lifecycle. These logical pieces can be implemented by user-defined contracts and called upon at critical moments.

More specifically, Hook contracts can be invoked at the following key points:

· onSwap: Called upon during an exchange, it can be used to implement custom logic, such as recording transaction information, executing specific operations, or modifying transaction fees, among others.

· onMint: Invoked when liquidity providers add liquidity to the pool, it can be used to implement custom logic, such as recording related information about the provided liquidity or performing certain actions.

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

Previous versions allowed developers to only customize LP and LP fees, but V4’s Hooks empower developers to innovate further on the foundation of Uniswap’s liquidity and security. It allows developers to set more custom behaviors. Uniswap Labs revealed a series of possibilities, demonstrating the unique features of the product, including:

· Time-weighted Average Market Makers (TWAMMs)

· Dynamic fees based on volatility or other numerical values

· On-chain limit orders

· Liquidity provision to lending protocols outside of ranges

· Custom on-chain Oracles, like geomean oracles

· Automatic reinvestment of LP fees into LP positions

· MEV (Miner Extractable Value) profits built-in and distributed to LPs

The Relationship Between Uniswap V4 Enhancements and Impermanent Loss (IL)

In fact, while these enhancements reinforce Uniswap’s position as a liquidity infrastructure and further amplify capital efficiency, the problem of impermanent loss (IL) due to concentrated liquidity remains prominent.

IL is an inherent issue in AMM, which occurs whenever the price of two assets deviates from the initial price. For Uniswap V3, V4’s concentrated liquidity mechanism (as well as other similar liquidity management protocols), the issue of IL can be even more severe due to the high Gamma in a narrow range, and can become more significant in some scenarios, such as in highly volatile markets or when the correlation between the liquidity-providing assets is low.

Currently, there are several ways to mitigate IL, but all of them only indirectly alleviate this issue:

· For instance, protocol token subsidies. Liquidity providers can stake these along with their liquidity. By staking these tokens, liquidity providers can earn additional rewards or compensations to offset potential temporary losses. These rewards can be provided in the form of additional tokens or a portion of the protocol’s transaction fees.

· Implement a dynamic fee structure that adjusts fees based on market conditions and the level of temporary loss experienced by liquidity providers. Charge higher fees during periods of significant temporary loss and distribute these extra fees as compensation to liquidity providers.

· The platform could establish an insurance fund to compensate liquidity providers for any losses incurred due to temporary losses. These funds are typically raised through various income sources within the protocol or contributions from the platform itself.

· Hedging mechanisms (such as options). 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. By constantly adjusting asset allocation based on price fluctuations and market conditions, this aims to optimize the exposure of liquidity providers and reduce potential losses.

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

As you can see, Uniswap V4’s dynamic fees, more optimized oracle prices, and more LP subsidies (MEV subsidies, automatic fee reinvestment, etc.) all indirectly compensate LP’s IL losses to some extent.

Regarding safety and contract complexity, Uniswap V4’s core logic, like V3’s, is non-upgradable. Although each pool can use its own Hooks smart contracts, Hooks will check whether this function needs to call an external contract. Calling an external contract enriches the features of Uniswap V4 and realizes more combinations, but only within the specific permissions determined at the time of pool creation. If the contract needs to call many external contracts, it will also bring additional Gas costs (hence simple Swaps may not be cheaper on V4 than V3/V2). This is a trade-off brought by complexity and combinability.

Singleton

In Uniswap V3, deploying separate contracts for each liquidity pool increased the cost of creating liquidity pools and executing swaps across multiple pools. In Uniswap V4, a “Singleton” contract is used to store all liquidity pools, greatly saving on Gas costs as token transactions no longer need to be transferred between different contracts. Preliminary estimates suggest that V4 has reduced the Gas costs of creating liquidity pools by up to 99%.

Flash accountingAccounting

The Fast Accounting system serves as a complement to Singleton in Uniswap V4. Instead of transferring assets in and out of liquidity pools at the end of each swap, it only transfers the net balance. This design makes the system more efficient and provides additional gas savings in Uniswap V4.

Native ETH

In previous versions, users were actually trading with WETH (Wrapped Ether) instead of ETH. Since ETH is not a token contract and WETH is, it was easier for Uniswap to integrate with ERC20 contracts. Therefore, each user swap required an extra wrapping step to turn ETH into WETH, which caused gas wastage. V4 reintroduced support for native ETH, further saving gas costs.

Potential Impact and Opportunities of Uniswap V4 on Other Tracks

1) Aggregator

For the aggregator market, Uniswap V4, with its improved rates, higher capital efficiency, and the enormous liquidity pool integrated by Singleton, is likely to attract more trading volume from the aggregator market, such as 1inch, Cowswap.

2) Customizable DEX and Similar Liquidity Customization Protocols

Onchain Limit Orders, customizable liquidity distribution, dynamic fees, etc., have an impact on existing Dex with similar features. For protocols that have LP yield enhanced vault products on Uni V3, the result seems to be foreseeable that their liquidity will be drained. They may have to join Uniswap V4 and become part of its ecosystem. For future DEX or other DeFi protocols, it may fundamentally change their liquidity building model. Uniswap V4’s Hook could become the most powerful tool for liquidity building, and the cost of building a DeFi platform and combining liquidity would be greatly reduced.

3) CEX

For centralized exchanges, due to the limit order functionality and the orthodoxy of decentralization, Uniswap V4 might be able to gain more market share from the impacted CEX. But in fact, the biggest problem that hinders users from entering DEX compared to CEX is that DEX is slower and less efficient. And many times, for most people, the initial threshold for using DEX, the contract security sacrificed for decentralization, and other risks, impose a high cost on users. In short, the inefficiency and user-unfriendliness require improvements in DeFi infrastructure, which V4 is currently unable to solve effectively. Once these two issues are solved, the path for DEX to replace CEX will become smoother.

4)MEV

When it can’t bring benefits to the core stakeholders of the platform (LP & Swapper), MEV and the protocol are opposed.

In previous versions, Uniswap V1 had no special built-in mechanisms to prevent or mitigate Miner Extractable Value (MEV), which resulted in miners or validators damaging users’ interests by manipulating the transaction order in the blockchain network for extra profits.

Uniswap V2 introduced the “price oracle” feature to help mitigate MEV. Price oracles provide reliable and tamper-resistant asset price information from an external price source. By relying on price oracles, Uniswap V2 aimed to prevent front-running attacks, where traders exploit block confirmation time delays to manipulate prices for profit.

Uniswap V3 introduced several features to mitigate MEV, including concentrated liquidity and non-fungible liquidity (NFT LP positions). Concentrated liquidity allows liquidity providers to specify a price range 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 internalized MEV allocation mechanism provides opportunities for MEV developers who want to occupy advantageous roles in V4 pools.

5) Oracles

UniswapV2’s TWAP (Time-Weighted Average Price) is an on-chain oracle that can be used to fetch the price of any token on Uniswap. Its main drawback is that it requires an off-chain program to trigger price updates regularly, leading to maintenance costs.

UniswapV3’s TWAP has addressed this issue. Triggering data storage no longer requires an off-chain program to regularly initiate but is automatically triggered when a transaction occurs on Uniswap. Regarding the data source for calculating TWAP, UniswapV2 only stored the latest price0CumulativeLast, price1CumulativeLast, and blockTimestampLast. UniswapV3, however, supports multiple Oracle Observers, allowing it to obtain price data from multiple sources. This design increases system fault tolerance and price reliability. For instance, Uniswap v3 filters different fee rate pools for the same token pair. Pools that are not empty and have the highest liquidity become the target pools. It then seeks price data from the pool with the best liquidity to serve as the price source for the oracle.

Uniswap V4’s built-in oracle will be more customizable, such as Geomean Oracles. For example, it will use different oracle price calculation methods for pools with high trading volume and stable depth (e.g., ETH-BTC) and token pairs with poor liquidity.

Regarding the impact on the oracle track, the cost of manipulating Uniswap’s TWAP oracle is controlling the average price of a token over a period of time. In contrast, the cost of manipulating Chainlink is to disrupt enough nodes and manipulate the exchange’s prices. Therefore, as Chainlink is an off-chain oracle, Uniswap V4’s built-in oracle is unlikely to pose a threat to Chainlink for now. For Uniswap’s ecosystem projects (such as lending, stable coins, synthetic assets, etc.), the participation of off-chain oracles like Chainlink is still needed.

Summary

For LPs, adding liquidity will be more customizable and convenient. For users, creating liquidity pools is cheaper, and transactions have more options. For example, using V2, V3, V4 each has its advantages. V2 has simple contracts and cheap single pool transactions; V4 is more complex but can save users a significant amount of Gas fees when multiple pools need to be called.

The continuous development of DeFi will lead to continuous optimization of liquidity management methods. For project parties, Uniswap V4’s Donate() function can help them bribe liquidity to achieve liquidity management goals. In addition, Uniswap V4’s Hook might become the most potent tool for building liquidity, significantly reducing the cost of building a DeFi platform and combining liquidity.

The future layout of DeFi will also change significantly with the appearance of V4. The V4 code is not yet finalized and audited, so it will take some time before it is officially publicly released. This is a window period for many protocols to develop their liquidity and adjust their development direction. Although V4 Hooks let the imagination of what each pool can achieve take flight and open the interface for developers and project parties to co-create based on Uniswap liquidity, there will also be problems such as the friction caused by the non-standardization of multiple pools for users in actual applications.

In general, the direction of Uniswap V4 is moving towards true DeFi infrastructure. For developers, various imaginative experiments could happen on Uniswap V4.

LD Capital is a leading crypto fund who is active in primary and secondary markets, whose sub-funds include dedicated eco fund, FoF, hedge fund and Meta Fund.

LD Capital has a professional global team with deep industrial resources, and focus on develivering superior post-investment services to enhance project value growth, and specializes in long-term value and ecosystem investment.

LD Capital has successively discovered and invested more than 300 companies in Infra/Protocol/Dapp/Privacy/Metaverse/Layer2/DeFi/DAO/GameFi fields since 2016.

--

--

LD Capital
LD Capital

Written by LD Capital

We are one of earliest VC investors in the Blockchain field in Asia. We focus on : Innovation projects within finance, games, content publishing and IOT

No responses yet