How Decentralised Exchanges Work: Uniswap Case Study

Welcome. If you’re new to Decentralized Africa’s Case Studies, allow us to take a look at certain decentralized technologies and simplify how they operate. In this piece, we are going to look at Uniswap, a name that is almost unavoidable in the DeFi world and has been a successful proponent of some of the sphere’s best innovations, including liquidity pools.
What is a decentralized exchange?

Let’s take a gentle step backwards. A decentralized exchange is a peer-to-peer online service that allows two interested parties to make direct cryptocurrency transactions without having to go through a central server.


Decentralized exchanges exist because of the numerous problems with centralized exchanges (CEX). Where CEXs store your data on a central server, hold your wallet keys, and control things that many users don’t want to be controlled, DEXs instead create new p2p markets directly on the blockchain, they give traders autonomy over their crypto and wallet keys, and they remove the third-party influence that many traders feel is a conflict of interest.

Why are we writing about Uniswap?

Uniswap is essential to what Decentralised Exchanges are trying to achieve. Uniswap allows people to exchange ERC-20 tokens on Ethereum, which, in simple terms, means that any cryptocurrency built on the Ethereum platform (over 200,000 types) can benefit from their technology.


Uniswap is open-source software that removes the need for intermediaries (central servers) and some forms of rent-seeking (which is seen as quite annoying), as well as making DEX trading faster and more efficient than it was before. The protocol is also more resistant to censorship and places great importance on security.


In simple terms, Uniswap provides the liquidity that makes it possible for DEXs to compete with CEXs.


Is it easy to get a token listed on the exchange?

Easy? Easy! It’s almost unchallenged. Because Uniswap is a completely decentralized protocol, there is no listing process, so any ERC-20 token can be launched with the tiny caveat that they require a liquidity pool for traders to use.


Uniswap is designed for the good of the DeFi world, so there is no listing fee and no ongoing fees either. How generous.


Who are the brains behind the operation?

Depending on who you ask, you might get one of two answers. The concept was initially proposed by Vitalik Buterin, one of the biggest and most well-known figures in the crypto sphere, for his role as co-Founder of Ethereum. However, the Uniswap protocol was eventually created by Hayden Adams, back in 2018.

From humble beginnings, Uniswap can now boast…

  • 16,923 Token Pairs
  • $234M 24H Volume
  • $3.1B Total Liquidity
  • >100 DeFi Integrations 
How does Uniswap explain the workings of their system?

We could spin, flip, and rewrite their explanation 100 times over, but ultimately, Uniswap’s own explanation of their system is the most succinct:


“Uniswap is an automated liquidity protocol. In practical terms, this means there are template smart contracts that define a standard way to make liquidity pools and corresponding markets that are compatible with each other. There is no order book, no centralized party and no central facilitator of trade. Each pool is defined by a smart contract that includes a few functions to enable swapping tokens, adding liquidity and more. At its core, each pool uses the function x*y=k to maintain a curve along which trades can happen.”


If that wasn’t detailed enough, a more technical description (assisted by graphics) can be found here.


How does their algorithm determine coin prices?
  1. The first factor is the amount of a token available in a liquidity pool
  2. The smart contract keeps the liquidity pool’s pairing constant with the x*y=k function, meaning x = example token 1, y = example token 2, and k = constant
  3. When a trade goes through, some tokens have to been removed from either side of the pair to keep the constant
  4. To maintain this constant, the prices must change based on the trade and the balances held by the smart contract

Here’s an example:

Our crypto-trader friend John wants to buy one Bitcoin. He buys that 1BTC for 11,000USDT (Tether). As that trade goes through, there’s now 1 less BTC in the liquidity pool and 11,000 more USDT. As a result, the price of BTC goes up to reflect its reduced supply in the pool. This is the algorithm that determines the pricing. What this also means is that if John buys 100BTC in one order, the price will change more dramatically than 1BTC. To counteract that effect, Uniswap incentivises very large liquidity pools so that the slippage is reduced. The bigger the liquidity pool, the lower the ratio of slippage when a big order goes through.


Does it cost to use a DEX?

There is a small cost, known as Ethereum Gas. You can visit an ETH gas station to find out exactly how much it costs to complete a transaction. Forming a new liquidity pool on Uniswap will cost more Ethereum than making purchases or sales will, that’s because the smart contract behind a Uniswap pool is more complex.


Why is this case study important?

Viable technologies in the DeFi world need exposure, they need to be discussed, and they need to be applied by developers. On the other side, they need to be simplified and understood by novice investors and beginner traders so that they aren’t overwhelmed by the technical nature, and so that these people can see that services like Uniswap are allies of the DeFi movement.

Leave a Reply

Your email address will not be published. Required fields are marked *