What is Uniswap and how does it work?

Updated on 21 September, 2022 2:21 PM
1 min read

Jump to:

    In the early days, if you were an apple farmer and wanted to buy unicorns, you would have to  find someone who wanted to trade your apples for their unicorns because there was no money! 

    Otherwise known as the "double coincidence of wishes", this was a really big limitation of the  bartering system, but move to the present day, and you no longer have to search for people if  you got money. 

    Traditionally, all cryptocurrency exchanges are centralized platforms where you trade with other  currency holders using fiat money. 

    In this article we will look at something unconventional. Uniswap

    What is Uniswap?

    Uniswap a permissionless, decentralized exchange that allows anyone to trade Ethereum ERC-20  tokens directly without the use of an intermediary. To understand what this really means, let's start by looking at how a traditional exchange like  CoinDCX or Binance works. 

    How does a centralized crypto exchange work?

    Traditional exchanges are centralized, meaning there is a proprietary company that has complete control over the exchange and the servers that run it. They are also regulated by KYC laws, which stands for “Know Your Customer”. These laws require every new customer to provide extensive personal information, including addresses and tax identification numbers before they can start doing business. Additionally, in order to trade, users must deposit money into the exchange, essentially giving the exchange control over their funds. 

    What are decentralized exchanges?

    Decentralized exchanges, also known as DEXs, are part of a decentralized financial ecosystem.  Decentralized finance, or DeFi for short, is what refers to traditional financial services such as currency exchanges, credit services, and insurance that have been decentralized using  Blockchain technology. 

    Now, unlike a traditional exchange that requires a managing company and centralized servers to operate, a DEX consists of a set of smart contracts deployed on the blockchain. Simply put, it is a set of automatic rules that are executed by a network of independent computers without any central entity controlling them. When using DEX, there is no need to create an account or go through an identification process. In addition, DEXs allow users to trade directly from their own wallets, allowing them to have full control over their funds. The key difference between a DEX and a traditional exchange is the way transactions are conducted and the price set. In a  traditional exchange, buyers and sellers set their price expectations as "Buy" and "Sell" orders in the order book. More buyers and sellers for an exchange mean a larger order book and more "liquidity”. In the absence of liquidity, the exchange is basically pointless because no trades can be made. 

    You can read more about the differences between centralized and decentralized here.

    What are liquidity pools?

    Liquidity on DEX is created through liquidity pools. Liquidity pools are a shared pool of funds deposited by the general public, and DEXs use liquidity pools to fulfill "buy" and "sell" orders.  People who put funds into liquidity funds are known as liquidity providers or LPs. In exchange for locked funds, LPs receive a portion of the DEX trading fees in a process known as liquidity mining.

    Now that we've covered all that, let's take a look at how the pricing is done. In a traditional exchange, when a seller and a buyer reach an agreement through matching orders in the exchange's order book, a trade occurs. At this point, the price of the coin is determined until another trade is made at a different price. In other words, the price of the last trade is considered to be the current price on the exchange. 

    On the other hand, a decentralized exchange does not have an order book. Users do not trade with one another, they trade within the liquidity pool. Here, instead of the last trade, a mathematical formula is used to determine the price. This formula or algorithm is called Automated Market  Maker or "AMM" for short. 

    Uniswap uses one such algorithm known as the “Constant Product Market Maker Model” to figure out the price of coins on its exchange. This AMM runs by the simple formula X times Y  equals K. This means that when trading, for example, BAT for Ether, the amount of BAT available times the amount of Ether available in Uniswap's BAT/Ether liquidity pool should always equal a constant number. 

    Let's understand this by imagining that there are 10 Ether and 10,000 BAT in a certain liquidity pool. As we can see, using the AMM model, this means that the number of ETH times the number of BAT equals 100,000, this is our constant K. If I bought 1 ETH, that would reduce the number of ETH in the pool to 9. Now the question is, how many BAT is that will cost? We can calculate this by taking our constant of 100,000 and dividing it by the new number of ETH, 9.  This would give us the new number of BAT required in our pool as 11,111. This means that to buy one ETH we need to deposit approximately 1 111 BAT.  

    As you can see, the price is determined by how much of a certain token you want to buy, not how much someone else wants to get for it. This model makes it impossibly expensive to consume the entire amount of a certain coin. For example, if you wanted to buy 9 ETH, it would cost you 90,000 BAT to keep 100,000 constant, so each ETH would cost 10,000 BAT instead of the 1,111 DAI it would cost you to buy just 1 ETH. 

    Now that we've covered DEX, let's dive deeper into Uniswap. Uniswap is a DEX built on the Ethereum network infrastructure. It is a set of automated rules used to trade ERC-20 tokens, a  term given to a certain Ethereum token standard. It is the most popular decentralized application or DAPP on the Ethereum platform, with hundreds of thousands of users trading on it every week. Plus, it's one of the most forked projects in the DeFi space, meaning people are using its code to build other apps.  

    The first version of Uniswap started in November 2018. Uniswap's V1 (Version 1) allowed any  ERC-20 token to be traded to and from Ether. In May 2020, V2 was released and trading ERC 20 tokens directly between each other was available without having to trade with Ether first. In  May 2021, V3 was released, allowing more efficient use of capital for anyone who chooses to supply liquidity to Uniswap. In other words, you can squeeze more "juice" out of the money you put into the liquidity pool. Trading has also become more efficient and reduced trading costs compared to V2. Other changes include concentrated liquidity, active liquidity, spread orders, flexible fees, and more.

    How to get started with Uniswap?

    It's rather simple, all you need is an Ethereum wallet like Metamask that can communicate with other Ethereum applications. Once you have Metamask installed in your browser, go to  Uniswap and connect your Metamask wallet. As many people trade on Uniswap at the same time, the price shown when you place an order may differ from the actual price when the order is executed.  

    This effect is called "Slippage" and you can limit how much slippage you are willing to tolerate before canceling the order. The reason for the slippage is that each trade on Uniswap is actually an Ethereum transaction and it may take some time for the transaction to be sent and confirmed by the Ethereum network and the price may vary while the transaction is being verified.  

    Another fun fact is that virtually anyone can create their own token and list it on Uniswap for free but unlike a traditional exchange that does extensive due diligence and examines every coin added to its platform, Uniswap doesn’t. But nonetheless, this platform delivers a lot of much-needed conveniences, and the future for tools like these sure looks plenty bright!

    Like this article? Spread the word

    Subscribe to our

    Receive timely updates on new posts & articles about crypto world.