DeFi Deep Dive — Uniswap, King Of the Ethereum Ecosystem

Share Article
In Brief
The Trust Project is an international consortium of news organizations building standards of transparency.

The Uniswap protocol facilitates decentralized swaps of crypto-assets through an automated market maker (AMM) type design. The protocol has become one of the pillars of the DeFi ecosystem in Ethereum.

Unlike decentralized exchanges based on order books, in an AMM-type decentralized exchange (DEX) any user can act as a liquidity provider.

To do this, the user only has to deposit cryptocurrencies in pools that represent the different markets. In return, the user earns commissions. Therefore, the price of assets is no longer conditioned by the ask and bids placed in an order book.

At Uniswap, when a user becomes a liquidity provider by depositing their funds in a pool, they receive a token representing their stake. Every time someone executes an exchange through the protocol, they must pay a commission of 0.3%.

These commissions are distributed among the liquidity providers based on the number of crypto assets they have deposited in the pool.

So, in short, Uniswap allows users to swap both ethereum (ETH) and most compatible ERC20 tokens without the need for intermediaries. It also offers the possibility for users to contribute to the system’s liquidity with their own assets. In return, they receive the commissions generated by each swap as a reward.

A Brief History

In a post on Reddit in 2017, Vitalik Buterin, founder of Ethereum, suggested programming a decentralized exchange through smart contracts. This type of exchange called Automated Market Maker would work exclusively on a blockchain.

Inspired by this idea, Hayden Adams, a former mechanical engineer who lost his job at Siemens, decided to start working on implementing it in October 2017. The first version of it, called Uniswap, would be ready in November 2017 with a single liquidity and simple swaps provider.

How does Uniswap work?

Uniswap is a protocol that facilitates the exchange of tokens on Ethereum. Tokens are always kept in possession of the user, and since it works within a blockchain, trust in third parties is not necessary.

The protocol eliminates the order book and instead maintains liquidity reserves of various tokens in its smart contracts. In this way, transactions are executed directly against these reserves.

Prices are set automatically using the constant product market maker mechanism. This system works with a constant (x * y = k), which keeps total reserves in relative equilibrium.

The reserves group between a network of liquidity providers that supply tokens to the system. In exchange, each liquidity provider (LP) takes a proportional part of the commissions for each transaction.

For example, after adding 1,000 DAI and 10 ETH, the liquidity pool is now 10,000 DAI and 100 ETH in total. Since the quantity offered is equal to 10% of the total liquidity, the contract mints and sends to the market maker “liquidity tokens” (LP tokens) that entitle them to 10% of the total liquidity pool.

These tokens are an accounting tool to keep track of how much liquidity providers are owed. If others subsequently add or withdraw coins, the new liquidity tokens are minted or burned so that the relative percentage of everyone’s liquidity pool remains the same.

How does an automatic market maker (AMM) work?

An AMM works using liquidity pools. Pools are funds in which users deposit their assets. These assets are always deposited in pairs to create a market.

For example, if it is intended to create an exchange market between ETH and DAI, the user must deposit the same amount of the two currencies in said pool. If an ETH is worth 100 DAI, and a user deposits 10 ETH in this pool, they will also have to put 1,000 DAI.

The key formula to consider is x * y = k, where x and y are the amounts of the currencies in the liquidity pool, and k is the product. Uniswap takes these two quantities and multiplies them (1000 x 10 = 10,000). From here on, any operation carried out must keep the product constant between the two currencies.

Pros and cons of AMM

One of the main problems of AMM is what is known as slippage. Slippage is the difference between the expected price of a trade and the price at which the trade is executed.

Still using the previous example, but in the case that someone wants to buy 2 ETH. Automatically instead of 10 ETH, there would be 8. As the product between the amount of ETH and DAI must remain constant and equal 10,000, The new pool configuration should be 1,250 DAI x 8 ETH = 10,000.

Therefore, those 2 ETH will have cost 250 DAI (1250 final DAI – 1000 initial DAI) or the same 125 DAI for each ETH. In this case, the real price of each ETH is 100 DAI, but in the end, the user ends up paying 125 for each one. This is slippage.

The slippage problem will be bigger the larger the order. In this case, 2 ETH represents 20% of the total reserve, and the final slip is 25%. Obviously, no one wants to pay 25% more than the market value of a token.

One of the simplest ways to solve this is to have bigger reserves. In this way, the orders should get bigger and bigger so that the slippage is considerable.

Yet this system has a great advantage. It can provide liquidity no matter how large the order size is or how small the liquidity pool is. While larger orders tend to suffer from excess slippage, the system never has to worry about running out of liquidity. It will literally always work.

The problem of impermanent loss

Another problem with AMM is what is known as impermanent loss (IL). The IL is a consequence of the way an AMM works from the constant product mechanism. In the case of a pool containing 10 ETH and 1000 DAI (ie 1ETH = 100 DAI) the product between these two quantities (10 * 1000 = 10,000) must remain unchanged.

