Decentralized exchanges – or DEXs – are exchanges that live on a blockchain, with many of the most popular ones, such as Uniswap and Sushiswap, living on the Ethereum blockchain.
DEXs use smart contracts to allow users to exchange cryptos back and forth without the need for a centralized authority, such as a bank or broker, and they do not allow trading between fiat and cryptos.
How do they work?
Unlike centralized exchanges, which utilize buy and sell orders to determine the market price, DEXs use Automated Market Makers (AMM) to create prices.
Automated Market Makers use smart contracts and liquidity pools to set prices. If you’ve ever wondered (or heard) about how cryptos can have different prices on different exchanges and websites, this is why.
AMMs rely on users locking up some amount of their crypto into a digital wallet where it cannot be removed for some amount of time. These coins are then able to be exchanged by traders on the DEX for other cryptos.
Now, of course, nobody is locking up their coins for free, liquidity providers (LPs) earn interest on their coins based on how much they provide.
Automated Market Makers use the formula x * y = k, where k is a constant. If we add 50 tomatoes and 50 potatoes to create a liquidity pool, then k must always equal 2,500. The total value of the two must typically start off equal, so let’s say they both cost a buck. That means 1 tomato equals 1 potato and we have a 50/50 split.
Now, suppose someone wants to trade 10 potatoes for some tomatoes. You might think, “Oh, easy, one-for-one”. Well, not exactly. What happens is, I go to the AMM and give it my 10 potatoes and it recalculates the exchange. We now have 50 tomatoes and 60 potatoes in the pool, but that doesn’t equal 2,500.
So given that we have 60 potatoes that must multiply with our tomatoes for 2,500, we simply divide 2,500 by 60, which equals 41.667. Thus, my 10 potatoes were worth 8.333 tomatoes.
When adding to a liquidity pool as a provider, one typically adds liquidity in the ratio that it is currently trading at. This prevents LPs from adding liquidity in a price-altering manner and means that you must add two kinds of cryptos when you provide liquidity.
Depending on how “exotic” the pair of cryptos are, the larger the fee incurred by traders to swap the coins, and the more is earned by the LPs. LPs earn based on the amount they provide, so if I make up 10% of a pool, then I’ll get 10% in fees every time the two are swapped.
Rates can vary, but on Uniswap, stable pairs can receive as little as 0.05% in fees, while exotic pairs receive as much as 1%. Considering the fees collected over the past 24 hours were $3.84 million on $2.19 billion, providing liquidity, on paper, could be a very profitable endeavor.
So Should You Provide Liquidity?
Well, “on paper” and “in-reality” are two very different things.
According to a study by Bancor, which is a decentralized trading protocol, about half of LPs on Uniswap are actually in the red. This is because of a phenomenon that has plagued DEXs called “impermanent loss” (IL).
Impermanent loss occurs when the liquidity pool becomes uneven compared to its original position.
Now let’s go back to our earlier example, where 10 potatoes got us 8.333 tomatoes. When I provided that liquidity, they were both worth $1 each. But what would happen if that were no longer the case?
Let’s say the price of tomatoes increased to $2, while potatoes remained steady at $1.
My pool of tomatoes and potatoes was once valued at $100 when there were 50 tomatoes and potatoes at a dollar apiece.
However, after the exchange, the market price of tomatoes doubled, meaning that the 41.667 tomatoes remaining in the pool are now worth $83.33, while my 60 potatoes are worth $60. The value of our liquidity pool is now worth $143.33, giving a profit of $43.33.
But what if instead of providing liquidity, we had just held the tomatoes and potatoes?
Well, my 50 tomatoes would be worth $100 and my 50 potatoes would be worth $50, for a grand total of $150.
This means that, if I hadn’t become an LP, I would have made $6.67 more than I did, thus, my impermanent loss is $6.67.
Given that half of all Uniswap liquidity providers are losing money, this means the change in relative value between the two coins is nickel-flip away from being much more drastic than the example shown.
For the “stable pairs”, providing liquidity could be a good option depending on the consensus mechanism of the crypto, but you may also be better off just staking those coins if you are looking for a long-term investment in those coins as that exchange rate is not guaranteed to persist.