DEX Dangers! Are You A Victim of These?

By Michael @ CryptoEQ | CryptoEQ | 26 Apr 2024


You are reading an excerpt from our free but shortened abridged report! While still packed with incredible research and data, for just $40/month you can upgrade to our FULL library of 60+ reports (including this one) and complete industry-leading analysis on the top crypto assets. 

67cbbf4723857b85c151585aa280e6d940346c501cef75bafd7dea02b44b24c9.png

Becoming a Premium member means enjoying all the perks of a Basic membership PLUS:

  • Full-length CORE Reports: More technical, in-depth research, actionable insights, and potential market alpha for serious crypto users
  • Early access to future CORE ratings: Being early is sometimes just as important as being right!
  • Premium Member CORE+ Reports: Coverage on the top issues pertaining to crypto users like bridge security, layer two solutions, DeFi plays, and more
  • CORE report Audio playback: Don’t want to read? No problem! Listen on the go.

80343245d23a711b72048b03337fca33602c226a79a46fcef047b46dc3354102.png

 

Toxic Flow

The ideal transaction partner for an AMM is a novice investor looking to sell at the going rate. AMMs are typically confident that they can offload the asset rapidly at a similar rate in the broader market. The least favored counterparts, however, are other market makers or high-frequency traders engaged in arbitrage, as these players are not driven by a desire to own the asset, but by exploiting price differences. This is considered 'toxic flow' because the losses incurred in such transactions outweigh the additional transaction fees generated.

This toxic flow for AMMs is most often triggered by abrupt price changes in centralized exchanges (CEX). Every shift in Ethereum's price on Binance, for example, sparks a flurry of trades against AMMs, which have not yet adjusted their prices. As estimated by Ambient Finance’s 0xfbifemboy, during the 12 months up to September 2022, around $100m was lost by USDC/ETH liquidity providers on Uniswap v3 due to arbitrage in the five minutes following significant price movements on Binance.

Toxic flow emerges when the future's marked price deteriorates compared to the execution price, even after factoring in fees and price fluctuations. At its heart, toxicity arises from the adverse selection that passive market makers like Uniswap face from market takers. In simpler terms, when informed traders possess superior knowledge about a cryptocurrency's price compared to AMMs, the Liquidity Providers (LPs) often find themselves on the less favorable side of trades, engaging at outdated, less favorable prices.

A classic illustration of this concept involves arbitrageurs. These savvy traders possess real-time knowledge of shifts in external market prices. Leveraging this insight, they can optimize profits by synchronizing the spot price of AMMs with that of the external market. The collateral damage in this process? The LPs. They invariably end up being the counterparty to the arbitrageurs, often to their detriment.

This raises an interesting predicament. Since AMMs don't utilize oracles for price data, they rely on arbitrage orders to enhance price discovery, striving for efficiency. However, this efficiency often comes at the LPs' expense.

Assessing the Liquidity Provision Dilemma

The core question arising from this dynamic is: Under what circumstances is it economically viable to provide liquidity? Breaking it down, this quandary can be addressed through a basic cost-benefit analysis:

  • Benefits encompass fee revenues and liquidity mining incentives.
  • Costs, on the other hand, revolve around the adverse selection of orders.

While benefits are relatively straightforward to quantify, costs present a more complex challenge. The prevalent method to gauge these costs is by measuring the 'impermanent loss' (IL). This metric endeavors to capture losses not encapsulated by traditional approaches. Yet, its inherent flaw is the omission of the price's trajectory.

To elucidate, consider a hypothetical ETH-USDC pool where ETH's price undergoes sharp fluctuations between $1000 and $2000. Arbitrageurs exploit these shifts, ensuring the AMM spot price mirrors external market rates. When viewed from an IL standpoint, as long as the starting and ending prices remain consistent, it appears as though LPs incur no losses. However, the reality is quite different. Arbitrageurs continue to reap significant profits from these fluctuations.

Given that trading is inherently a zero-sum endeavor, where one party's gain inevitably corresponds to another's loss, it becomes evident that arbitrageurs' profits often come at the LPs' expense. This underscores the fact that increased market volatility can amplify the adverse selection costs, especially when dealing with well-informed arbitrageurs.

In conclusion, while AMMs have revolutionized decentralized finance, they also bring forth intricate challenges like toxic flow. Understanding and navigating these complexities is vital for all market participants, from casual traders to seasoned liquidity providers.

Slippage Attacks

Another significant consideration for market participants is 'slippage'. As in traditional financial markets, slippage refers to the difference between the expected price of a trade and the price at which the trade is executed. In DeFi, slippage specifically denotes the price variance that may occur from the moment a participant submits a swap trade to when the trade actually executes. While typically minimal, slippage can be substantial during volatile periods or for tokens with low liquidity, potentially leaving traders with more or frequently fewer tokens than anticipated.

In order to mitigate such risks, DeFi platforms should offer users the ability to set a 'slippage parameter'—a minimum number of output tokens they aim to receive from the swap. This feature ensures that if a swap fails to meet the specified minimum amount, the transaction will automatically reverse, thus protecting users from unfavorable market conditions. However, there are prevalent implementation errors to watch for in DeFi platforms that both developers and auditors should address.

Firstly, the absence of a slippage parameter can prove dangerous. DeFi platforms should obligate users to specify this parameter—the minimum token return they seek from a swap. It is crucial to guard against swaps that set slippage to zero, a code that signifies the user's willingness to accept a minimum of zero output tokens. This situation makes users vulnerable to massive fund losses through Miner Extractable Value (MEV) bot sandwich attacks. While platforms might provide a default value if users neglect to specify one, the user's slippage parameters should always supersede platform defaults.

Another significant factor is the inclusion of an expiration deadline. Sophisticated protocols such as Automated Market Makers (AMMs) can enable users to set a deadline parameter, which enforces a time limit for the execution of the transaction. Without a deadline, transactions can linger in the mempool, resulting in delayed execution and potentially a less favorable price for the user.

It is worth noting that setting the deadline to 'block.timestamp' provides no protection. Validators could hold the transaction, and the block it eventually falls into will align with the 'block.timestamp', negating any protective function. Consequently, users engaging with AMMs should be able to set expiration deadlines, and the absence of one could create a critical vulnerability for fund losses, especially in the absence of a slippage parameter.

In conclusion, as an investor or user in the crypto space, understanding these key features and their proper implementation is crucial to navigate the complexities of the DeFi landscape, protecting your investments from potentially significant losses due to slippage or other vulnerabilities. DeFi platforms, developers, and auditors must all work cohesively to implement and monitor these parameters effectively. As the saying goes, 'knowledge is power'—and in the world of DeFi, this wisdom holds doubly true.

How do you rate this article?

64


Michael @ CryptoEQ
Michael @ CryptoEQ

I am a Co-Founder and Lead Analyst at CryptoEQ. Gain the market insights you need to grow your cryptocurrency portfolio. Our team's supportive and interactive approach helps you refine your crypto investing and trading strategies.


CryptoEQ
CryptoEQ

Gain the market insights you need to grow your cryptocurrency portfolio. Our team's supportive and interactive approach helps you refine your crypto investing and trading strategies.

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.