Notes on Uniswap v4
Aggregated Notes From Whitepaper, Blog Post and Bankless Podcast:
Uniswap Vision and Growth
Approach to Uniswap v4 is different than what the approach was to v2 and v3.
Hayden says that Uniswap is now similar to Ethereum in that it is a core piece of public infrastructure, where teams build and other market participants interact.
Similar to how Ethereum has a public process, Uniswap wants to build v4 in public.
Vision, whitepaper and draft of code launched today (June 13th)
v2 and v3 were built within a month and were live on mainnet. Code was already done and being audited.
In v4 there will be a long period for collaboration, for PR’s, open issues. Will have a contribution guidelines and etc. and more time for other builders in the space to plan integrations and build on top of it.
Hayden says that growth for Uniswap in terms of market share is tough. Instead, Uniswap can grow much bigger by growing Ethereum as a whole.
One of the main focuses for v4 is to make it easier to experiment and innovate while letting innovation stay within the Uniswap space.
v3 versus v4
v3 was opinionated. Immutable smart contracts cannot really be updated and modified without leading to risks.
In the v3 design there were a lot of tradeoffs in design. An example is price oracles and price accumulators for Uniswap v3, which were useful, but led to extra gas cost for swappers.
Uniswap v4’s core logic, like v3, is non-upgradeable.
v4 Features
Flagship feature of v4 is Hooks:
Hooks are modules or customizations that you can make when you deploy a pool.
Anyone can create a pool and choose what hooks their protocol uses,
Base Uniswap v4 pool is standardized and cheap. This base system is even less complex than v3, (i.e. does not include price accumulators).
Hooks run at certain points of the lifecycle of a pool. i.e. before/after/during x run this code.
Examples of Hooks:
Dynamic fees: Can choose both dynamic or static fees, or a combination based on conditions.
Limit Order: Allows limit orders.
TWAMM Feature: To reduce price impact from large orders.
Customized On-Chain Oracles
Internalized MEV profits redistributed
There are other architectural changes to contracts, called Singleton and Flash Accounting:
Singleton:
In v4, all pools are held in one singleton contract, which will lead to gas savings, since swaps will no longer need to transfer tokens between pools held in different contracts.
This is aimed at reducing cost of fragmentation across many pools and to make it efficient to route across many pools.
Flash Accounting:
Instead of transferring assets in and out of pools at the end of every swap, flash accounting transfers only on net balances, which requires less gas and is more efficient.
With the addition of Singleton and Flash Accounting, there’s no more limiting of fee tiers (previously in v3, there were limited options for fees). Previously, there were limited options for fees to reduce liquidity of fragmentation.
v4 will also bring back support for native ETH, which will lead to additional gas savings.