Uniswap explained
Tags: uniswap, defi, exchange
Published: 2022-12-11 12:26:00

**Index**

1. What is Uniswap
2. How to exchange tokens
3. How to open position in Liquidity pools (providing liquidity) and earn revenue
4. Major improvements in Uniswap v3 vs v1 and v2

---
## **<u>What is Uniswap</u>**
Uniswap is a decentralized exchange (DEX) built on the Ethereum blockchain. It allows users to easily trade Ethereum-based tokens without the need for a centralized authority or intermediaries. This makes it a popular choice for those looking to trade cryptocurrencies in a trustless and secure manner.

Uniswap was created in 2018 by a developer named Hayden Adams. The platform uses a unique liquidity pool model that allows it to function without the need for traditional order books. Instead, users who provide liquidity to the platform earn a portion of the trading fees generated by the DEX.

In brief, Here are some key features of Uniswap
- Offers users a simple,decentralized and trustless way to trade Ethereum-based tokens.
- Its unique liquidity pool model and automated trading processes make it a popular choice among those looking to participate in the DeFi ecosystem.
- This platform is automated and uses smart contracts to automatically execute trades, which ensures that they are completed quickly and without the need for manual intervention.
- Uniswap is currently one of the largest and most successful DeFi projects, with a total value locked of over $4 billion.

## **<u>How to exchange tokens</u>**
1) Since Uniswap is decentralized platform, you don't have to sign up for an account, just make sure you're on the right platform.
[Uniswap](https://app.uniswap.org/#/swap)
2) You can see the total liquidity and volume of trades going on, on this link [Uniswap-info](https://info.uniswap.org/#/), high volume will result in high gas prices because of high strain on the network

![Liquidity](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t0nifeht592s7lorqu1p.png)
3) Below you can see top tokens and top pools on the platform with their price and other information

> You might wonder what is wrapped BTC, Wrapped BTC (or WBTC) is a version of the Bitcoin cryptocurrency that has been converted into a form that is compatible with the Ethereum blockchain. This allows it to be easily exchanged and used in various Ethereum-based decentralized finance (DeFi) applications.

![Tokens](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3gncr61f0ajm9658tcuw.png)


4) Getting back to swap page, You will see a simple exchange interface where you click the "Connect Wallet" button. This will prompt you to connect your Web3 wallet to the platform such as Metamask. After connecting your wallet, your current chain will be shown in the UI. 

![swap](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pv8dpl26j5se0shq2zko.png)

5) By clicking on Select Token button, you can select your desired token or paste the token contract address.

![Token](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mfvfnn7agc7algzuskoe.png)

6) After selecting the token, the calculated exchange price will be automatically show, you can alter the values of one token as your liking and new exchange price will be automatically reflected


![exchange](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2motww68y1j3pb41zq5z.png)

7) After clicking swap you'll see this prompt. Here are few things you should know before swapping.
- <u>Expected output</u>: Amount of token you should get during the exchange disregarding gas price.
- <u>Price impact</u>: The impact of gas price on expected output, it means this much amount will be deducted.
- <u>Minimum amount received after slippage</u>: Amount you might receive after deduction and slippage. 
- <u>Liquidity provider fee</u>: Small amount of fees user have  to pay while trading to the users who provide liquidity to the pools.

> Slippage: It refers to the difference between the expected price of a trade and the actual price at which the trade is executed. It typically occurs when there is a high level of volatility in the market or when there is a large difference between the expected and actual amount of an asset being traded. 

![swap](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l3rbehfxj4yd4f7hy79i.png)

8) You can adjust allowed slippage and transaction deadline by clicking on setting icon. (if the transaction is not successful under the deadline, it will be cancelled)

![deadline](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s493fp5p9ksojwmga7j2.png)


9) After clicking on confirm swap, your metamask wallet prompt will be opened, click on confirm to start the transaction. You can click on 'View on Etherscan' to view the transaction on chain explorer.

![polygon explorer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ervj5iblma043742dtht.png)

10) Congratulations, you just learned how to swap tokens on Uniswap.

## **<u>How to open position in Liquidity pools (providing liquidity) and earn revenue</u>**
1) Go to [Pools](https://app.uniswap.org/#/pool) on uniswap and click on 'Add position'.

![Add position](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cn1n36jyf6qsaiz829rf.png)


2) Select a token and choose your pair, Below you'll see the percentage of revenue you want to generate. It is a good choice to choose stable pairs, because with high reward come high risks too.

![pair](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q2tzif52y6ioe8fy6ebq.png)

3) After that choose your price range in which you want to set stop loss (explained in detail in next section), then choose your amount of tokens you want to add.


![tokens](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bcybqlkvvry2ur4ioj4l.png)

4) After clicking on preview, you'll see this. Most important thing to notice is if the current price of USDC per MATIC went below the min price, all tokens will be converted to MATIC and in other case into the USDC.


![add liquidity](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9xus4nabfw9pgmoe1ic2.png)

5) Click on 'Add', confirm transaction from metamask and you'll now see your position listed on the website as a NFT.

![nft](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1i8elgvl3hsxvh5n915f.png)




## **<u>Major improvements in Uniswap v3 vs v1 and v2</u>**
Current version of Uniswap works on V3 and it has significant changes about how investor can add and maintain liquidity.


![improvements](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mgcwmp4pqqcq5g0u0u48.png)


**1) Concentrated liquidity**
![concentrated liquidity](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mre7yeuuorxdgsppik1t.png)

- Before V3, while providing liquidity user provided liquidity for the complete price range (Complete red line curve as shown in diagram), which was not very efficient as in stable coins most of the trades happens in a certain limit of price range.
- So V3 introduced a concept of Concentrated liquidity for liquidity providers where they can select the price range in which they want to provide liquidity and earn profits for all the exchanges happens in that range.
This also reduced the risk of impermanent loss

> <u>Impermanent loss</u>: It refers to the situation where the value of the assets that a liquidity provider has deposited into the platform decreases relative to the value of the tokens that they receive in return.
For example, if a liquidity provider deposits $100 worth of ETH and $100 worth of a stablecoin into a DEX liquidity pool, they may receive 200 tokens in return. If the value of ETH subsequently decreases relative to the stablecoin, the liquidity provider may experience a loss.

**2) NFT Liquidity tokens**
- Uniswap gives a NFT liquidity token when you add the liquidity in the pools and it is redeemable which means you can claim your assets back anytime. NFT will be burned after transfer is complete. It can also be traded with other users.

This just covered the few of the major improvements, you see more in details on Uniswap docs.

Thank you for your time.
Cheers.