Uniswap is a decentralized exchange built on the Ethereum blockchain and released to the public in November 2018. Unlike centralized exchanges, Uniswap allows the exchange of tokens without an intermediary. An advantage of decentralized exchanges(DEX) over centralized exchanges is security of funds, as DEXs operated using non-custodial wallets.
How does an exchange take place on Uniswap?
Source: Jeremy Bezanger on Unsplash
Centralized exchanges make use of order books to facilitate trades on their platforms. Think of a pool, filled not with water🌊, but with two kinds of coins, ETH and USDT. This pool is called the ETH/USDT pool. Liquidity providers, supply coins to these pools to earn rewards in form of tokens.
If you have some USDT and, wish to exchange it for some ETH, Uniswap makes this possible by allowing you to connect to the wallet where you have the USDT stored and exchange it for an equivalent amount of ETH.
Now you know how exchange takes place on Uniswap. Later in the guide, I'll walk you through making this work, but before then, you may want to understand the cost of providing liquidity.
The cost of Providing Liquidity.
Source Olieman.eth on Unsplash
Providing liquidity isn't risk-free, as those who do are at risk of having Impermanent loss. Impermanent loss refers to temporary loss incurred by LPs due to volatility in token prices.
First, what does liquidity mean, especially for cryptocurrency? Liquidity in cryptocurrency refers to the ease at which the exchange of tokens for one another can occur. So, by contributing to a pool, you make it easier to exchange tokens. By doing so, you are providing liquidity, making you a liquidity provider. Liquidity providers are at the risk of impermanent loss. Hang in there. I'll explain what that means with the illustration below.
The ETH/USDT pool on Uniswap contains 50 ETH and 50000 USDT, where 1 ETH equals 100 dollars, making the total dollar value $55000. You get a gift of $10,000 from a friend and decide to invest $2000(10 ETH and 1000 USDT) in the ETH/USDT pool to make some decent gains. The total value of the ETH/USDT pool with your investment is $57000, giving you a 0.0351% share of the pool.
A year later, the price of ETH increases , 1 ETH equals 400 dollars, bringing the total dollar value of the pool containing 60 ETH and 51000 USDT to $75,000. You own 0.0351% of the pool, about $2632.5. Pretty nice profit, a gain of $632.5. The $632.5 profit is nice, but it could have been more.
If you held your 10 ETH and 1000 USDT, with 1 ETH at $400, your assets would be worth - $5000. If you compare $5000 to $2632.5, it seems more like a loss than a profit.
If the price of assets changes while your assets are locked in the liquidity pool, you will be a victim of impermanent loss. It's not a bad thing, as the rewards earned from providing liquidity may cover up the losses made while doing so. Also, the price may revert to its initial position. Keep in mind that the loss is impermanent while your assets are still locked in the pool, but once you pull out, it becomes very much permanent.
How are prices determined on Uniswap?
Source: Siora Photography on Unsplash
Different platforms use various methods to determine the price of assets. Some use order book models, some price oracles, but Uniswap uses Automated Market Makers(AMM).
First of all, understand that AMMs are algorithms. There are several types, but Uniswap makes use of the Constant Product Market algorithm, x * y = k, where:
- x = the number of a token in the pool, for example, ETH
- y = the number of another token in the pool, say, USDT
- k = the product of the number of tokens in the pool.
Using the understanding behind the concept of scarcity, the more scarce or limited an item is to another, the higher its price. Take fuel/gas scarcity as a reference point.
When a token is withdrawn from a pool, the algorithm supplies of it's paired token to ensure "k" remains constant. Using the ETH/USDT pool, removing ETH from the pool means more supply of USDT to keep the "k" constant making ETH scarce. This scarcity drives up the price of ETH while lowering that of USDT.
Using numbers for clarity, in a pool with 100 ETH and 100 USDT, the product is 10,000 (100 x 100). A user withdraws 50 ETH making the product 5,000 (50 x 100). Keeping the product constant requires adding 100 more USDT to the pool. The reduction in the number of ETH drives up its price, while the increase in the number of USDT reduces it. It's a game of demand and supply, just like all financial markets.
How to swap tokens on Uniswap.
Source: Ferhat Deniz Fors on Unsplash
- Head over to uniswap.org and click on the launch app button at the top right corner.
- Select the tokens you wish to swap, and enter your desired input or output amount. Uniswap calculates the price of the tokens relative to each other.
- Connect your wallet to Uniswap, and approve the transaction.
- Review the transaction details and make sure you are good with what you see.
confirm swapand confirm the transaction in your wallet.
In this guide to Uniswap, you have understood what it is, how exchange takes place, the cost of providing liquidity, price determination, and how to swap on Uniswap.
If you wish to dive deeper, you can check out the following articles:
- Detailed History of Uniswap
- In-depth Guide on AMM
- Custodial vs Non-Custodial Wallets
- The Complete Beginner's Guide to Decentralized Finance
- What is Yield Farming in Decentralized Finance(DeFi)
You, you can reach me on Twitter for corrections and improvement.
Cover Image Source: BeInCrypto