Skip to content
Business logic Audit finding Intermediate

Providing and withdrawing liquidity lacks slippage protection

The ProvideLiquidity and WithdrawLiquidity messages lack slippage protection parameters, so users cannot specify minimum acceptable amounts. An attacker or market movement could change pool reserves before execution, causing users to receive fewer LP tokens or an unfavourable asset mix.

0x37 Follow with 0xDjango, MissDida and 8 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2025-09-dango-dex-judging/issues/412

Found by

0x37, 0xDjango, MissDida, berndartmueller, blockace, cu5t0mPe0, dandan, haxagon, holtzzx, merlin, ni8mare

Summary

The ProvideLiquidity and WithdrawLiquidity messages do not include slippage protection parameters. This omission exposes users to the risk of receiving fewer tokens than expected due to market conditions between the transaction initiation and execution.

Root Cause

The ProvideLiquidity and WithdrawLiquidity messages calculate the resulting tokens based on pool reserves at the moment of execution, without allowing users to specify a minimum amount of tokens they are willing to accept. This exposes them to slippage caused by market volatility or front-running.

Providing Liquidity

When providing liquidity, the number of LP tokens minted is derived from the ratio of the deposit to the current reserves at execution time (e.g., XYK pool). Any change in reserves between signing and execution will alter the outcome.

Withdrawing Liquidity

When withdrawing liquidity, the user receives a pro-rata share of the current reserves:

Rust
56:  let refund = reserve.split(lp_burn_amount, lp_token_supply)?;

The composition of the withdrawn assets is therefore sensitive to any trades that occur before the withdrawal is processed.

This is a deviation from the industry standard for XYK pools, where platforms like Uniswap V2 allow users to specify minimum amounts for liquidity provision to protect against slippage.

Internal Pre-conditions

N/A

External Pre-conditions

  • The reserves of the targeted liquidity pool change between the time the user signs the transaction and when it is executed.

Attack Path

Providing Liquidity:

  1. A user intends to provide liquidity to a pool with reserves of 1,000 ETH and 2,000,000 USDC (price: 2,000 USDC). They sign a transaction to deposit 10 ETH and 20,000 USDC.
  2. A large trade is executed, which sells 200 ETH to the pool. This trade significantly alters the pool's balance.
  3. The trade swaps 200 ETH for approximately 333,333 USDC. The new pool reserves become 1,200 ETH and ~1,666,667 USDC. The price of ETH drops to ~1,389 USDC.
  4. The user's ProvideLiquidity transaction is now executed against these reserves. Their deposit of 10 ETH and 20,000 USDC is now highly unbalanced relative to the new pool ratio.
  5. As a result, the user receives significantly fewer LP tokens than they would have at the time of signing, and they may incur a substantial asymmetry fee, leading to an immediate loss.

Withdrawing Liquidity

  1. A user holds 1% of the LP tokens for a pool with reserves of 1,000 ETH and 2,000,000 USDC. They sign a transaction to withdraw their share, expecting to receive approximately 10 ETH and 20,000 USDC.
  2. A large purchase of 300 ETH from the pool is executed, using approximately 857,143 USDC.
  3. The trade shifts the pool reserves to 700 ETH and ~2,857,143 USDC. The price of ETH rises to ~4,081 USDC.
  4. The user's WithdrawLiquidity transaction now executes against the new pool state.
  5. The user receives 1% of the new reserves: 7 ETH and ~28,571 USDC. They receive 30% less ETH than anticipated and are forced to realize their position at a disadvantageous price, effectively crystallizing impermanent loss.

Impact

Liquidity providers can suffer a loss of value due to slippage. When providing liquidity, they may receive fewer LP tokens for their assets than expected. When withdrawing, they may receive an unfavorable mix of assets, potentially forcing them to realize impermanent loss or leaving them with less of a specific asset they require.

PoC

N/A

Mitigation

Consider introducing slippage protection mechanisms by adding parameters to both ProvideLiquidity and WithdrawLiquidity messages.

Additionally, consider adding an optional deadline parameter to these messages to prevent them from being held and executed at a much later time under significantly different market conditions.

The original report as published on Sherlock, by 0x37. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The ProvideLiquidity and WithdrawLiquidity messages calculate outcomes from live pool reserves without letting users set a minimum acceptable amount, unlike industry-standard XYK pools.

Impact

Liquidity providers could suffer a loss of value due to slippage, receiving fewer LP tokens when providing or an unfavourable asset mix when withdrawing, potentially realising impermanent loss.

What the attacker needed

Pool reserves change before execution

The fix

Slippage protection mechanisms should be added by introducing parameters to both ProvideLiquidity and WithdrawLiquidity messages, and an optional deadline parameter should be considered.

How it was found

  1. A user signs a transaction to provide liquidity with specific token amounts.
  2. A large trade changes the pool reserves before the user's transaction executes.
  3. The user's ProvideLiquidity transaction executes against the new reserves.
  4. The user receives fewer LP tokens than expected and may incur an asymmetry fee.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When you add or remove money from a shared pool, the amount you get back depends on the pool's balance at the moment your transaction runs. If someone else trades just before you, the balance changes and you might get less than you expected. This report says the system gives you no way to say 'don't do it if I get less than X'.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by 0x37

View all

79 more disclosed reports, best first.

More from Dango DEX

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.