Uniswap Labs releases Uniswap v4 code draft, a peep into the main functions

Uniswap Labs releases Uniswap v4 code draft, a peep into the main functions

Tonight, UniswapLabs released the Uniswap v4 code draft so that v4 can be built publicly, with public feedback and meaningful community contributions. The vision of Uniswapv4 is to allow anyone to make trade-off decisions by introducing "hooks". Hooks are contracts that run at various points in the lifecycle of pool operations. Pools can make the same tradeoffs as ;v 3, or they can add entirely new features. For example, v4 will allow the pool itself to support dynamic fees, add on-chain cap orders, or act as a time-weighted average market maker (TWAMM) to spread out large orders over time. v4 pools will exist in a single contract, which will reduce the gas cost of pool creation by 99%.

The Uniswap v;4 code will be released under the Business Source License 1.1, which will limit the use of the v;4 source code in a commercial or production environment to 4 years, at which point it will be permanently converted to a GPL license. The protocol fee mechanism will also be modeled after v3. Governance will be able to vote to add protocol fees to any pool, up to a capped amount.

The following is the article written by the founder of Uniswap Hayden Adams **, compiled by Odaily Planet Daily. **

Two years ago we released Uniswap v3, a turning point for on-chain liquidity and DeFi. Today, the Uniswap protocol is the largest decentralized exchange protocol, handling more than; 1.5; trillion dollars in transaction volume. As a public infrastructure, it is an important part of the cryptocurrency ecosystem.

As technology and markets evolve, the Uniswap protocol must evolve too. We are very pleased to introduce the vision of Uniswap v;4 to you, and we believe it will open up infinite possibilities for the trading method of creating tokens for on-chain liquidity.

We've now released code drafts to create v;4; with open feedback and meaningful community contributions. We expect this to be a months-long process. You can read the open-source early release of Uniswap v;4 core and surrounding libraries here, read the draft technical white paper here, and learn more about how to contribute here.

Uniswap v3; takes a strong, assertive approach to providing liquidity, balanced by an extremely complex trade-off space. New features come at the cost of higher expense and code complexity. For example, the V3 version includes oracles, allowing builders to integrate real-time on-chain pricing data, but at the expense of increased costs for traders.

Our vision for Uniswap v;4 is to allow anyone to make trade-off decisions by introducing "hooks". hooks; are contracts that run at different points in the lifecycle of pool operations. Pools can make the same tradeoffs as v3, or add entirely new functionality. For example, v;4 would allow mining pools to support dynamic fees themselves, add on-chain cap orders, or act as a time-weighted average market maker (TWAMM) to spread out large orders over time.

While doing this customization, the architecture of Uniswap v;4 also reduces costs and ensures efficiency. It introduces a new "singleton" contract where all mining pools are in one smart contract. We believe that the combination of "hooks" and singleton architecture will create a very powerful platform with fast and safe pool customization and efficient routing across multiple pools. Uniswap v;4 brings fast, expressive AMM innovation in a robust ecosystem.

What is Uniswap v;4;?

hooks; and custom pools

Every Uniswap liquidity pool has a lifecycle. During the lifetime of a pool, several things happen: pools are created with default fee tiers; liquidity is added, removed, or realigned; and of course, users trade tokens. In Uniswap v3, these lifecycle events are tightly coupled and executed in a very strict order.

To create room for customizable liquidity in Uniswap v;4, we want to create a way for pool deployers to introduce code that performs specified actions at key points in the pool's life cycle -- such as before a trade or After, or before or after changing the LP position.

Enter hooks, which are plugins that customize how pools, swaps, fees, and LP positions interact. Developers can innovate on the liquidity and security of the Uniswap protocol to create custom AMM pools through hooks integrated with v;4 smart contracts.

We're excited about some experiments, including:

  • Time Weighted Average Market Maker (TWAMM)
  • Dynamic fees based on volatility or other inputs
  • Chain cap order
  • Deposit out-of-range liquidity into the lending agreement
  • Customized on-chain oracles, such as geomean oracles
  • Automatically compound LP fees back into LP positions
  • Internalized MEV profits are distributed back to LPs

The sea is as wide as the fish leap, the sky is as high as the birds fly, the imagination space of v4 is unlimited. Now each pool is not just defined by tokens and fee tiers, we will see pools of all colors, shapes and sizes. The core logic of Uniswap v4 is the same as that of v3, which is not upgradeable. While each pool can use its own hooks smart contract, hooks can be restricted to specific permissions determined at pool creation time.

We have created a sample hooks contract, click to see the current framework. We expect developers to come up with new and interesting ways to build features we haven't thought of yet.

Uniswap Labs releases Uniswap v4 code draft, a peep into the main functions

Improve architecture and save; GAS

In Uniswap v3, we deploy a new contract for each pool, which makes it more expensive to create pools and perform multi-pool swaps. In v;4, we put all pools in a singleton contract, which will provide effective gas savings, as transactions no longer need to transfer tokens between pools in different contracts. Early data shows that v;4 reduces pool creation gas costs by 99%;. Hooks introduce a world of endless choices, and singletons allow you to efficiently span all of them.

This singleton architecture is complemented by a new "flash accounting" system. Instead of transferring assets in and out of the pool at the end of each transaction in v3, the system only makes transfers based on net balances - meaning a more efficient system that provides additional gas in Uniswap v;4 save.

We believe that the best design for flash accounting is to use "transient storage", which will be implemented by EIP-1153. This EIP is being considered to be included as part of the Ethereum Cancun hard fork upgrade and will bring more Gas improvements and cleaner contract designs in various applications.

With the efficiencies of singletons and flash accounting, there is no longer a need to limit fee levels. Pool creators can set them at a level that makes them most competitive, or customize them using dynamic fee hooks. v;4 provides support for native ETH, which provides additional gas savings.

Uniswap Labs releases Uniswap v4 code draft, a peep into the main functions

License and Administration

As always, we firmly believe that core financial infrastructure should be open and transparent. We also believe that the Uniswap community - the people and teams who support, use, and build the protocol - should govern v;4; of the protocol, just as they have governed previous versions.

The code will be released under Business Source License 1.1, which limits the use of the v;4 source code in a commercial or production environment to four years, at which point it will permanently transition to the GPL license. As with v3, Uniswap Governance and Uniswap Labs can grant license exceptions.

The charging mechanism of the protocol will also be based on v3. Governance layers will be able to vote to increase protocol fees in any pool, subject to a cap. More details on the fee mechanism can be found in the white paper.

View Original
This page may contain third-party content, which is provided for information purposes only (not representations/warranties) and should not be considered as an endorsement of its views by Gate, nor as financial or professional advice. See Disclaimer for details.
  • Reward
  • Comment
  • Repost
  • Share
Comment
0/400
No comments
Trade Crypto Anywhere Anytime
qrCode
Scan to download Gate app
Community
English
  • 简体中文
  • English
  • Tiếng Việt
  • 繁體中文
  • Español
  • Русский
  • Français (Afrique)
  • Português (Portugal)
  • Bahasa Indonesia
  • 日本語
  • بالعربية
  • Українська
  • Português (Brasil)