The burgeoning decentralized finance (DeFi) ecosystem aims to use decentralized, non-custodial financial products to replace centralized middlemen in financial applications such as loans, insurance and derivatives.
Uniswap is an example of one of the core products in the DeFi ecosystem, the decentralized crypto exchange, or DEX. DEXs aim to solve many of the problems of their centralized counterparts, including the risk of hacking, mismanagement, and arbitrary fees. However, decentralized exchanges have their own problems, mainly lack of liquidity—which means a lack of amount of money sloshing around an exchange that makes trading faster and more efficient.
Uniswap is trying to solve decentralized exchanges' liquidity problem, by allowing the exchange to swap tokens without relying on buyers and sellers creating that liquidity.
Below we explore how Uniswap works—and how it became one of the leading decentralized exchanges built on Ethereum.
What is Uniswap?
Uniswap is a protocol on Ethereum for swapping ERC20 tokens. Unlike most exchanges, which are designed to take fees, Uniswap is designed to function as a public good—a tool for the community to trade tokens without platform fees or middlemen. Also unlike most exchanges, which match buyers and sellers to determine prices and execute trades, Uniswap uses a simple math equation and pools of tokens and ETH to do the same job.
What’s so special about Uniswap?
Uniswap’s main distinction from other decentralized exchanges is the use of a pricing mechanism called the “Constant Product Market Maker Model.”
Any token can be added to Uniswap by funding it with an equivalent value of ETH and the ERC20 token being traded. For example, if you wanted to make an exchange for an altcoin called Durian Token, you would launch a new Uniswap smart contract for Durian Token and create a liquidity pool with–for example–$10 worth of Durian Token and $10 worth of ETH.
Where Uniswap differs is that instead of connecting buyers and sellers to determine the price of Durian Token, Uniswap uses a constant equation: x * y = k.
In the equation, x and y represent the quantity of ETH and ERC20 tokens available in a liquidity pool and k is a constant value. This equation uses the balance between the ETH and ERC20 tokens–and supply and demand–to determine the price of a particular token. Whenever someone buys Durian Token with ETH, the supply of Durian Token decreases while the supply of ETH increases–the price of Durian Token goes up.
As a result, the price of tokens on Uniswap can only change if trades occur. Essentially, what Uniswap is doing is balancing out the value of tokens, and the swapping of them based on how much people want to buy and sell them.
What else is different about Uniswap?
Absolutely any ERC20 token can be listed on Uniswap–no permission required. Each token has its own smart contract and liquidity pool–if one doesn’t exist, it can be created easily.
Once a token has its own exchange smart contract and liquidity pool, anyone can trade the token or contribute to the liquidity pool while earning a liquidity provider fee of 0.3%. To contribute to a liquidity pool, you need an equal value of ETH and ERC20 tokens.
Uniswap V2 and V3
Though Uniswap launched back in November 2018, it wasn't until relatively recently that the protocol began to see significant traction.
The release of Uniswap V2 in May 2020 saw a major upgrade that allows for direct ERC20 to ERC20 swaps, cutting Wrapped Ether (WETH) out of the equation where possible. Uniswap V2 also added support for incompatible ERC20 tokens like OmiseGo (OMG) and Tether (USDT), and added a host of technical improvements that make it more desirable to use.
As liquidity mining and yield farming platforms dramatically increased in popularity in 2020, Uniswap saw a corresponding surge in interest, since many DeFi platforms allow Uniswap liquidity providers to see an additional return on their LP tokens.
This, in combination with the 0.3% exchange fees distributed to liquidity providers—and the platform’s popularity as a launchpad for popular DeFi project tokens—has seen Uniswap rise the ranks to become one of the leading DeFi platforms by total value locked (TVL)—a measure of the total value of crypto assets locked up in the platform.
In May 2021, Uniswap V3 launched, with the latest iteration of the DEX adding a number of new features. First up is concentrated liquidity, which enables liquidity providers to allocate liquidity within a custom price range. That, in turn, means that traders don't have to put as much capital on the line to achieve results.
V3 also adds more fee tiers, enabling traders to better determine their risk level when trading volatile assets (which can change in price between when a trade's initiated and executed). It also adds "easier and cheaper" oracles, which ensures that the DEX's price data is up to date.
Finally (and perhaps least essentially) it also generates non-fungible tokens (NFTs) based on LP positions, turning them into "on-chain generated art".