🎉 #Gate xStocks Trading Share# Posting Event Is Ongoing!
📝 Share your trading experience on Gate Square to unlock $1,000 rewards!
🎁 5 top Square creators * $100 Futures Voucher
🎉 Share your post on X – Top 10 posts by views * extra $50
How to Participate:
1️⃣ Follow Gate_Square
2️⃣ Make an original post (at least 20 words) with #Gate xStocks Trading Share#
3️⃣ If you share on Twitter, submit post link here: https://www.gate.com/questionnaire/6854
Note: You may submit the form multiple times. More posts, higher chances to win!
📅 End at: July 9, 16:00 UTC
Show off your trading on Gate Squ
Uniswap Evolution History: Opportunities and Impacts of V4
Original author: Yilan, LD Capital
Uniswap V0
Uniswap V1 was launched in November 2018. However, in fact, in the previous year, the prototype of Uniswapd has been formed. In 2017, the founder Hayden resigned from Siemens. Karl, a friend working at the Ethereum Foundation, comforted Hayden, "Mechanical engineering is a sunset industry, and Ethereum is the future." Under the guidance of Karl, Hayden learned about Ethereum and Solidity, 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 looked like from the very beginning.
Before the official launch of V1, Hayden used Balance and MakerDao's office to work on V0. 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 to the Ethereum mainnet. On that day, only $30,000 of liquidity was deposited as the basic liquidity of the three tokens, which can only guarantee a transaction 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, that is, liquidity mining based on ERC-20 tokens. During the V1 period, the transaction volume was relatively small, and the user scale was relatively small. As the first version of the Uniswap protocol. V1 uses an Automated Market Maker (AMM) based mechanism that allows users to trade permissionless tokens on the Ethereum blockchain without an order book. A constant product model is adopted, ie x*y=k, where x and y are the balances of the two tokens in the transaction pair.
The innovative mechanism of Uniswap V1 enables users to conduct 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. But in fact, the Uniswap V1 version at that time did not attract many users.
Uniswap V2
In May 2020, Uniswap V2 was released. At the same time, in September 2020, SushiSwap began to appear on the stage of the encryption community, attracting a lot of attention and users, which actually made Uniswap really start to gain the attention of the user market.
The most significant change of Uniswap V2 on the basis of Uniswap V1 is the introduction of multiple token pair transactions, increasing the flexibility of transaction pairs, and upgrading from ERC-20 that can only be exchanged with ETH to support ERC-20 to ERC-20 exchange. Additionally, significant improvements to the time-weighted average price (TWAP) oracle introduced with Uniswap V2.
The launch of Uniswap V2 has consolidated Uniswap's position in the field of decentralized exchanges. It provides more functions and flexibility, allowing users to better manage liquidity and conduct more types of transactions. Uniswap V2 has also contributed 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 within trading pairs for more precise price control. This provides liquidity providers with greater transaction fee gains and reduces opportunities for arbitrageurs to take advantage of 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 machine can extend the data availability period to 9 days or longer through a 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 equivalent to those of V2. Features are about 30% cheaper.
Additionally, Uniswap V2 uses the standard 0.3% transaction fee, while V3 offers 3 separate fee tiers: 0.05%, 0.3%, and 1%. This allows liquidity providers to select pools based on the risk they are willing to take. V3 introduced the model of using NFT as LP to provide proof of liquidity for the first time, that is, the provided liquidity is tracked by non-homogeneous ERC 721 tokens.
The launch of Uniswap V3 has had a major impact in the DeFi ecosystem. It provides liquidity providers with more choices and better income opportunities, while improving transaction efficiency. Uniswap V3 also drives innovation in decentralized exchanges and leads the efforts of other exchanges and protocols to improve user experience and reduce transaction costs. But at the same time, passive liquidity providers have been criticized for being squeezed out by JIT and professional market makers to earn income from handling fees.
Uniswap V4 — Hooks change everything
Once the white paper draft of Uniswap V4 was launched, the market fully interpreted it. It mainly mentions optimizations such as Hook, Singleton, Flash Accounting and native ETH, among which Hook is the most important innovation of V4. The Hook of Uniswap V4 may become the most powerful tool for liquidity construction. In the future, the cost of building a DeFi platform and combining liquidity will be greatly reduced.
Hooks
In simple terms, the Hooks contract is a contract that calls other smart contracts, and the logic executed in the transaction life cycle. 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 the exchange occurs, it can be used to implement custom logic, such as recording transaction information, performing specific operations or modifying transaction fees, etc.
· onMint: Called when the liquidity provider adds liquidity to the pool, it can be used for custom logic, such as recording relevant information provided by liquidity or performing specific operations.
· onBurn: Called when the liquidity provider withdraws liquidity from the pool, it can be used for custom logic, such as recording relevant information provided by liquidity or performing specific operations.
The previous version of liquidity pool developers can only customize LP and LP fee, and V4 Hooks allows developers to make more innovations based on Uniswap's liquidity and security, allowing developers to set more custom behaviors, Uniswap Labs showcased the following range of possibilities, revealing unique characteristics of the product, including:
The relationship between Uniswap V4 optimization and unpaid 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 centralized liquidity is still prominent.
IL is an endogenous adjunct problem of AMM, as long as the two asset prices deviate from the initial price, IL will be generated. For the centralized liquidity mechanism of Uni V3, V4 (and other similar liquidity management protocols), the IL problem itself is more serious due to the high Gamma in a narrow range, which may be more significant in some scenarios, such as high volatility market or when the correlation between assets providing liquidity is low.
About IL, there are currently the following solutions, but they are only indirectly alleviating this problem:
It can be seen that Uniswap V4's dynamic handling fees, more optimized oracle prices, and more LP subsidies (MEV subsidies, automatic reinvestment handling fees, etc.) all indirectly compensate LP's IL loss to some extent.
Regarding security and contract complexity, the core logic of Uniswap V4 is as non-upgradeable as V3. Although each pool can use its own Hooks smart contract, Hooks will check whether this part of the function requires external contract calls. Calling external contracts enriches the functions of Uniswap V4 and realizes more combination possibilities, but only when the pool is created identified specific permissions. Contracts need to call too many external contracts, which will also bring additional gas costs (so simple Swap may not be cheaper than V3/V2), which is also the Tradeoff brought about by complexity and composition.
Singleton
In Uniswap V3, deploying separate contracts for each liquidity pool increases the cost of creating liquidity pools and performing swaps across multiple pools. In Uniswap V4, the "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. According to preliminary estimates, V4 reduces the gas cost of creating a liquidity pool by as much as 99%.
Flash accounting
A quick bookkeeping system complements Singleton. In V4, the system no longer transfers assets into 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 the previous version, the user was actually trading with WETH. ETH is not a Token Contract but WETH is a Token Contract. For Uniswap, the ERC 20 contract is easier to integrate, so each time the user Swap needs to pack ETH an extra time, changing ETH to Into WETH, this step leads to gas waste. V4 restores support for native ETH, further saving Gas overhead.
The potential impact and opportunities of Uniswap V4 on other tracks
1) Aggregator track
From the perspective of the aggregator market, Uniswap V4 provides better rates, higher capital efficiency, and a huge liquidity pool integrated by Singleton, which will attract more from the aggregator market (1inch, Cowswap), which is the track of rolling rates. High transaction volume.
The impact of Onchain Limit Orders, customized liquidity distribution, dynamic rate, etc. on existing Dex with similar functions, including the LP yield enhanced vault on Uni V3. The liquidity of the product agreement is drawn away seems to be a foreseeable result, these The agreement may face the situation of joining if it can't win, and eventually become a part of the Uniswap V4 ecosystem. For future DEX or other DeFi protocols, it may fundamentally change its liquidity construction model. 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 .
3) CEX
For centralized exchanges, due to the price limit function and the orthodoxy of decentralization, Uniswap V4 may be able to gain more market share from the hit CEX. 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 many times, for most people, the early threshold of using DEX and the sacrifice of contract security for decentralization Sex and other risks, so that users need to bear relatively high costs. To put it simply, low efficiency and unusability require the improvement and solution of the DEFI infrastructure, and the V4 version cannot effectively solve it at present. After solving these two problems, the road for DEX to replace CEX will be smoother.
4) MEV track
When it cannot bring benefits to the core Stake holder (LP&Swapper) of the platform, MEV and the protocol are in opposition.
In previous versions, Uniswap V1 had no built-in mechanism specifically designed to prevent or mitigate MEV (miner-extractable value), causing miners or validators to gain extra profits by manipulating the order of transactions in the blockchain network to the detriment of users Benefit.
To help mitigate MEV, Uniswap V2 introduces a “price oracle” feature, an external price source that provides 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 block confirmation time delays to manipulate prices for profit.
Uniswap V3 introduces several features to mitigate MEV, including the concepts of centralized liquidity and non-homogeneous liquidity (NFT LP positions). Centralized liquidity allows liquidity providers to specify price ranges for their liquidity, reducing the risk of price manipulation. Non-homogeneous liquidity positions allow liquidity providers to have fine-grained control over their liquidity, reducing the risk of being squeezed or exploited by arbitrageurs.
In Uniswap V4, the internalized MEV allocation mechanism has opportunities for MEV developers who want to occupy a favorable role in the V4 pool.
5) Oracle track
The TWAP of Uniswap V2 is an oracle machine on the chain, which can be applied to obtain the price of any Token existing on Uniswap. The main defect is that it needs to be triggered by an off-chain program to update the price regularly, and there is maintenance cost.
Uniswap V3's TWAP solves this defect, and the storage of trigger data no longer requires an off-chain program to be triggered regularly, but is automatically triggered when a transaction occurs on Uniswap. In terms of data sources for calculating TWAP, Uniswap V2 only stores the latest three values of price 0 CumulativeLast, price 1 CumulativeLast and blockTimestampLast. Uniswap V3 supports multiple price observers (Oracle Observers), which can obtain price data from multiple sources. This design increases the fault tolerance and price reliability of the system. For example, Uniswap v3 screens pools with different commission rates for the same currency pair. The pool that is not empty and has the highest liquidity becomes the target pool. The price data in the pool with the best liquidity is used as the price of the oracle source.
Uniswap V4's built-in oracle will be more customized, such as Geomean Oracles, such as using different oracle price calculation methods for large-volume deep and stable pools (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 tokens over a period of time. In contrast, Chainlink’s cost of manipulation is disrupting enough nodes and manipulating prices on exchanges. Therefore, Chainlink is an 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 loans, stable coins, synthetic assets, etc.), the participation of off-chain oracles like Chainlink is still required.
Summarize
In general, the direction of 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, it is cheaper to create a transaction pool, and transactions have more options. For example, using V2, V3, and V4 has its own advantages. The contract of V2 is simple, and the transaction of a single pool is cheap; the structure of V4 is complex, but it can help users save a lot of gas costs when multiple pools need to be called.
The continuous development of DeFi will lead to the continuous optimization of liquidity management methods. For the project side, the Uniswap V4 Donate() function can help the project side 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 pattern will also undergo great changes due to the emergence of V4. The V4 code has not yet been finalized and reviewed, so it will take some time before the official public release. This is a window period for many protocols to develop their own liquidity and adjust their development direction.