What Is Uniswap?
Tech Deep Dives

What Is Uniswap?

7m
1 year ago

Uniswap V4 introduces "hooks" — contracts that run at various points in a pool action's lifecycle. Find out how it works!

What Is Uniswap?

Table of Contents

In the ever-evolving space of DeFi, one protocol has established itself as the undisputed king of the blockchain - Uniswap. This decentralized exchange didn't just pave the way for automated market makers (AMMs), it kept reinventing the entire ecosystem with each new iteration.
From humble beginnings facilitating simple token swaps in 2018, Uniswap has transformed into a protean crypto chameleon, seamlessly adapting to market demands. Concentrated liquidity in V3 ushered in a revolution of capital efficiency. With the launch of Uniswap V4, the protocol is leveled up again, offering unprecedented customization through "Hooks" and more gas-saving.
Uniswap's continuous metamorphosis isn't just about maintaining its DeFi dominance, holding over $5.772 billion in total value locked. No, this ever-shifting protocol keeps the entire crypto space on its toes, forcing competitors to adapt or get left behind in its perpetual slipstream of innovation.
It's no wonder Uniswap took home the "Most Innovative DeFi Project" award at the 2024 CoinMarketCap Crypto Awards. When your protocol is crypto's premier shapeshifter, constantly mutating to solve new problems, that kind of recognition comes with the territory.
Note: The Most Innovative DeFi Project Award is presented in partnership with Chainwire - the leading crypto & blockchain press release distribution platform used by 400+ brands and PR agencies worldwide.

With Uniswap V4 and features like Hooks, let's explore how this DeFi leader continues pushing the boundaries of what's possible.

Join us in showcasing the cryptocurrency revolution, one newsletter at a time. Subscribe now to get daily news and market updates right to your inbox, along with our millions of other subscribers (that’s right, millions love us!) — what are you waiting for?

Uniswap V1: November 2018

Hayden Adams founded Uniswap (V1) as a decentralized exchange protocol for trading ERC-20 tokens on the Ethereum blockchain on November 2, 2018. Uniswap V1 is a set of smart contracts that allows users to swap tokens without the need for an order book or an intermediary. Instead, it uses a constant product market maker algorithm that automatically adjusts the price of tokens based on supply and demand.
Uniswap V1 only supported ERC-20 trading pairs on Ethereum. The protocol is completely decentralized, permissionless, and censorship-resistant, meaning that anyone can swap or list a token without permission. The UNI token was launched on September 16, 2020.

Uniswap V2: May 2020

Uniswap V2 launched in the early days of DeFi Summer of 2020, bringing to the protocol ERC-20 trading pairs, when initially all pairs were paired with WETH. This addition greatly increased the utility for traders on Uniswap. This flexibility is further increased with the introduction of Flash Swaps, which enabled more efficient trade execution and settlement.
More than that, Uniswap V2 implemented harder-to-manipulate price feeds on the protocol, which keeps their platform safe from price manipulators looking to exploit the platform.

Source: Uniswap Blog (link)

Uniswap V3: May 2021

Just one year later, Uniswap V3 was released, bringing the now well-known concept of concentrated liquidity to the DeFi space.
Concentrated liquidity enables significantly greater capital efficiency to the original AMM model through the concentration of liquidity in liquidity pools. Moreover, this also gave liquidity providers the opportunity to earn outsized fees through their provided liquidity, provided they were savvy enough to keep their liquidity within the current trading range.

Source: Uniswap Blog (link)

Uniswap V3 came with a significant downside though. Passive liquidity providers were unable to take advantage of the benefits of Uniswap V3 and those who were inexperienced with it also lost out due to impermanent loss.

Nevertheless, the concentrated liquidity model has still received mainstream adoption and has since been copied or adapted into a variety of models, with most prominent AMMs implementing some form of concentrated liquidity model on their platform.

Uniswap V4: Hooks and Custom Pools

Fast forward another two years, Uniswap V4 launched on June 12, 2023 - the latest in Uniswap developments.

Uniswap V4 introduces the concept of “Hooks” to the platform. Hooks are essentially contracts that run at specified points in a pool action’s lifecycle. These points can include, but are not limited to, when a pool is set up, when liquidity is added or removed, and when trades are made in the pool.

These hooks allow increased customizability over deployed pools on Uniswap V4, enabling pool creators to have greater control over the behavior of their pools.

In fact, together with publishing their draft code for Uniswap V4, the Uniswap team has also released a set of sample code for hooks they have written to demonstrate what’s possible with them. These include:

  • A time-weighted average market maker (TWAMM) pool
  • Dynamic fees based on volatility or other inputs
  • On-chain limit orders
  • Depositing out-of-range liquidity into lending protocols
  • Customized on-chain oracles, such as geomean oracles
  • Autocompounded liquidity pool fees back into the liquidity pool positions
  • Internalized maximal extractable value (MEV) profits are distributed back to liquidity providers
