Uniswap (UNI) v3 Is Here. But Can It Remain the King of DEXs?!
UNI cover logo

Uniswap (UNI) v3 Is Here. But Can It Remain the King of DEXs?!

By Michael @ CryptoEQ | CryptoEQ | 16 Jun 2021


CEQ logo   UNI logo

Overview

Uniswap is a DeFi project that is built on Ethereum and serves as the largest decentralized exchange and automated market maker (AMM), which is a type of decentralized exchange protocol that relies on a mathematical formula to price assets. Uniswap allows users to create liquidity pools of ERC-20 tokens to be launched and traded on their protocol without any listing fees. Additionally, Uniswap is completely open-sourced. This on-chain platform enables trustless token swaps executed from smart contracts for small fees. The UNI token itself can be earned by staking pre-determined pairs of other tokens and serves as an adoption and incentive tool for its ecosystem.

UNI Strengths

  • One of the top Ethereum dApps by nearly any metric: users, volume, TVL, revenue, etc.
  • One of the few truly permissionless, decentralized, and unstoppable protocols with no backdoor vulnerabilities in DeFi.
  • Impressive team with a stellar record of continually improving the product and shipping new versions (V1 vs V2 vs V3).
  • Anyone is able to create a market on Uniswap allowing it to list long tail ERC-20 assets long before centralized exchanges are able.

UNI Weaknesses

  • UNI token is solely a governance token and does not accrue fees generated by the protocol.
  • Uniswap and DEXs, in general, can be copied/knocked off (SushiSwap and PancakeSwap) due to their open-source nature, losing market share.
  • Traders may suffer impermanent loss when providing liquidity to Uniswap, deterring a portion of potential users.
  • Uniswap only trades Ethereum ERC-20 tokens and future cross-chain DEXs like Thorchain and Gravity DEX (Cosmos) may interest more traders looking to trade across blockchains. 

Important Links

UNI logo

Use Case

Uniswap is a decentralized exchange (DEX) and automated liquidity protocol built on Ethereum. Uniswap allows users to create liquidity pools for ERC-20 tokens to be launched and traded without any listing fees and is completely open-sourced. This on-chain platform enables trustless token swaps executed from smart contracts for small fees.

Uniswap V1 set the foundation of on-chain token swaps and decentralized liquidity pools that rewarded users for providing liquidity of underlying token pairs, such as DAI to ETH or DAI to USDC. Uniswap V2 introduced ERC-20 to ERC-20 token swaps, a price oracle, flash swapping (allowed you to withdraw any ERC-20 token at no upfront cost), and support of non-standard ERC-20 tokens. Uniswap V3 introduces concentrated liquidity, multiple fee tiers (allows liquidity pools to be appropriately paid for taking on risk), and 4000x capital efficiency (allowing earning higher returns on equity). This platform provides a decentralized pricing mechanism that seamlessly automates order book depth, and allows swaps between ERC-20 tokens.

Uniswap executes its digital exchange under a constant product market maker, which is a type of model of an automated market maker (AMM). Inspired by Ethereum co-founder Vitalik Buterin and created by Haden Adams, Uniswap uses an AMM construction, built from smart contracts, which allows anyone to create liquidity pools for any Ethereum token and to do so much faster than centralized exchanges. Anyone can pay a fee and provide liquidity to a pool that is then distributed to providers in respect to the amount of the provider’s pool share. Stakers provide a deposit of two tokens, either ETH and an ERC-20 token or two ERC-20 tokens, in return for interest from the principal. Stakers also commonly use other DeFi platforms, like Aave, to put down the principle, occur interest, then take out flash loans to use as principle to enter a liquidity pool on Uniswap or other DeFi platforms to accumulate risky, high volume profits. 

UNI logo

Technology

An automated market maker (AMM) is a specific type of decentralized exchange (DEX) that relies on a mathematical formula to price assets instead of an order book where buys and sells are matched like on Coinbase or Gemini. Traditional market-making utilizes giant firms with extensive resources to create a tight bid-ask spread on an order book exchange. Automated market makers decentralize this process, enabling anyone to create a market for any two tokens on a blockchain. 

Uniswap uses the formula x * y = k.

  • x is the amount of one token in the liquidity pool
  • y is the amount of another
  • k is a fixed constant 

 

This means that the ratio of value between the two tokens must always remain the same. The price of a trade is determined by how much the ratio between the tokens in the liquidity pool changes after a trade. If the ratio changes by a wide margin, there’s going to be a large amount of slippage. Traders interact with a smart contract, rather than an order book, that dictates the trade price between assets. This is a peer-to-contract (P2C) interaction that removes the need for a central entity/business to help facilitate the trade. 

