logo academy

Uniswap: DeFi’s first exchange

February 22, 2024

11 min

Uniswap: DeFi’s first exchange
Beginner

What is Uniswap, the first DEX ever created, launched in 2018 on the Ethereum blockchain? And how does UNI, its governance token, work? It is available from 2020, two years after the release of Uniswap.

In this article, we look at the project that invented the concept of a decentralised exchange as we know it today, which has remained one of the most robust and widely used. Find out what Uniswap is, how it works, and all the new features of version 4.

The first successful DEX

Uniswap is primarily a Decentralised Exchange (DEX), i.e. a cryptocurrency exchange platform that is not controlled by any intermediary or company but is entirely reliant on smart contracts and algorithms. 

Thanks to its key features, Uniswap is the first such project to achieve real success. 

Ease of use

Understanding Uniswap means knowing how the first solid and truly functioning DEX works. Decentralised token exchange solutions built before this platform were very complex; Uniswap, on the other hand, comes with a very intuitive interface, especially the swap section.

Liquidity Availability

Decentralised exchanges have always had liquidity problems. To allow traders to execute orders at any time, it is necessary always to have a large and active supply and demand for all assets. In other words, it is essential to have liquidity available at all times.

Uniswap solved this gap by introducing an Automated Market Maker and an incentive programme for liquidity provision, which we will discuss later.

Automated Market Makers (AMMs) are a series of smart contracts that determine prices with an algorithm and use liquidity pools to execute orders automatically. 

The core of DeFi

To summarise in very few words what Uniswap is and how it works, the protocol gave birth to DeFi, allowing so many tokens to have a market and emerge. As a result, traders could buy brand-new cryptocurrencies unavailable on any other platform.

SushiSwap’s attack and UniSwap’s comeback

In May 2020, V2 was released with substantial improvements, and by the summer of that year, Uniswap was seeing daily volumes above $1 million. The team grew and raised Series A funding from four Venture Capitals while riding on the glory.

With autumn came the first big hurdle: SushiSwap launched an offer to take away users and liquidity providers from Uniswap and succeeded. 

This ‘vampire attack’ drained Uniswap’s liquidity, but the team was not unprepared and was already working on V3. 

Not only that but a few days after the attack, the UNI token arrived on the market with a large airdrop for all those who had already used the protocol. The UNI token was immediately listed by the most extensive international exchanges at an outclass speed. Uniswap had taken back the scene in two ‘simple’ moves.

Version 3: A Real Breakthrough

Version 3 brought together several features that marked a turning point for the project and all the later DEX. Many, especially to make up for the lack of such platforms on other networks, proudly advertised themselves as forks of Uniswap to emphasise the high quality of the smart contracts they comprised. 

The protocol update was activated on 5 May 2021 on Ethereum and is still the last to have been implemented. Version 4 is expected to arrive in the first half of 2024.

The keyword of V3 was ‘customisation‘. From then on, users had more freedom of choice about three main functionalities:

  • The provision of liquidity, thanks to concentrated liquidity
  • Token swaps, thanks to range orders
  • Fees, thanks to the addition of flexible commissions

What is Concentrated Liquidity?

Let’s start with the concept of Liquidity Provider (LP). 

LPs are users who deposit their tokens in liquidity pools to obtain an incentive as a reward.

Liquidity pools are one of the main instruments of decentralised exchanges. They are ‘containers’ of large quantities of token pairs. The liquidity that the pools contain serves the exchange to conduct token exchanges.

Providing liquidity in V2

In V2, any liquidity provider (LP) on Uniswap would lock its token pairs in a pool to receive a periodic interest in UNI or other tokens.

The LP would deposit an equal amount for both tokens, making up the pair concerned. The AMM then takes the number of tokens it needs to execute an order at a specific price from the pool.

Providing liquidity in V3

In V3, on the other hand, the LP also decides for which price range to provide liquidity. So you will have a lot of liquidity for a specific price range, hence the term ‘concentrated liquidity‘. 

Let’s take an example by comparing the strategy of an LP V2 and an LP V3.

Supplying Liquidity in V3: Example

Alice and Bob want to provide liquidity to an ETH/DAI pool on Uniswap v3.They have $1 million each.The current price of ETH is 1,500 DAI.

uniswap v3

