en
Back to the list

DEX vs. CEX Part 3

source-logo  iota-news.com 13 April 2023 14:07, UTC

Mastering Decentralized Exchanges

DEX vs. CEX Part 3

TL;DR:

In this final part of our comparison of centralized and decentralized exchanges, we’re looking more closely at DEX, specifically impermanent loss, miner extractable value (MEV), and alternate models for Automated Market Makers (AMM).

Following our comparison of the fundamental elements of centralized and decentralized exchanges, there’s much more to explore about decentralized exchanges, including impermanent loss, the ever-controversial MEV, and alternate models of Automated Market Makers. Ready to learn more?

👉
This article was first published in the newsletter of the IOTA Content Creators DAO and is based on the second session of the IOTA x Bankless DeFi education series. The session was presented on 15 September 2022 by 0xHunter and the summary, organization, and additional detail in the article are by DigitalSoul.

Impermanent loss

Impermanent loss is the opportunity cost of being a liquidity provider compared to simply holding the two initial assets. It is a temporary loss of value that occurs as a result of changes in the price of the assets in the pool. Liquidity providers are always selling rising assets and buying falling assets by nature. In this way, they are always on the wrong side of profitable trade, but this doesn’t necessarily mean the trades are bad.

There could be situations where an investor always wants their portfolio to be half ETH and half USD Coin (USDC). In that case, providing liquidity is essentially auto-rebalancing their portfolio. However, if their goal is to just make as much money as possible then it might have been more profitable to simply hold the assets without entering the pool.