Liquidity providers (LPs) add funds to the AMM pool which creates the market for each trading pair. LPs will deposit an equivalent value of two tokens i.e 50% ETH and 50% AAVE to the ETH/AAVE pool. When a trader draws from that liquidity pool, the mathematical formula will set the price so that the balance of ETH-AAVE remains in balance.

Uniswap v2 charges traders 0.3% that goes directly to LPs. This incentivizes users to add liquidity which helps create better prices for traders which brings in more fees creating a flywheel effect! Uniswap v3 offers LPs three separate fee tiers per pair — 0.05%, 0.30%, and 1.00%

Uniswap V2 added an “end-of-block” price to one cumulative-price variable that represents a sum of the Uniswap price for each second of the contract. This variable may also be manipulated by contracts to trace accurate time-weighted average prices. This happens by reading the value from an ERC-20 token pair at the start and at the end of the mentioned segment. The difference of the cumulative price can then be divided by the length of the interval to make a time-weighted average price for that period.

 

Flash Swaps

Uniswap V2 swaps allow withdrawals at any amount of any ERC-20 token on Uniswap at no upfront cost, providing that by the end of the day the transaction execution, the user either:

·         Buys all ERC-20 tokens withdrawn;

·         Obtains a percentage of ERC-20 tokens and returns the rest; or

·         Returns ERC-20 tokens.

Liquidity provider fees are enforced by subtracting 0.3% from all input amounts, whether or not the input ERC-20 tokens are being returned as a part of a flash swap.

Flash swaps on Ethereum feature a high upfront cost, but a low net cost or are even net profitable by the end of the series. Flash swaps are useful because they remove upfront capital requirements and unnecessary constraints on order-of-operations for multi-step transactions that use Uniswap. One example of this is arbitrage with no upfront capital. Another example case is improving the efficiency of margin trading protocols that borrow from lending protocols and use Uniswap for ERC-20 token conversion.

 

An Automated Market Making DEX

Uniswap is an AMM decentralized exchange, meaning it is a protocol that relies on a math formula to price this asset instead of using an order book and is made up of a series of smart contracts that hold pairs of tokens.

UNI AMM
Uniswap. Uniswap Blog​​​​​​

The image shown above illustrates the three primary parties:

·         Liquidity Providers – create new pools, add liquidity to existing pools, and remove tokens from reserves they contribute to;

·         Traders – pay the swap fee, which is effectively added to the reserve of the pool KNC/USDT; and

·         Arbitrageurs – enforce an efficient price mechanism at a pool-level.

 

Uniswap V3

There are two significant differences that V3 introduces in its design: more concentrated liquidity and multiple fee tiers. On Uniswap V2, users provide liquidity evenly along all of its markets’ price curves. This is somewhat inefficient since there does not need to be equal amounts of liquidity for ETH at $1 vs $2500. The concentrated liquidity gives individual liquidity pools control over what price range their funds are allocated to. This allows for individual positions to be fused together into a single pool to make one combined curve for traders to trade against. Liquidity pools can focus capital within a custom price range so pools can provide larger amounts of liquidity at desired prices. This mechanism allows for individualized price curves. In doing so, traders can trade against the combined liquidity pool of all curves with no gas increase per liquidity provider. Trading fees are then collected and dispersed at a given range appropriately. 

Multiple fee tiers allow for liquidity pools to be compensated for taking risks. There are three fee tiers per pair: 0.05%, 0.30%, and 1%. These options make sure that liquidity pools are customized to their margins according to certain pair volatility of the tokens. This may lead to some liquidity fragmentation, but the Uniswap team believes that most pairs will calibrate to an appropriate fee tier. 

The V3 upgrade also introduces more characteristics to make Uniswap one of the most flexible and efficient automatic market markers in this space. The liquidity pools can give liquidity with up to 4000x capital efficiency relative to Uniswap V2 so providers can earn higher returns. By concentrating liquidity, users can acquire the same increases as V2 within a certain price range while putting down less principal.  V3 also offers a way for low slippage trade execution compared to centralized exchanges and stablecoin AMMs. In order to help protect pool providers, changes were made to increase exposure to preferred assets and to reduce their risk taken. V3 liquidity pools can sell one asset for another by adding liquidity to a price range above or below the market price as needed. 

Another new feature in V3 is that liquidity providers receive non-fungible tokens (NFTs) that represent their Uniswap V3 liquidity positions. In Uniswap V1 and V2, users receive fungible ERC-20 tokens representing their liquidity position in the pool. The reason for issuing NFTs is explained in the V3 mainnet post:

UNI logo

Economics

Since Uniswap's genesis, it has served as a trustless and decentralized financial infrastructure on Ethereum. Uniswap aims to stay a permissionless, securitized, and immutable platform to rival centralized traditional markets. Within two years, Uniswap has supported over $20 billion in trading volume by over 250,000 addresses across 8,484 assets. They have also secured over one billion dollars in liquidity deposits by 49,000 liquidity providers. Uniswap has earned $36 million in fees and has emerged as one of the most successful DeFi platforms.