In addition to hooks, Uniswap V4 is also designed to run out of a singleton contract. This means that all pools will share a single contract, which is opposed to the current architecture of every pool having its own smart contract. This is expected to generate savings of up to 99% for traders as token transfers are minimized in swaps involving more than one pool. Moreover, the singleton contract enables flash accounting, which means that the changes in each pool are recorded as net changes rather than at the end of each swap, further increasing savings for users.

Singleton architecture

The ‘singleton architecture’ is a significant feature as it eliminates the 1 pool: 1 contract requirement. This feature consolidates all pools into one contract, thereby making pool creation and multi-pool swaps more cost-effective. An indication of the gas cost for creating a new pool is estimated at a substantial 99% reduction.

Though this dramatically improves efficiency, some have suggested it also makes Uniswap more vulnerable to black swan events.

Flash accounting system

The Flash accounting system is set to complement the singleton architecture by enabling the optimization of asset transfers by working on net balances rather than transferring assets at the end of every swap. This streamlines the process of swapping tokens and yields a further reduction in gas costs.

Governance

Uniswap V4 will continue its community-driven governance, releasing the code under the Business Source License 1.1. This limits commercial forking for four years before converting to a GPL license. Uniswap Governance and Uniswap Labs will retain the ability to grant exceptions, ensuring the protocol remains open and adaptable.

License Controversy

Currently, Uniswap V4’s draft code has been open sourced, released under a Business Source License (BUSL). The team has also opened up the code base for contribution from the public.

The decision to release the code under BUSL has drawn flak from many developers who criticized the use of the term “open source” to describe the new Uniswap V4 codebase. While BUSL allows the code to be copied, modified and contributed to, it does not allow the code to be utilized for commercial uses for the next four years. This effectively makes it a proprietary license, and in most developer circles, would not qualify as “open source.”

Uniswap founder and CEO, Hayden Adams, and the team responded by claiming that four years is not a long time and that the protection that the license confers incentivizes innovation. However, other developers claim that the license instead stifles innovation due to fear of a copyright claim for any code that looks remotely similar. Adams has since retracted, stating that “source available is more accurate.”

View post on Twitter
Additionally, certain members of the DeFi community have also alleged that concepts of Uniswap V4 seemed to exhibit similarities to open source code from other teams. These allegations include the copying of protocols such as Crocswap (now Ambient Finance) and Shell protocol.
Furthermore, some DeFi users have even speculated that Uniswap V4’s announcement was accelerated due to Ambient Finance, a decentralized trading protocol, hinting at their imminent launch earlier in the week. Ambient Finance has since launched on the Ethereum mainnet.

How Does Uniswap V4 Differ From Sushiswap V3?

Widely considered to be one of Uniswap’s biggest competitor, SushiSwap forked from Uniswap in 2020 and began to develop along different paths — with Uniswap primarily focusing on capital efficiency and Ethereum-based products, whereas SushiSwap opted for a more aggressive multi-chain approach and diverse DeFi product lineup.

While Uniswap and Sushiswap are operating on their third public release (V3), there are subtle differences in the way liquidity pools are created and fees are generated. Uniswap offers liquidity providers (LPs) with three fee levels (0.05%, 0.30%, and 1.0%) for pool creation, along with a dynamic taker fee for each trade. While SushiSwap charges a flat fee rate of 0.30% per trade, with 0.25% of the fee distributed among LPs.

Uniswap V4 will act to further differentiate the two platforms by providing developers with the tools needed to create more complex and nuanced pool types. It also redoubles its efforts to improve gas efficiency.

Meanwhile, Sushi has continued its cross-chain expansion, recently expanding to the Core ecosystem. In July 2022, the first cross-chain AMM, SushiXSwap, was launched in partnership with LayerZero’s Stargate to provide cross-chain swaps across Ethereum and EVM chains like Polygon, Optimism, Arbitrum, BNB Chain, Avalanche and Fantom.
Click here to learn more about SushiSwap.
This article contains links to third-party websites or other content for information purposes only (“Third-Party Sites”). The Third-Party Sites are not under the control of CoinMarketCap, and CoinMarketCap is not responsible for the content of any Third-Party Site, including without limitation any link contained in a Third-Party Site, or any changes or updates to a Third-Party Site. CoinMarketCap is providing these links to you only as a convenience, and the inclusion of any link does not imply endorsement, approval or recommendation by CoinMarketCap of the site or any association with its operators. This article is intended to be used and must be used for informational purposes only. It is important to do your own research and analysis before making any material decisions related to any of the products or services described. This article is not intended as, and shall not be construed as, financial advice. The views and opinions expressed in this article are the author’s [company’s] own and do not necessarily reflect those of CoinMarketCap.
4 people liked this article