TL;DR
Uniswap is a set of computer programs that run on the Ethereum blockchain and facilitate decentralized token swaps. It works with the help of unicorns (as illustrated by its logo).
Traders can exchange Ethereum tokens on Uniswap without having to trust anyone else with their funds. Meanwhile, anyone can lend their crypto to special reserves called liquidity pools and earn fees in return.
How do these magical unicorns convert one token to another and what do you need to use Uniswap? Keep reading to find out.
Introduction
Centralized exchanges (CEXs) have been the backbone of the cryptocurrency market for years. They offer short settlement times, high trading volume, and continually improving liquidity. However, there’s a parallel world being built in the form of trustless protocols. Decentralized exchanges (DEXs) require no middlemen or custodians to facilitate trading.
Due to the inherent limitations of blockchain technology, building DEXs that meaningfully compete with their centralized counterparts is challenging. Most DEXs have significant room for improvement when it comes to performance and user experience.
Many developers have been pondering new ways to build a DEX, with one of the pioneers being Uniswap. Compared to a regular DEX, how Uniswap works may be a bit more difficult to understand. However, it does feature several attractive benefits.
In fact, Uniswap has become one of the most successful projects in the decentralized finance (DeFi) movement. Let’s take a look at what Uniswap is, how it works, and how you can swap tokens on it with an Ethereum wallet.
What Is Uniswap?
Created by Hayden Adams in 2018, Uniswap’s implementation was inspired by underlying technology that was first described by Ethereum co-founder Vitalik Buterin.
Uniswap is a DEX protocol built on Ethereum — more precisely, it is an automated liquidity protocol. Thanks to its high degree of decentralization and censorship resistance, Uniswap allows users to trade without intermediaries, order books, or any centralized party. Uniswap also uses open-source software that you can check out on the Uniswap GitHub.
But how do trades happen without an order book? Well, Uniswap uses a model that entails liquidity providers (LPs) creating liquidity pools. This system provides a decentralized pricing mechanism that essentially smooths out order book depth. This also allows users to seamlessly swap ERC-20 tokens without the need for an order book.
Since the Uniswap protocol is decentralized, there is no listing process. Essentially any ERC-20 token can be launched on Uniswap as long as there is a liquidity pool available for traders. As a result, Uniswap doesn’t charge any listing fees, either.
How Does Uniswap Work?
Uniswap eschews the traditional architecture of a digital exchange by using a design called Constant Product Market Maker — a variant of a model called Automated Market Maker (AMM) — instead of an order book.
AMMs are smart contracts that hold liquidity reserves (or liquidity pools) against which traders can trade. These reserves are funded by LPs, i.e., anyone who deposits an equivalent value of two tokens in a pool. In return, traders pay a fee to the pool that is then distributed to LPs in proportion to their share of the pool.
The two tokens an LP deposits can either be ETH and an ERC-20 token or two ERC-20 tokens. These pools are commonly made up of stablecoins such as DAI, USDC, or USDT, but this isn’t a requirement. In return, LPs receive “liquidity tokens”, which represent their share of the entire liquidity pool. These tokens can be redeemed for the share they represent in the pool.
Let’s consider the ETH/USDT liquidity pool. We’ll call the ETH portion of the pool x and the USDT portion y. Uniswap takes these two quantities and multiplies them to calculate the total liquidity in the pool, which we’ll call k. The core idea behind Uniswap is that k must remain constant. As such, the formula for pool’s total liquidity is:
x * y = k
So what happens when someone wants to make a trade? Let’s say Alice buys 1 ETH for 300 USDT using the ETH/USDT liquidity pool. By doing so, she increases the USDT portion and decreases the ETH portion of the pool. This effectively means that ETH price goes up.
Why? There is less ETH in the pool after the transaction, and we know the pool’s total liquidity (k) must remain constant; this mechanism is what determines the token price. Ultimately, the price paid for this ETH is based on how much a given trade shifts the ratio between x and y.
It’s worth noting that this model does not scale linearly. The larger the order, the more it shifts the balance between x and y. This means that larger orders become exponentially more expensive than smaller orders, leading to increasingly greater slippage. It also means that the larger a liquidity pool is, the smaller the shift between x and y and hence, the easier it is to process large orders.
Uniswap v3
The technology behind Uniswap has undergone several iterations, with the latest and most significant being Uniswap v3. Here’s what the most recent update means for Uniswap.
Capital efficiency
One of the most significant changes of Uniswap v3 relates to capital efficiency. Most AMMs are largely capital-inefficient — most of the funds they contain at any given moment are not in use. This is due to an inherent characteristic of the aforementioned x*y=k model. Simply put, the more liquidity the pool has, the larger the orders the system can support, and in a larger price range.
LPs in these pools provide liquidity for a price curve between 0 and infinity. Therefore, the capital provided by LPs in an AMM is evenly distributed across all price ranges. This means only a portion of the liquidity in the pool sits where most of the trading is taking place.
Uniswap v3 seeks to addresses this issue — LPs can now set custom price ranges for which they want to provide liquidity, which should result in more concentrated liquidity in the price range with the most trading activity. For example, if an LP sets a price range of $1,000 to $2,000, the liquidity provided can only enable trading between these two prices, instead of within infinite price ranges.
In some sense, Uniswap v3 is a rudimentary way of creating an on-chain order book on Ethereum, where market makers can decide to provide liquidity in the price ranges they set. It’s worth noting that this change favors professional market makers over retail participants, though the beauty of AMMs is that anyone can provide liquidity and put their funds to work.
However, with this additional layer of complexity, less active LPs will earn much less in trading fees than professional players who are able to constantly optimize their strategy. At the same time, it’s not hard to imagine aggregators like Yearn.finance offering retail LPs a way to remain somewhat competitive in this environment.
Uniswap LP tokens as NFTs
Since each LP can set their own price range, each Uniswap LP’s position is unique and as such, no longer fungible. As a result, each LP’s position is now represented by a non-fungible token (NFT) — a digital image that displays essential information like the token pair and a curve representing the position’s “steepness”.
Uniswap v3 LPs now see all fees generated directly in the NFTs themselves. These NFTs can be traded between wallets and the holder can always collect position fees. It’s basically a digital image that displays essential information, such as the token pair and a curve representing the position’s “steepness”. Each Uniswap v3 position also has a unique color scheme, and different pools are represented by different color variations.
Uniswap on Layer 2
Historically, Ethereum transaction fees have been on the rise as network usage has increased. This makes using Uniswap economically unfeasible at times, especially for smaller users.
To solve this problem, Uniswap v3 uses Layer 2 scaling solutions to scale smart contracts while still enjoying the security of the Ethereum network. In addition, this implementation helps to increase transaction throughput and lower fees for users.
What Is Impermanent Loss?
Aside from earning fees for providing liquidity to traders who can swap between tokens, LPs should also be aware of an effect called impermanent loss.
Let’s say Alice deposits 1 ETH and 100 USDT in a Uniswap pool. Since the token pair needs to be of equivalent value, the price of 1 ETH is 100 USDT. At the same time, there are a total of 10 ETH and 1,000 USDT in the pool — the rest funded by other LPs like Alice. This means she has a 10% share of the pool, which has a total liquidity (k) of 10,000.
If ETH price increases to 400 USDT, it means the ratio between how much ETH and how much USDT is in the pool has changed — there are 5 ETH and 2,000 USDT in the pool now because arbitrage traders have added USDT to the pool and removed ETH from it until the ratio accurately reflected the price.
Alice decides to withdraw her funds and gets 10% of the pool, according to her share. She gets 0.5 ETH and 200 USDT, totaling 400 USDT, which makes it seem like she’s made a tidy profit. But what would have happened if she hadn’t put her funds in the pool? She’d have 1 ETH and 100 USDT, totaling 500 USDT.
In fact, Alice would have been better off HODLing rather than depositing into the Uniswap pool. In this case, impermanent loss is essentially the opportunity cost of pooling a token that appreciates in price. This means that by depositing funds into Uniswap in hopes of earning fees, Alice lost out on other opportunities.
Note that the above scenario applies whether the price rises or falls from the time of the deposit. This means that if the price of ETH decreases from the time of the deposit, the losses incurred by the LP may also be amplified.
But why is the loss labeled “impermanent”? If the price of the pooled tokens returns to the same price as when they were added to the pool, the effect is mitigated. And since LPs earn fees, the loss may be balanced out over time. Even so, LPs must be aware of this before adding funds to a pool.
How Does Uniswap Make Money?
It doesn’t. Uniswap is a decentralized protocol backed by crypto hedge fund Paradigm. All fees go to LPs and none of the founders get a cut from the trades that happen through the protocol.
Currently, the transaction fee paid to LPs is 0.3% per trade. By default, these are added to the liquidity pool, though LPs can redeem them at any time. The fees are distributed in proportion to each LP’s share of the pool.
How to Use Uniswap
Uniswap is an open-source protocol, meaning anyone can create their own front-end application for it.
- Go to the Uniswap interface.
- Connect your wallet. You can use MetaMask, Trust Wallet, or any other supported Ethereum wallet.
- Select the token you’d like to exchange from.
- Select the token you’d like to exchange to.
- Click on Swap.
- Preview the transaction in the pop-up window.
- Confirm the transaction request in your wallet.
Wait for the transaction to be confirmed on the Ethereum blockchain; you can monitor its status on etherscan.
The Uniswap (UNI) Token
UNI is the Uniswap protocol’s native token, which entitles its holders to governance rights. This means UNI holders can vote on changes to the protocol.
1 billion UNI tokens were minted at genesis — 60% are distributed to existing Uniswap community members, while the remaining 40% will be made available to team members, investors, and advisors over the course of four years.
Part of the community distribution happens through liquidity mining, meaning that UNI is distributed to LPs in the following Uniswap pools:
- ETH/USDT
- ETH/USDC
- ETH/DAI
- ETH/WBTC
How to Claim UNI via Airdrop
If you’ve used Uniswap before September 1, 2020, you can likely claim 400 UNI for every address with which you used Uniswap. To claim your tokens:
- Go to the Uniswap interface of your choice.
- Connect the wallet with which you used Uniswap.
- Click on “Claim your UNI tokens” or close the pop-up.
- Confirm the transaction in your wallet (you can check the current gas prices at the Ethscan Gas Tracker).
- Congratulations — you’re now an UNI holder!
Closing Thoughts
Uniswap is an innovative DEX protocol built on Ethereum. It allows anyone with an Ethereum wallet to exchange tokens without the involvement of intermediaries or third parties.
While it does have its limitations, this technology may have some exciting implications for the future of trustless token swapping. And as Ethereum scalability solutions keep improving, Uniswap may also benefit from these changes.
Further Reading:
- What Is an IDO (Initial DEX Offering)?
- What Are Decentralized Applications (DApps)?
- The Best Crypto Wallets for BNB Smart Chain (BSC)
- What Is Real Yield in DeFi?
Disclaimer and Risk Warning: This content is presented to you on an “as is” basis for general information and educational purposes only, without representation or warranty of any kind. It should not be construed as financial advice, nor is it intended to recommend the purchase of any specific product or service. Please read our full disclaimer here for further details. Digital asset prices can be volatile. The value of your investment may go down or up and you may not get back the amount invested. You are solely responsible for your investment decisions and Binance Academy is not liable for any losses you may incur. Not financial advice. For more information, see our Terms of Use and Risk Warning.
No Comment! Be the first one.