UNI v3
UNI volume. Image credit: TokenTerminal

 

1 billion UNI tokens were minted in 2020. This initial supply will be fully diluted over the four next years, with an allocation breakdown as follows:

  • 60.00% or approximately 600,000,000 UNI to Uniswap community members;
  • 21.51% or approximately 215,101,000 UN to team members and future employees with 4-year vesting;
  • 17.80% or approximately 178,000,000 UNI to investors with 4-year vesting; and
  • 0.069% or approximately 6,899,000 UNI to advisors with 4-year vesting.

UNI genesis allocation
Uniswap. Uniswap Blog 

60% of the UNI genesis supply was distributed to community members. As of Q2 2021, 50% of the supply was distributed to reward past Uniswap users, who can claim tokens on the governance portal. The remainder of the allocation was going to be offered through liquidity mining on four pre-selected pools: ETH/USDT, ETH/USDC, ETH/DAI, and ETH/WBTC. This liquidity mining was scheduled to last for 3 months. The supply will grow at a rate of 2% of annual inflation from 2024.

UNI issuance
Binance Research

 

15% of UNI tokens can be claimed by historical liquidity providers, users, and SOCKS holders. 4.917% is proportional to all 49,192 historical liquidity pools. 49 million UNI tokens belong to historical liquidity providers. The formula accounts for liquidity pools on a second time interval basis since the deployment of Uniswap V1. This ensures that rewards are weighted towards liquidity pools and provide liquidity when total liquidity is low. 10% of the supply was split evenly across all ~250,000 historical Uniswap user addresses. 400 UNI are claimable via the airdrop by any address that has ever used the Uniswap v1 or V2 protocols.

Uniswap V3 launched in May 2021 and, within its first month, volume on V3 exceeded V2. Summing V2 and V3 together, the DEXs have traded over $65B in three weeks as of Q2 2021and continue to command ~55% of DeFi DEX volume market share. The top liquidity pairs in V3 are the ETH/USDC, ETH/USDT, USDC/USDT, and ETH/WBTC markets, which account for ~75% of activity. Uniswap remains far and away the most revenue-generating dApp built on Ethereum over the last year despite holding a modest ~$4.5 billion in total locked value (TVL).

UNI total revenue
UNI total revenue. Image credit: TokenTerminal

As of Q2 2021, holding UNI only gives users the right to participate in protocol governance. However, UNI token holders can vote to turn on a "fee switch" on a pool-by-pool basis. If the vote passes for that individual pool, 10-25% of liquidity provider's fees will go to the protocol. These fees can then, theoretically, be redirected to UNI holders via buybacks and burns. While these mechanisms would turn UNI into a productive asset, they would also reduce revenue for liquidity providers, meaning that these cash flows may come at the cost of hampering the protocol’s growth.

UNI logo

Governance

Uniswap launched in November 2018 without the UNI token. UNI is the native token of the Uniswap protocol was airdropped to users in 2020 and entitles its holders to governance rights. This means that UNI token holders can vote on changes to protocol updates. Uniswap governance manages all UNI vested to the Uniswap treasury. This governance can vote to allocate UNI towards grants, governance initiatives, and strategic partnerships, additional liquidity mining pools, and other programs. Uniswap seeks to do a variety of experimentation, including within the areas of ecosystem grants and public goods funding. UNI holders are responsible for enforcing governance decisions that are in compliance with laws and regulations. The fee switch has been created to initialize a contract UNI holders can use to vote on tokens for which they will collect fees. The community is responsible for consulting with legal and regulatory professionals before implementing any proposal. 

UNI holders who own > 1% of the UNI supply are eligible to submit development proposals. Users with < 1% of the supply can vote on proposals. UNI holders can also help fund grants, partnerships, liquidity mining pools, and more.

UNI holders currently have ownership of:

  • Uniswap governance;
  • UNI community treasury;
  • The protocol fee switch;

 

Initial governance parameters are as follows:

  • 1% of UNI total supply to submit a governance proposal;
  • 4% of UNI supply required to vote yes to reach quorum;
  • 7-day voting period; and
  • 2-day timelock delay on execution.

 

With 15% of tokens already available to be claimed by historical users and liquidity providers, the governance treasury will retain 43% of the UNI supply to distribute on an ongoing basis through contributor grants, community initiatives, liquidity mining, and other programs. UNI will vest to the governance treasury on a continuous basis according to a fixed schedule. The governance community obtained access to the vested UNI in October 18, 2020. The Uniswap community treasury currently holds over 47 million UNI, which can be distributed through votes by token holders on a discretionary basis.

Uniswap decided to airdrop 150 million UNI governance tokens to holders in the last quarter of 2020. The airdrop allowed anyone with a wallet that had tried to use Uniswap prior to September 1, 2020 at 12:00 AM UTC  to claim 400 UNI. 

