TL;DR: You can get a summary of this article on its last section
Uniswap is an open-source decentralized exchange (DEX) that swaps ETH and ERC-20 tokens. As a collection of smart contracts, trade happens in Uniswap with no centralization, fully on-chain. Uniswap does not use a token and completely does away with the concept of an order book.
This article is a guide to the fundamentals behind Uniswap. We will cover the history and technology behind the protocol, its future, as well as its market maturity and the state of its ecosystem.
In presenting this guide and review of Aave, I will divide my analysis into 5 sections, each containing a salient feature of the project, as follows:
Uniswap was created by Hayden Adams, a mechanical engineer who was hoping to get some experience in Solidity, the programming language of Ethereum smart contracts. Adams ran into a post by Vitalik Buterin of Ethereum proposing a new kind of DEX.
Vitalik goes on to describe a system with an on-chain automated market maker (AMM) and built-in pricing mechanisms and dynamics. Adams took this as a practice exercise but eventually received a $100k grant from the Ethereum Foundation.
In April 2019, Uniswap received a $1M seed round from Paradigm which was used to build Uniswap v2 according to the Uniswap Whitepaper . Just a few weeks ago, in August 2020, Uniswap announced an $11M Series A round led by Andreessen Horowitz which will be used to build Uniswap v3.
Uniswap was created to address problems with existing decentralized exchanges. Whereas 0x -based relayers provided non-custodial trading, they handled all trading logic on private servers, due to the slow performance of their smart contracts. This led to, for example, IDEX being pressured into instituting KYC procedures and blocking access to certain IP addresses.
Uniswap’s unique architecture allows it to create a fast and efficient trading environment that’s fully on-chain. Uniswap does this by doing away with order books completely, relying instead on liquidity pools. In a traditional order book model, market makers place tiered bids on both the buy and the sell price, and profit from the spread. The price displayed to the other becomes the mid-market price. Doing order book matching would require an enormous amount of data requests to fill different orders at the same time.
The model used by Uniswap is called constant product market maker model (CPMMM), a variant of AMM. Prices are set according to a deterministic algorithm, following the simple logic of maintaining a constant
x * y = k relationship between the liquidity of trading pairs on any market.
Another major headache of DEXs is the need to obtain liquidity. Uniswap provides an one-time mechanism to provide liquidity, which makes it attractive to market makers. A market maker or liquidity provider (LP) on Uniswap gets a cut of the 0.30% of fees per trade according to his share of the liquidity pool. So, by depositing ETH into a Uniswap contract, one can get a share of the 0.30% fees on each trade without ever adjusting buy and sell bids to keep up with the market.
The impressive growth of Uniswap proves. Total value locked (TVL) and 24-hour volume have both surpassed $1B in recent days, and Uniswap has taken the no.1 spot in TVL with $1.7B locked and also surpassed the daily volume of giants like Coinbase . Clearly, Uniswap has become the most dominant DEX, albeit it is only functioning on Ethereum.
To really understand the success of Uniswap one must consider the simplicity in its design and mechanics.
Take, for example, a trading pair between ETH
. We know from the formula
x * y = k that the relationship between the two pairs must be inverse. That is to say, if the pool is set up with 1,000 ETH and 100,000 DAI, to maintain the constant 100,000,000 at all times, then if we take 1 ETH out of the pool, we must add 100.10 DAI. That gives us a price, in this example, of $100.10 per ETH. Conversely, to take 100 ETH, we would need 111,111.11 DAI for a price of $111.11 per ETH. As can be seen, the price doesn’t change linearly. To avoid significant slippage, pools must have sufficient liquidity.
To provide liquidity, one must add equal parts of both assets to the contract. For example, if a contract has 900 ETH and 90,000 DAI, for a user to add 100 ETH he must add 10,000 DAI as well. The LP is given minted “UNI” tokens equivalent to 10% of outstanding supply. Once the LP decided to draw its liquidity, the “UNI” tokens are burnt.
By now you may be thinking that the price of ETH is not $100, but higher ( as of this writing). Whenever the price of Uniswap is out of sync, an arbitrage opportunity is presented. In this case, users will come and buy ETH in Uniswap at and sell it elsewhere at the market price, pocketing the spread, until the spread disappears. Meanwhile, liquidity providers will make 0.30% off of these trades.
There are, of course, risks to LPs in this model which are outside the scope of this guide. Suffice it to say that, for any given trading pairs, if price swings are too drastic in either direction and the volumes are low, LPs are likely to suffer what is called an impermanent loss that fee earnings won’t be able to overcome.
Uniswap has no token of its own.
According to CoinMarketCap , the pairs with the most volume on Uniswap are:
|Trading Pair||Volume (%)|
Together these 5 pairs accounted for over 53% of the volume in the last 24 hours.
Uniswap ecosystem players are liquidity providers, traders, and developers. Each of them plays an important role in the growth of Uniswap. Traders are the main users of any exchange, they pay 0.30% to get their tokens swapped. This fee goes to liquidity providers, while developers integrate Uniswap to power trading or retail experiences in their dApps among other use cases.
Uniswap v3 has been announced, albeit no features have been confirmed, it is widely expected that a governance token with both economic and voting rights is launched.
In the meantime, a dev can find all of the guiding and tooling he needs to integrate Uniswap on the Uniswap docs . Uniswap maintains an SDK written in TypeScript to build interfaces that link to Uniswap. There’s the possibility to take the smart contracts from Uniswap and adapt them to your application, with Uniswap providing a testing environment as well. The Uniswap API is to retrieve data about Uniswap — this data is organized and not meant to be used for structuring transactions (where live data from contracts is ideal).
It is to note that Uniswap is an open protocol, anyone can create an ERC20 token and list it on Uniswap.
The SushiSwap challenge 🍣
Perhaps as a preemptive strive to Uniswap v3, or maybe because there is some hostility from some corners in Crypto towards VC-backing, the truth is many early (and semi-professional) LPs seem to feel sidelined by the growth of Uniswap, as their percentage of the pool has been diluted by better-capitalized players. In response, an anonymous group of degen devs announced an “evolution of Uniswap”
that introduced a governance token. They named the project SushiSwap and the token
SUSHI together with a Yam
-inspired interface with heavy emoji 👨🏼🍳 use. The governance token proposes new tokenomics, with the 0.30% fee for trades split as 0.25% for LPs with 0.05% getting conveyed to SUSHI
and going to existing SUSHI holders. SUSHI can be earned by providing liquidity, and initially by staking Uniswap liquidity tokens from a select number of pools into SushiSwap as part of a plan the team calls The Liquidity Migration™ which has been labeled by the Crypto experts as vampire mining as eventually liquidity in these pools will be migrated to SushiSwap.
What initially seemed like a memecoin project, eventually brought into its pools $800M or 80% of total Uniswap assets the weekend after its announcement. While the Uniswap team has warned of the risks of putting what now is $1B in a project that is but days old and as a “whale game”, Binance and others have listed SUSHI while Quantstamp audited its codebase. In some ways, many have turned this into some sort of contest between so-called elites and anons*. Definitely the hottest controversy in Crypto this year, and maybe since *the DAO incident or Bitcoin’s first fork.
Whatever happens with SushiSwap , we will know in a week. The whole community will see whether this is another project that gamblers are going to farm to zero, or a moonshot takeover of a successful and well-respected DeFi leader, as well as the repercussions of so much liquidity being sucked out of Uniswap.
Uniswap’s elegant implementation of a simple econometric equation led to the resurgence of demand in decentralized exchanges. While Uniswap has championed openness and ease-of-development for the community at large to benefit from its utility, it remains a work-in-progress, particularly in remaining a sustainable and self-governable protocol moving into the future.