This article looks at how Uniswap works, terms used by the platform, Layer 2 scalability additions, and the UNI token.
What is Uniswap?
Uniswap is a decentralized exchange (DEX) protocol built on top of the Ethereum blockchain network. Users can exchange ETH and ERC-20 tokens in a trustless manner. Unlike centralized exchanges the Uniswap exchange protocol enables users to trade directly from their personal non-custodial wallets. Rather than using centralized order books, the Uniswap crypto liquidity model is backed by automated market maker (AMM) technology and liquidity pools.
The Uniswap exchange protocol runs on open-source software, which has led to the rise of many clones that have been created by forking the codebase. Uniswap has no central authority in control of listings and doesn’t charge any listing fees. The protocol is public and permissionless, meaning anyone can list any ERC-20 token simply by creating an associated liquidity pool.
How Does the The Uniswap Exchange Work?
Uniswap uses Constant Product Market Maker (CPMM) - a variation of AMM technology also used by other popular ERC-20 DEXs like Bancor and Curve. AMMs are smart contracts that enable liquidity providers (LPs) to add or remove liquidity by interacting with a liquidity pool. On Uniswap, liquidity providers are required to deposit Ethereum (ETH) and an ERC-20 token (e.g. AAVE, DAI, COMP, or thousands of others) into a smart contract at a 50/50 ratio. Users who make trades on the Uniswap exchange pay a 0.3% fee, which is shared among all the liquidity providers in the same liquidity pool. In other words, liquidity providers have an opportunity to earn rewards for letting their idle funds sit in a smart contract. When a liquidity provider wants to redeem their funds, they can do so at any time by withdrawing from the smart contract.
Trading On Uniswap - Terms Explained
Uniswap supports trading of ETH and thousands of ERC-20 tokens. To make your first trade on Uniswap, you’ll need ETH to pay for gas fees. If you just want to sell ETH to buy an ERC-20 token, ETH is the only asset you’ll need to get started. However, the Uniswap exchange also supports trading unlimited trading pairs, meaning you can trade any ERC-20 for another ERC-20. Keep in mind you’ll still need ETH to gas for gas fees, though.
Looking at the example shown here, we’re looking to trade USDC for AAVE. You’ll notice a few interesting notes at the bottom of the trading interface. These are all related to how the Uniswap exchange AMM works. Let’s briefly summarize them.
Minimum received - Because prices are constantly changing with the AMM model, Uniswap can’t say for certain how much of a specific asset you (the trader) will receive in return. The protocol can only guarantee a minimum amount you’ll receive.
Price Impact - When making trades, there is sometimes a difference between market price and estimated price. For transparency, Uniswap provides the trader with this info upfront. This percentage. Is correlated with the size of the order. With smaller orders, the price doesn’t vary much but does for larger orders. On traditional exchanges, a more common phrase for this is “slippage.”
Liquidity Provider Fee - Each time you sell an asset, you pay a fee to liquidity providers in that asset. In this example, selling USDC means the trader news to pay a fee in USDC.
Route - The Uniswap exchange has a routing system to ensure that you are paying the lowest price for each trade. In some cases, trading may involve four or more tokens. Like in this example, we see the route is USDC>COMP>ETH>AAVE. This is basically what goes on in the background to make the trade happen. As an end-user, however, the trader doesn’t actually have to interact with the COMP and ETH in the middle of the route.
How to Make Your First Trade on Uniswap
- Navigate to app.uniswap.org and click “Connect to a wallet.”
2. Choose a supported wallet from the list. In this example, we select MetaMask.
3. (Optional) - Select ETH from the first drop-down box and choose another asset if you want to trade one ERC-20 token for another. Then choose an asset from the list. Don’t see your asset? Use the search functionality. If you want to trade ETH for an ERC-20 token, you can skip to step 4.
4. Click on “Select a token" to choose which asset you want to buy. Don’t see your asset? Use the search functionality.
5. Choose an amount you want to trade by either clicking "Max" to trade the entire balance of your selected asset or type a number in the field to the right. An equivalent amount in the other asset (based on real-time market prices) will automatically appear.
6. Click the “Swap” button. If you don’t have enough funds to complete the trade, you’ll have to enter a new amount in the trading interface and repeat this step.
7. You will receive a message that says "Waiting for confirmation." To start the trade click "Confirm" in your wallet (MetaMask in this example). The trade will then take place if you have sufficient funds. You will receive your new assets after the transaction is confirmed on the blockchain.
Liquidity Pools and Uniswap Impermanent Loss
What Is Impermanent Loss?
The term “impermanent loss” sounds complicated, but in practical terms, the concept is easy to understand. If you’re a liquidity provider on Uniswap, there’s an opportunity cost involved with depositing your funds in a smart contract. Let’s say you have 1 ETH (valued at a market price of $1,700 when depositing) and $1700 in USDC.
With the way that Uniswap works, it’s possible that the ratio of funds in the pool changes. If the price of ETH goes up, it’s easy to have Uniswap impermanent loss. That’s because arbitrage traders will add USDC to the liquidity pool and remove ETH from it until the ratio more closely reflects the market price. Let’s say a liquidity provider wants to withdraw their funds, and the result is that they end up with 0.8 ETH and 2,000 USDC.
While this is a net profit, what happens if the price of ETH goes up by a substantial amount while funds are essentially locked in the liquidity pool? The answer is “impermanent loss”, which means in some cases the potential rewards from providing liquidity are outweighed by the gains of just HODLing in a non-custodial wallet. The loss is “impermanent” because the liquidity pool ratio might balance out again and the collected fees might equal to higher profitability than the gains of just HODLing. Loss is only “impermanent” if the liquidity provider keeps funds in the smart contract liquidity pool. The loss actually becomes permanent as soon as funds are withdrawn from the liquidity pool, making Uniswap a somewhat risky way to try to make profits for liquidity providers.
Uniswap Tackles Impermanent Loss
In Uniswap v2, liquidity is distributed evenly along an x*y=k price curve, with assets reserved for all prices between 0 and infinity. According to Uniswap, a majority of this liquidity is never put to use. As a result, v2 liquidity providers only earn fees on a small portion of their funds, which can fail to appropriately compensate for Uniswap exchange impermanent loss. Additionally, traders are often subject to high degrees of slippage as liquidity is spread thin across all price ranges.
Uniswap v3, which goes live on the Ethereum mainnet on May 5, 2021, brings a major change to tackle the impermanent loss issue. Liquidity providers concentrate their capital within custom price ranges, so they can provide more or less greater amounts of liquidity at desired prices. Uniswap also touts that v3 is 4000x more capital efficient. This improvement also benefits traders because it enables low-spliggage trading (shown on Uniswap as price impact). Slippage percentages are even lower than centralized exchanges and stablecoin-focused AMMs.
Uniswap v3 and Ethereum 2.0 - Major UX Improvements
Uniswap published the highly anticipated Uniswap v3 Core whitepaer on March 23, 2021, which includes lots of details on what the future of the Uniswap exchange protocol will look like. Uniswap v3 addresses some of the fundamental issues that users face on Uniswap v2 - and on DEXs in general.
Liquidity providers now have the flexibility to set customized price ranges for how much capital they allocate to smart contracts, which mitigates the issue of impermanent loss. For liquidity providers, more people are asking what’s the Uniswap best strategy for success. Just because capital can be used more efficiently, doesn’t mean that all LPs will benefit equally. It’s likely that bots will take on a greater role because correctly guessing price trends and providing matching liquidity allocation is difficult and time-consuming. As a byproduct, liquidity positions are no longer fungible and are not represented as ERC20 tokens in the core protocol. Instead, LP positions will be represented by non-fungible tokens (NFTs).
For traders, Uniswap v3 adds a Layer 2 deployment of Optimistic Rollup in May 2021. This improvement will be highly beneficial as gas fees will go from around $40+ per trade on v2 to practically $0 in v3. This would make Uniswap practical for the average trader who might want to trade a couple hundred bucks or maybe even smaller amounts.
Prior to the official Uniswap v3 announcement, there was talk around the possible launch of an integrated non-fungible token (NFT) marketplace. However, there is no info to support that as of March 2021.
The Uniswap (UNI) Token
For nearly two years after its initial launch, the Uniswap exchange didn’t have a native token. The protocol amassed over $20 billion in trading volume, and became the top decentralized exchange in the crypto space. To support community-led growth, development, and self-sustainability Uniswap launched the Uniswap (UNI) token in September 2020. 60% of the UNI genesis supply was allocated to Uniswap community members, a quarter of which (15% of total supply) has already been distributed to past users.
The Uniswap coin (or Uniswap token) is used primarily as a governance token. The idea behind UNI, like any governance token, is to enable holders to have ownership in the major decisions that impact the future of the protocol. 1% of the total UNI supply is required to submit proposals. Voting takes place over a 7-day period, and 4% of the total UNI supply is required to vote ’yes’ to reach quorum. On December 25, 2020, Uniswap Grants Program v0.1 became the first governance proposal to pass, with a total of 60,088,813 Uniswap tokens voting for and only 9,300 voting against.
Uniswap continues to climb in trading volume on a month-by-month basis - showing just how far DEX adoption has ramped up. In less than two years, Uniswap went from an unknown to a juggernaut. It hasn’t been all smooth sailin, even with this unprecedented success. Uniswap competitors include not just ERC-20 DEXs but also BEP-20 DEXs like Pancakeswap and atomic swap DEXs like AtomicDEX are also gaining momentum. The good news for Uniswap fans is that the protocol’s developers are meeting the market challenges and continuing to build a robust protocol that is keeping up with the hyper-speed innovations of the crypto sector.
If you'd like to learn more about blockchain technology and keep up with Komodo's progress, subscribe to our newsletter. Begin your blockchain journey with Komodo today.