UNISWAP

Daniel Anthony
5 min readMay 11, 2022

Learn about the leading DEX on Ethereum.

OVERVIEW

Uniswap, the largest crypto project on Ethereum is a protocol for automated token exchange. Uniswap allows you to swap any Ethereum token for any other Ethereum token for a minimal fee.

The reserve is pooled by a network of liquidity providers who supply the systems with tokens in exchange for a proportional share of transfer fees. Prices are set automatically using the x*y=z formula. Uniswap is open-source software licensed under the GPL (General Public License).

HISTORY

Uniswap was founded by Hayden Adams and he launched the protocol on the 2nd of November 2018 through a series of tweets on Twitter to his then 200 followers. With significant help from Karl Floersch

The protocol initially only had one liquidity provider and facilitated simple swaps. Uniswap was born from a Reddit post made by Vitalik Buterin himself on building Automated Market Makers. Alan Lu of Gnosis invented the mechanism behind the Uniswap market maker. The protocol was also named by Vitalik.

Products

Uniswap v1

The first version of Uniswap was launched in November 2018 at Devcon4. It was permissionless meaning it would remain as long as Ethereum lasts.

The Uniswap protocol v1 is designed for simplicity and provides an interface for the seamless exchange of ERC20 tokens with Ethereum. By eliminating unnecessary hiring and transitional forms, faster and more efficient exchanges can be achieved. Where compromises are made, the priorities are decentralization, resilience to censorship and security.

The v1 features include:

  • Add support for any ERC20 token using the Uniswap factory
  • Join liquidity pools to collect fees on ETH-ERC20 pairs
  • Liquidity-sensitive automated pricing using constant product formula
  • Trade ETH for any ERC20 without wrapping
  • Trade any ERC20 for any ERC20 in a single transaction
  • Trade and transfer to a different address in a single transaction
  • Lowest gas cost of any decentralized exchange
  • Support for private and custom UniSwap exchanges
  • Buy ERC20 tokens from any wallet using ENS
  • Partially verified smart contracts written in Vyper
  • Mobile-optimized open-source front-end implementation
  • Funded through an Ethereum Foundation grant

Uniswap v2

ERC 20 Pairs

In Uniswap V1, you can only exchange between the ETH and the ERC20 token. Uniswap V2 uses Wrapped Ether (WETH) in basic contracts. Allows aggregation of any ERC20 token directly with any other ERC20 token.

Flash Swaps

With Uniswap V2, the user can withdraw any amount of any ERC20 token for free. This is known as a flash swap. Requirements for this include one of the following:

.Payment for all downloaded ERC20 tokens
.Pay part of the ERC20 token and return the rest
.Return all downloaded ERC20 tokens

Price Oracles

Uniswap V1 price sources are not decentralized and can be manipulated. Use is not safe. Uniswap V2 oracle is highly decentralized and does not tolerate manipulation. The oracle measures prices when they are expensive to manoeuvre.

Core Architecture

Uniswap V2 smart contracts are called Uniswap V2 Core. It consists of functions including:

.V2 introduces WETH instead of ETH. Users can use ETH directly, converting routers between ETH and WETH
.These routers manage the logic around slip checks and multi-hop trades.
.V1 stores ERC20 balances in the ERC 20 token agreement. In version 2, Core stores ERC20 token balances internally.

Uniswap V2 brings many technical improvements, including:

.V2 is written in Solidity instead of Vyper
.Fixed “lost page” issue with ERC20 token in Uniswap V1
.Compatible with ERC777 and other non-standard ERC20 tokens
Uniswap V1 uses all remaining gas in failed transactions. V2 fixed this bug.

Uniswap v3

Uniswap v3 was launched in March of 2021 on both the Ethereum and Optimism mainnet.

Concentrated Liquidity

The big update here is concentrated liquidity. The main advantage of concentrated liquidity is that you can add rules to the money you provide to the liquidity pools. Unlike the older versions where the assets pooled from liquidity providers are evenly spread thin across all price ranges from 0 to infinity for traders to use, in v3 however, the LPs can select where to deploy their concentrated liquidity.

Concentrated liquidity allows the market to decide on a reasonable liquidity distribution, while LPs can create as many positions as they want in their price range. The UniSwap fee calculator enables you to input your investment amount, see current swaps and liquidity, and estimate fee income.

Multiple pools per pair

UniSwap V3 introduces a new concept of multiple pools per pair of tokens, each with a different exchange fee. Usually, each pair of tokens is equivalent to a liquidity pool, each with a standard fee of 0.3% for all swaps. Although this method has worked well in the past, it is probably too low for pools that sell faster tokens and too high for relatively strong ones.

With UniSwap V3, all pools are created on the basis of the same factory contract, which allows you to create contracts at three different levels: 0.05%, 0.3% and 1%. This route will take you to the pools that will give you the best features.

Range orders

Customizable UniSwap V3 LPs, along with one-way asset staging, open up new functionality to complement market orders, referred to as “Range Orders”.

Range orders allow LPs to deposit a token at the custom price range above or below the current price. When the market enters the range set by the LP, a range order allows one asset to be sold to another asset while receiving a swap fee.

Ticks

To get concentrated liquidity to work, Uniswap has created ticks that are used to maintain liquidity within a specific price range. Each tick has its own set of liquidity provider tokens. Technically, small trades do not need to cover more than one tick, but large trades or trades with higher slippage can cover more once liquidity is exhausted on the first tick.

Due to the UniSwap V3 smart contract, the distance between checkmarks is directly related to the swap fee. A lower rate allows closer active ticks and a higher rate allows a greater distance between these ticks. The contraction of the ticks increases the aggregation of liquidity, reduces the price effect at the time of trading, and may improve the trading price of stable coins.

Oracle Upgrades

UniSwap V3 eliminates the need to track previous accumulator values ​​externally. This is accomplished by storing a series of running sums instead of just one, allowing TWAP to be calculated in the past on a single string call.

Since this is a historical reward set, it is much easier and cheaper to create more advanced oracles with greater abilities. This reduced gas costs for UniSwap traders by around 50% compared to UniSwap V2.

Governance

UNI is Uniswap native governance token allowing holders to delegate, vote and propose. The more UNI a user has in their wallet, the more weight their delegation or vote on a proposal holds. Uniswap created 3 venues for UNI holders to participate in the governance process, they are gov.uniswap.com, snapshot, and governance portal.

Website: https://uniswap.org/

Twitter: https://twitter.com/Uniswap

--

--

Daniel Anthony

WEB3 Advocate — I | Write | Podcast | Research And Document Everything Web3