Author: Yilan, LD Capital Uniswap V0
Uniswap V1 was launched in November 2018. However, in fact, the prototype of Uniswapd had already 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, and Ethereum is the future." Under Karl's guidance, Hayden learned about Ethereum and Solidity, and created his Proof-of-something (Proof of concept AMM as they named it) in November 2017, which is Uniswap V0. This picture shows what Uniswap looked like at the beginning.
Before V1 was officially launched, Hayden worked on V0 using the offices of Balance and MakerDao. At the end of July 2018, Uniswap officially received the Grant from the Ethereum Foundation.
Uniswap V1
On November 2, 2018, the last day of Devcon 4, Uniswap’s smart contracts were deployed on the Ethereum mainnet. On that day, only $30,000 of liquidity was deposited as the base liquidity of the three tokens, which could only guarantee a trading depth of $100. Next, uniswap.io and app.uniswap.org/# were also deployed and launched.
In September 2019, Uniswap V1 launched the first liquidity mining project, namely liquidity mining based on ERC-20 tokens. During V1, the trading volume was relatively small and the user scale was relatively small. As the first version of the Uniswap protocol. V1 uses a mechanism based on automatic market makers (AMM) to allow users to conduct unlicensed token transactions on the Ethereum blockchain without an order book. A constant product model is adopted, that is, x*y=k, where x and y are the balances of the two tokens in the trading pair.
Uniswap V1’s innovative mechanism enables users to trade tokens 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. But in fact, Uniswap V1 did not attract many users at the time.
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 lot of attention and users, which actually made Uniswap really start to gain user market attention.
The most significant change of Uniswap V2 based on Uniswap V1 is the introduction of transactions of multiple token pairs, increasing the flexibility of trading pairs, and upgrading from ERC-20 to ETH exchange to support ERC-20 to ERC- 20 exchange. Additionally, Uniswap V2 introduces major improvements to the Time Weighted Average Price (TWAP) oracle.
The launch of Uniswap V2 consolidates Uniswap's position in the decentralized trading space. It provides more functionality and flexibility, allowing users to better manage liquidity and conduct more types of transactions. Uniswap V2 also contributes to the rapid development of decentralized finance (DeFi), providing users with an important source of liquidity.
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 transaction fee income and reduces the opportunity for arbitrageurs to trade on price differences.
Uniswap V3 also expands the oracle of Uniswap V2 and optimizes the calculation method and gas efficiency of the TWAP oracle. The V3 oracle can extend the data availability period to 9 days or more through a single on-chain call. At the same time, through the overall optimization of TWAP, the gas consumption is reduced by about 50% compared to V2. Simple transactions will be about 30% cheaper than the equivalent functions of V2.
In addition, Uniswap V2 uses a standard 0.3% transaction fee, while V3 provides 3 independent fee levels: 0.05%, 0.3% and 1%. This allows liquidity providers to choose a pool of funds based on the risk they are willing to take. V3 introduced for the first time a model of using NFT as LP to provide liquidity proof, that is, the provided liquidity is tracked by non-fungible ERC721 tokens.
The launch of Uniswap V3 has had a significant impact in the DeFi ecosystem. It provides liquidity providers with more options and better opportunities for profit while improving transaction efficiency. Uniswap V3 also promotes innovation in decentralized trading and leads other exchanges and protocols in their efforts to improve user experience and reduce transaction costs. However, passive liquidity providers have also been criticized for having their fee income space squeezed by JIT and professional market makers.
Uniswap V4 — Hooks Change Everything
As soon as the white paper draft of Uniswap V4 was released, the market gave it a full interpretation. It mainly mentioned optimizations such as Hook, Singleton, Flash Accounting and native ETH, among which Hook is the most important innovation of V4. Hook of Uniswap V4 may become the most powerful tool for building liquidity. In the future, the cost of building a DeFi platform and combining liquidity will be greatly reduced.
Hooks
In simple terms, Hooks contracts are contracts that call other smart contracts and execute logic in the transaction lifecycle. These logics can be implemented by user-defined contracts and called at critical moments.
Specifically, the Hooks contract can be called at the following key points:
onSwap: Called when a swap occurs. It can be used to implement custom logic, such as recording transaction information, performing specific operations, or modifying transaction fees.
onMint: Called when a liquidity provider adds liquidity to the pool. It can be used for custom logic, such as recording information about liquidity provision or performing specific operations.
onBurn: Called when a liquidity provider withdraws liquidity from the pool. It can be used for custom logic, such as recording information about liquidity provision or performing specific operations.
In previous versions, developers of liquidity pools could only customize LP and LP fee. 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 demonstrated the following possibilities, revealing the unique features of the product, including:
Time Weighted Average Market Maker (TWAMM)
Dynamic fees based on volatility or other values
On-chain price limit orders
Depositing out-of-scope liquidity into lending protocols
Custom on-chain oracles, such as geomean oracles
Automatically reinvest LP fees into LP positions
Built-in MEV (Miner Extractable Value) profit distribution to LPs
Uniswap V4 Optimization and the Relationship with Uncompensated Loss (IL)
In fact, these optimizations further enhance capital efficiency while strengthening the position of Uniswap’s liquidity infrastructure, but the problem of uncompensated loss (IL) of concentrated liquidity remains prominent.
IL is a concomitant problem of AMM endogeneity. As long as the prices of two assets deviate from the initial prices, IL will occur. For Uni V3, V4’s centralized liquidity mechanism (and other similar liquidity management protocols), the IL problem itself is more serious due to high Gamma in a narrow range, and may be more significant in some scenarios, such as high volatility in volatile markets or when correlations between assets providing liquidity are low.
Regarding IL, there are currently the following solutions, but they only indirectly alleviate this problem:
For example, using protocol tokens for subsidies. Liquidity providers can stake with their liquidity. By staking 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 transaction fees.
· Implement a dynamic fee structure that adjusts fees based on market conditions and temporary loss levels experienced by liquidity providers. Charge higher fees during periods when temporary losses are significant, and distribute these additional fees to liquidity providers as compensation.
Platforms can set up insurance funds to compensate liquidity providers for any losses incurred due to temporary losses. These funds are usually raised through various revenue sources within the protocol or through 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 Oracles and Time-Weighted Average Price (TWAP): Price oracles and TWAP-based pricing mechanisms can be used to reduce the impact of sudden 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.
It can be seen that Uniswap V4's dynamic transaction fees, more optimized oracle prices, and more LP subsidies (MEV subsidies, automatic reinvestment fees, etc.) all indirectly compensate LP's IL losses to some extent.
Regarding security and contract complexity, the core logic of Uniswap V4 is not upgradeable, just like V3. Although each pool can use its own Hooks smart contract, Hooks will check whether this part of the function requires an external contract call. Calling external contracts enriches the functionality of Uniswap V4 and enables more combination possibilities, but it is limited to specific permissions determined when the pool is created. If a contract needs to call too many external contracts, it will also bring additional Gas fees (so a simple Swap may not be cheaper in V4 than in V3/V2), which is also a tradeoff caused by complexity and combinability.
Singleton
In Uniswap V3, deploying a separate contract for each liquidity pool increased the cost of creating liquidity pools and performing swaps across multiple pools. In Uniswap V4, a "Singleton" contract is used to save all liquidity pools, which greatly saves gas fees because token transactions no longer need to be transferred between different contracts. Preliminary estimates show that V4 reduces the gas fee for creating liquidity pools by up to 99%.
Flash accounting
The fast accounting system complements Singleton. In V4, the system no longer transfers assets in and out of the liquidity pool at the end of each exchange, but only transfers on the net balance. This design makes the system more efficient and can provide additional gas savings in Uniswap V4.
Native ETH
In previous versions, users were actually trading with WETH. ETH is not a token contract, but WETH is a token contract. ERC20 contract is easier to integrate for Uniswap, so each time a user swaps, they need to pack ETH once more to convert 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
From the perspective of the aggregator market, Uniswap V4 provides better fees, higher capital efficiency, and a huge liquidity pool integrated by Singleton, which will attract more trading volume from the fee-carrying track, namely the aggregator market (1inch, Cowswap).
2) Customized DEX and similar liquidity customization function protocols
The impact of onchain limit orders, customized liquidity distribution, dynamic rates, etc. on existing Dex with similar functions, including the withdrawal of liquidity of LP yield enhanced vault product protocols on Uni V3, seems to be a foreseeable result. These protocols may face the situation of joining if they can't beat them, and eventually become part of the Uniswap V4 ecosystem. For future DEX or other DeFi protocols, their liquidity building model may be fundamentally changed. The Hook of Uniswap V4 may become the most powerful tool for liquidity building, and the cost of building a DeFi platform and combining liquidity will be greatly reduced.
3) CEX
For centralized exchanges, Uniswap V4 may be able to gain more market share from the hit CEX due to the price limit function and the orthodoxy of decentralization. But in fact, compared with CEX, the biggest problem that hinders users from entering DEX is that the speed and efficiency are not as good as CEX, and in many cases, for most people, the initial threshold of using DEX and the contract security and other risks sacrificed for decentralization require users to bear relatively high costs. In short, low efficiency and poor usability require the DEFI infrastructure to be improved and solved, which the V4 version cannot effectively solve at present. After solving these two problems, the road for DEX to replace CEX will be smoother.
4) MEV track
When it fails to bring benefits to the core Stakeholders (LP & Swapper) of the platform, MEV and the protocol are in opposition.
In the previous few versions, Uniswap V1 did not have a built-in mechanism specifically designed to prevent or mitigate MEV (miner extractable value), which resulted in miners or validators gaining extra profits by manipulating the order of transactions in the blockchain network at the expense of user interests.
Uniswap V2 introduces a "price oracle" feature to help mitigate MEV. Price oracles are external price sources that provide reliable and tamper-proof asset price information. By relying on price oracles, Uniswap V2 aims to prevent front-running attacks, in which traders take advantage of time delays in block confirmations to manipulate prices for profit.
Uniswap V3 introduces several features to mitigate MEV, including the concepts of centralized liquidity and non-fungible liquidity (NFT LP positions). Centralized 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-grained control over their liquidity, reducing the risk of being squeezed or exploited by arbitrageurs.
In Uniswap V4, the internalized MEV allocation mechanism presents opportunities for MEV developers who want to occupy an advantageous role in the V4 pool.
5) Oracle Track
UniswapV2's TWAP is an on-chain oracle that can be used to obtain the price of any existing token on Uniswap. Its main drawback is that it requires an off-chain program to trigger price updates at regular intervals, which incurs maintenance costs.
UniswapV3's TWAP solves this defect problem. The storage of trigger data no longer requires off-chain programs to trigger it regularly, but is automatically triggered when a transaction occurs in Uniswap. In terms of the data source for calculating TWAP, UniswapV2 only stores the latest three values: price0CumulativeLast, price1CumulativeLast, and blockTimestampLast. UniswapV3 supports multiple price observers (Oracle Observers) and can obtain price data from multiple sources. This design increases the system's fault tolerance and price reliability. For example, Uniswap v3 screens pools with different handling fee rates for the same currency pair. The pool that is not empty and has the highest liquidity becomes the target pool, and the price data is found in the pool with the best liquidity as the price source of the oracle.
Uniswap V4’s built-in oracles will be more customized, such as Geomean Oracles, which use different oracle price calculation methods for pools with large trading volumes, deep stability (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, the manipulation cost of Chainlink is to destroy enough nodes and manipulate the price of the exchange. Therefore, Chainlink belongs to the off-chain oracle, and Uniswap V4's built-in oracle will not pose a threat to Chainlink for the time being. For Uniswap's ecological projects (such as lending, stablecoins, synthetic assets, etc.), the participation of off-chain oracles similar to Chainlink is still needed.
Summarize
In general, Uniswap V4 is moving towards the real infrastructure of DeFi, and imaginative experiments for developers can take place on Uniswap V4.
For LPs, adding liquidity will be more customized and convenient. For users, creating trading pools is cheaper and trading has more options. For example, using V2, V3, and V4 each has its own advantages. V2 has a simple contract and a single pool has cheap transactions; V4 has a complex structure, but it can help users save a lot of gas fees when multiple pools need to be called.
The continued development of DeFi will lead to the continuous optimization of liquidity management methods. For project parties, the Uniswap V4 Donate() function can help project parties bribe liquidity to achieve the goal of liquidity management. In addition, the Hook of Uniswap V4 may become the most powerful tool for liquidity construction, and the cost of building a DeFi platform and combining liquidity will be greatly reduced.
The future DeFi landscape will also change greatly due to the emergence of V4. The V4 code has not yet been finalized and reviewed, so it will take some time before it is officially released to the public. This is a window period for many protocols to develop their own liquidity and adjust their development direction.