Alice decides to distribute her capital over the entire price range (as she would have done in Uniswap V2). She deposits 500,000 DAI and 333.33 ETH (for a total value of $1 million).

Bob instead creates a concentrated position, depositing only in the price range of 1,000 to 2,250. He deposits 91,751 DAI and 61.17 ETH, for a total value of about $183,500. He keeps the other $816,500, using it as he wishes.

Although Alice deposited 5.44 times more capital than Bob, they earned the same amount of commission as long as the price of ETH/DAI remained within the range of 1,000 to 2,250.

If the price of ETH falls to $0, Alice’s and Bob’s liquidity will be fully converted into ETH. However, Bob will only have lost $159,000 compared to Alice’s $1 million.

Bob can use his additional $816,500 to protect himself against risk or in any other functionality.

Range Order

V3 also introduced range orders.

Range orders allow you to limit orders to a specific price range.

It works like this: 

  • the user selects an A-B pair and deposits the single token A he wants to convert into token B.
  • Selects a price range within which token A will be converted. The price range may be above or below the current price of A.
  • If the market price enters the selected price range, token A is progressively replaced by token B, following a smooth curve.
  • Together with token B, you also receive swap fees.

Suppose Alice wants to use a range order:

range order
  1. Alice deposits 1 million DAI in the DAI-USDC pair when the price of DAI is 1,000 USDC. 
  2. Select range 1.001-1.002. 
  3. The range order is usually executed at the average price between the two selected extremes.
  4. Thus, according to the curve, when the price of DAI reaches 1.0015, Alice will already have converted half of her DAI into USDC.Once DAI reaches 1.002, on the other hand, Alice will have about 1 million USDC Not only that, she will also have the commission she is due for providing liquidity in DAI at an asking price.

There is one more precaution to be taken once the order is completed: in order not to risk that the USDCs get converted back into DAIs when the price returns to the selected range, Alice must withdraw USDCs from the range order functionality.

Flexible fees

The fees on Uniswap are the commissions to be paid to the exchange and at the same time, the rewards for LPs.

Uniswap v3 offers LPs three separate commission levels per pair – 0.05%, 0.30% and 1.00%. This variety of options ensures that LPs adjust their provision according to the expected volatility of the pairs: LPs take a higher risk in particularly volatile pairs such as ETH/DAI and, conversely, take a lower risk in pairs such as USDC/DAI, as both currencies are pegged to the dollar.

Similar token pairs are expected to assume the 0.05% fee level, and pairs such as ETH/DAIs are expected to use the 0.30% fee level, whereas for more recently launched and more complex tokens, 1.00% is more appropriate given the level of risk.

Thanks to ‘customisation‘, traders can optimise their operations. The most significant improvements resulting from this are as follows:

  • LPs can provide liquidity with up to 4000 times the capital efficiency of Uniswap v2, earning higher returns on their liquidity just like Bob did!
  • Capital efficiency paves the way for executing low-price swaps (slippage).
  • Thanks to concentrated liquidity, LPs can significantly increase their exposure to preferred assets and reduce the percentage of risk of loss.
  • The possibility of placing not only market orders but also range orders, thus expanding one’s trading strategies.

Uniswap: what’s new

We must address the upcoming protocol update to answer what Uniswap is and how it works thoroughly. With the arrival of the new version, which can only be implemented after activating the Ethereum Cancun update, the platform will continue improving its customisation and security logic. Here’s how in detail.Introduction of ‘hooks’ and increasingly customisable pools: In v4 of Uniswap, it will be possible to introduce commands that will be activated at crucial points in the life cycle of a pool, such as before or after a ‘swap’. These hooks can be customised to set dynamic fees based on the price volatility of the crypto in question. This will make it easier to avoid MEV attacks. 

Scams occur when a bot places a large purchase order before one or more orders from ‘normal’ users. After executing the user’s order, the attacker immediately sells the same token amount, exploiting the price variation caused by its initial order and the transactions within this ‘sandwich’.

Singleton’s architecture: in v4, all pools will be combined into one smart contract. According to the development team, this will save users a considerable amount of gas fees, up to 99%, because swaps will no longer have to transfer tokens between pools held in different smart contracts.

If you’ve read this entire article, you can certainly claim to know what Uniswap, DeFi’s first decentralised exchange, is and how it works. 

Related