One unique aspect of Uniswap, when compared to its centralized counterparts, is that the project itself does not accrue any of the value. Uniswap is simply a decentralized protocol (code). All the fees go directly to the LPs who provide the liquidity, which can be anyone all over the world. This makes it a truly decentralized, permissionless, unstoppable crypto exchange.

As of Q2 2021, Uniswap governance consists of ~5,000 unique delegates and 6,000 unique delegators. The first successful governance proposal was executed on December 27th, establishing a grants program to invest in the ecosystem’s future.

UNI logo

Vulnerabilities

A team of six software engineers reviewed and verified critical aspects of the smart contracts for Uniswap V2. The audit included investigation of the following:

  • Formal verification of the core smart contracts;
  • Code review of the core smart contracts;
  • Numerical error analysis; and
  • Code review of periphery smart contracts.

 

After the audit, these three bugs were reported and seven improvements were suggested:

  • Bugs
    • Router – incompatible with token with fees on transfer;
    • Pair – fix to liquidity deflation introduces race condition; and
    • Math – integer overflow in sqrt.

 

Considerations When Building on Uniswap

Uniswap opens itself up to various security vulnerabilities and manipulations by integrating with another on-chain system (Ethereum). There are two big risks associated with Uniswap V2. The first risk is called static errors. This is when one sends too many tokens to a pair during a swap (or requesting too few tokens back) or permitting transactions to linger in the mempool long enough for the sender’s expectations to pass price expirations. The second involves runtime pricing. For example, one could insert transactions before and after the naive transaction, causing the smart contract to trade at a worse price, profit from this at the trader’s expense, and then return the contracts to their original state. Uniswap believes that the best way to protect oneself from these attacks is to implement a price oracle. 

Users and LPs of Uniswap must consider impermanent loss. Impermanent loss is an opportunity cost that occurs when the price ratio of deposited tokens changes after you deposited them in the pool. If the ratio between tokens (ETH-AAVE) changes a lot, LPs may incur a loss in value rather than if they just held the tokens. The threat of this is somewhat offset by the fees that LPs accrue which do/could make up for any impermanent loss.    

Beyond the technical risks, Uniswap faces stiff competition in the crowded DEX landscape. The largest outstanding competitor for Uniswap’s volume is SushiSwap, a Uniswap fork with vampire mining and governance token included within. SushiSwap started as a copy of Uniswap, but now has a market capitalization of just under $1.8 billion. SushiSwap wins within valuation metrics P/S (price to sales) and P/V (price to volume ratio) due to its economic design and smaller market cap, but Uniswap’s overall volume and traffic has yet to be matched. Other "knock-offs" like Binance Chain's PancakeSwap, which is almost entirely a copy and paste of Uniswap's code, has also seen great traction thanks to Uniswap's efforts but Binance Chain's low fees.

Uniswap also has an open and ongoing bug bounty program.

UNI logo

Network Effect

Uniswap generated more than $15M in liquidity provider fees in 2020. The Uniswap protocol supported more than $58 billion in volume over the course of 2020, up 15,000% from $390 million in 2019. If the protocol "fee switch" was on, ~$830,000 of this would instead go to a decentralized funding mechanism used to support contributions to Uniswap and its ecosystem.

Liquidity pools bring together any number of distinct focused positions within one pool. By doing this, a liquidity pool can guess the shape of any automated market maker or active order book. This gives the ability for users to trade against the combined liquidity of all curves with no gas fee increases. Trading fees earned by collecting at a price range are split pro-rata by the liquidity pools appropriate to the amount of liquidity they contributed to. Uniswap V3 generated more than $6.5 billion in volume within 7 days of its genesis and became the top decentralized exchange on Ethereum behind V2 after only 3 days. 


UNI v2 vs v3
Image credit: Messari

This type of support boosts network effects from which Uniswap and its users benefit greatly. Incentivized contributions lead to increased protocol functionality and usage. Usage generates fees, which attract liquidity. Increased liquidity further entrenches Uniswap, attracting additional users, contributors, and integrations. This has led to Uniswap being the DEX market leader by a wide margin.

UNI maket share


Image credit: Dune Analytics

Uniswap V2 and V3 protocols account for ~25% of all Ethereum transactions. Since V3 launched in May 2021, they have seen over ~860,000 unique addresses swap on V2 and V3.  The average trade size on V3 is ~$3,400, doubling the average transaction on V2.


UNI active monthly users
Image credit: Dune Analytics

How do you rate this article?


131

4

Michael @ CryptoEQ
Michael @ CryptoEQ

I am a Co-Founder and Lead Analyst at CryptoEQ


CryptoEQ
CryptoEQ

Crypto is complex. We make it simple.

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.