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.
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:
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:
- 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.
- A large trade is executed, which sells 200 ETH to the pool. This trade significantly alters the pool's balance.
- 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.
- The user's
ProvideLiquiditytransaction 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. - 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
- 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.
- A large purchase of 300 ETH from the pool is executed, using approximately 857,143 USDC.
- The trade shifts the pool reserves to 700 ETH and ~2,857,143 USDC. The price of ETH rises to ~4,081 USDC.
- The user's
WithdrawLiquiditytransaction now executes against the new pool state. - 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.
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
- A user signs a transaction to provide liquidity with specific token amounts.
- A large trade changes the pool reserves before the user's transaction executes.
- The user's ProvideLiquidity transaction executes against the new reserves.
- 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.