The problem will be greater with highly volatile and poorly correlated assets. As an example, the price of ETH goes from $100 to $150. In that case the contract will now reflect something closer to 1,224 DAI and 8.17 ETH (applying the formula explained above, 1,224 * 8.17 = 10,000 (our constant product) and 1,224 / 8.17 = 150, our new price).

If a user wanted to withdraw that amount from the liquidity pool, they would need to have 1,224 DAI and 8.17 ETH at that time. The total market value here is $ 2,450, whereas the amounts that were deposited at the beginning were withdrawn; they would get 1000+ 10 * 150 = 2500. Hence, the $50 in profit is lost to the liquidity provider.

Naturally, if the price returned to $100 again, everything would rebalance. That is why this phenomenon is known as impermanent loss. Without a doubt, it is one of the most uncomfortable problems of the Uniswap system. Nobody likes to provide liquidity in exchange for losing value.

Uniswap V2: The first iteration

In May 2020, Uniswap released its second version (V2). In Uniswap V1, ETH and any other ERC20 tokens make up all liquidity pools. Users can exchange any ERC20 for any other ERC20 but always following a route through ETH.

Since ETH is the most liquid asset, this meant less risk for the platform in its early days. This made it the best option for Uniswap V1. Uniswap V2 introduced reserves with ERC-20/ERC-20 pairs without the need to go through ETH.

Having direct ERC20 / ERC20 pairs resulted in an improvement in prices, reducing the number of commissions for each transaction. For example, to go from DAI to USDC in V1, the route would have been with the following steps:


With the V2 version of Uniswap it is possible for this transaction to be made directly from DAI to USDC.

Uniswap V2 implemented new functionality that allowed highly decentralized, and tamper-resistant on-chain price feeds. In contrast, Uniswap V1 could not be safely used as a price oracle because the price can move significantly in a short period of time.

UNI Token arrives

In September 2020, Uniswap finally launched its token. Every wallet that ever connected and used Uniswap was sent 400 UNI, about $12,000 today.

In addition to airdrops, Uniswap also launched a liquidity mining program to distribute its token. all those who act as liquidity providers in certain currency pairs receive 5 million UNI.

UNI is basically a governance token that allows its holders to vote on proposals to improve the protocol. For example, through governance, you can vote to allocate UNI for grants, strategic partnerships, and other programs.

Uniswap V3: The most flexible AMM ever

Finally, on March 23, Uniswap announced its latest version, Uniswap V3, release date — May 5. Perhaps the most innovative feature of Uniswap V3 is the concentrated liquidity positions, a model reminiscent of the Fed Price Reserve from Kyber Network.

In the previous version, a liquidity provider deposited its assets in the pool to be sold in any price range, from 0 to infinity. In this new version, the user has full control over the price ranges to which he wishes to provide liquidity.

Thanks to this, LPs can provide liquidity with a capital efficiency of up to 4,000 times higher than Uniswap V2, obtaining higher returns on user capital. This increases the efficiency of the system and, therefore, the slippage in prices.

Even so, this system of concentrated liquidity has the counterpart of increasing the impermanent loss.

In addition, Uniswap V3 incorporates multiple levels of commissions. This will allow LPs to be adequately compensated for assuming varying degrees of risk. Another interesting aspect users can convert LP tokens into NFTs.

Uniswap oracles are now much easier and cheaper to integrate. Thanks to these design improvements, the cost per transaction on the V3 will be slightly cheaper than on the V2.

Finally, the protocol will soon incorporate a layer 2 solution. The chosen system is Optimism’s optimistic roll-ups, which will make transactions significantly cheaper.

These features make Uniswap V3 the most flexible and efficient AMM ever designed.

Uniswap V3: A mixed reaction

The announcement of the Uniswap V3 has generated a lot of expectation among the DeFi community. It has also been met with criticism.

Firstly, with Uniswap V3 the protocol doesn’t reward the UNI token and maintains it as a simple status as a governance token.

On the other hand, the concentrated liquidity system forces liquidity providers to be more active and constantly redesign their strategies. Its operation is more complex, which gives an advantage to professional market makers while it hurts less experienced users.

The most significant criticism towards Uniswap V3 is the license under which it will operate. The code is no longer open for practical purposes. A fork of Uniswap V3 will not be legal for another 2 years. The code is accessible but not for commercial use

In the summer of 2020, the industry witnessed a dramatic episode in which Sushiswap forked Uniswap. In the process, it “vampirized” part of its liquidity deposits, absorbing billions of dollars from Uniswap.

After that event, it seems that the team wants to close any possibility of something similar happening. However, this completely breaks with the ethos of the DeFi ecosystem, leaving the source completely open and available to anyone.


All the information contained on our website is published in good faith and for general information purposes only. Any action the reader takes upon the information found on our website is strictly at their own risk.
Share Article

Albert has been digging into the blockchain ecosystem since 2017, studying and continuously monitoring the decentralized finance sector.

Follow Author

Don’t get FUD! Level up and unlock new trading experiences on Bybit!     

Start now

Don’t get FUD! Win 1 ETH when you deposit $100 with Bybit!      


Buy your first NFT on Bybit and earn up to 20,000 USDT.