Let’s illustrate impermanent loss with an example. First, assume that a liquidity provider deposits 1 ETH and 1000 Tether (USDT, a stablecoin pegged to the value of the U.S. dollar) into a DEX liquidity pool. At the time of the deposit, the price of ETH is $1000 and the price of USDT is $1. Therefore, the value of the deposit is $2000 (that's $1000 ETH and $1000 USDT). Let’s also assume that this position represents 10% of the total constant product liquidity pool size. This tells us that the ‘k’ product for this pool is 10 ETH x 10000 USDT = 100,000. (As explained in the previous part of this blog post series, under “Automated Market Maker: the algorithm behind a DEX”, the prices of two assets are calculated via the formula x*y = k, where ‘x’ is the amount of asset ‘A’, y is the amount of asset ‘B’, and ‘k’ is a constant.)

Next, consider that the price of ETH goes up by a factor of four to $4000 while USDT remains the same. In this scenario, traders will use the pool to swap USDT for ETH until the ratio indicates the current price. Since the constant ‘k’ of 100,000 must be maintained in the pool, there is now 5 ETH and 20000 USDT in the pool.

The liquidity provider is still entitled to 10% of the pool. If they withdraw their assets from the pool at this point, they would receive 0.5 ETH and 2000 USDT. While their total value of assets has increased from $2000 to $4000 (by adding 2000 ETH to 2000 USDT), the value of the USDT portion of the deposit has decreased, resulting in an impermanent loss.

Note that if the liquidity provider had simply held the initial assets, the initial deposit of 1 ETH and 1000 USDT would now be worth $5000 ($4000 for the ETH and $1000 for the USDT). The loss is called “impermanent” because it will only occur if the price of the assets in the pool changes while the liquidity provider has funds in the pool. If the prices of the assets return to their original values, or if the liquidity provider withdraws the funds before any significant price changes occur, they won’t experience any impermanent loss. Even so, the effects of impermanent loss can be offset by the trading fees. If there is sufficient volume in a certain price range over a long enough period, the fees generated by the protocol and split among the liquidity providers can be more profitable than simply holding the initial assets.

It should be clear that providing liquidity is more complicated than many people believe! While there are services that attempt to aggregate and manage liquidity, it helps immensely to first develop a strategy. Providing liquidity should not be done passively unless the prices of the assets in the pool are tightly bound. Instead, liquidity providers should be more active to ensure that the asset prices don’t diverge too much. They should monitor their position to be able to remove liquidity when the asset’s prices reach the same ratio that existed when the liquidity was first provided.

In certain cases, Impermanent loss can also be offset by yield farming: the practice of providing liquidity to earn rewards in the form of additional tokens or fees. Yield farming typically involves staking or locking up assets in a smart contract in exchange for rewards, but can help to mitigate impermanent loss. However, these LP tokens can be highly volatile, so they are not without inherent risk themselves.

Maximum Extractable Value: controversial profit extraction

Maximum Extractable Value (MEV, also known as Miner Extractable Value) is the value that can be extracted by actors based on the way a blockchain orders its transactions. For example, the Ethereum network includes an auction to order transactions. There’s even an MEV Searcher community that bids to get certain transactions included in each block to extract the value.

This is considered a negative example of MEV since miners can essentially choose transactions with the highest extractable value to include in a given block. By contrast, the Shimmer network has unordered transactions so many of the MEV opportunities are mitigated.

Another example of MEV is arbitrage: buying an underpriced asset from one exchange and selling it on another for a higher price. This is generally considered positive for DeFi because it equalizes prices across markets, limits fragmented liquidity, and promotes healthy markets. Arbitrage generally happens in the same block on the Ethereum network and in sequential blocks on platforms where transactions are not orderable. When transactions can be ordered, traders will want to submit theirs as quickly as possible to front-run other traders. This happens in real time, leading to virtually zero lag time between price equalization on DEXs.

Middle Post Content

The last example of MEV is related to the slippage tolerance discussed earlier. If Trader A sees an order waiting to be filled and knows that Trader B will tolerate a slippage of one percent, trader A can buy the asset up to the maximum price that Trader B will tolerate. Then, immediately after Trader B buys it for the one percent higher price that they originally set, trader A will sell the asset for a profit. This is generally considered predatory behavior; because of gas fees, it’s also not profitable to do this with very small trades. It’s only a problem on Ethereum and other blockchains where you can order transactions.

Alternate Automated Market Maker models

In the previous part of this blog post series, we considered the simple constant product AMM popularized by Uniswap. However, instead of using the x*y=k curve, a protocol could implement any curve they want. In fact, many protocols are still experimenting with different curves for different models. In other words, “The curve the protocol.”

We also considered pools that were balanced 50%-50% but this can also be adjusted: for example, a pool could be 95% ETH and 5% USDC. One consequence of changing the weight of the pool is that liquidity providers are less exposed to impermanent loss.

Also, if a project launches a token but can't match the value with another token to start the pool, the project could provide 80% of the position in their token and 20% in a stablecoin, for instance. The trade-off is more slippage and potentially higher fees for traders due to the imbalanced liquidity.

https://docs.balancer.fi/concepts/advanced/impermanent-loss.html

Also, in the same initial AMM model, there are only two assets in the pool. But there could be many more assets in a given pool. Offering exposure to several different assets can provide interesting opportunities to liquidity providers. (for example, the Curve protocol is well-known for multi-asset pools).

For instance, if a pool comprises three different stablecoins, the liquidity provider gets the volume for all three stablecoins trading against each other. Also, the coins are priced in terms of each other and so their prices are more tightly bound together and, as long as there is enough liquidity, one stablecoin can always be traded for another.

However, if one of the stablecoins is riskier compared to the others and it de-pegs, your liquidity position is in jeopardy. In this case, traders will quickly come in to arbitrage and buy the remaining “good” stablecoins. In the end, these multi-asset pools expose each asset to the others, making these pools riskier.

It gets really interesting if several of these factors are combined. For example, there could be a weighted, multi-asset pool similar to that offered by Balancer. This could be a liquidity position tailored to a specific portfolio. In this case, you can be sure that the asset allocation you want for your portfolio is maintained while you collect the fees generated by trading in the pool.

Conclusion

Ultimately, the choice between centralized and decentralized exchanges depends on your personal preferences and risk tolerance.

Regardless of which type of exchange you choose, it's important to do your research, stay informed about the latest developments in the crypto world, and always prioritize security and responsible trading practices. With the right knowledge and tools, you can make the most of both centralized and decentralized exchanges and take your experience with decentralized finance to the next level.


iota-news.com