Curly Eggplant Bee
High
The static slippage tolerance calculation in addLiquidityV2
will cause financial loss for liquidity providers as MEV bots or attacker will front-run transactions to manipulate token prices and exploit slippage.
In addLiquidityV2 (code link), the slippage calculation (_pTKNLPTokens * (1000 - _slippage)) / 1000
uses a static user-provided value. This allows MEV bots or even attackers to manipulate the token price during the transaction’s pending state.
- Liquidity providers must set a slippage tolerance (_slippage) that allows exploitable price ranges (example >1%).
- The protocol’s paired LP token (e.g., IDX/ETH) must have sufficient liquidity for price manipulation to be profitable.
MEV bots or an attackers must monitor the mempool for pending addLPAndStake
transactions.
-
User calls
addLPAndStake
with_slippage = 100
(10% tolerance). -
MEV bot or an attacker detects the transaction in the mempool and front-runs it by buying the paired LP token (e.g., IDX), inflating its price.
-
User’s transaction executes at the manipulated price, resulting in fewer LP tokens minted than expected.
-
MEV bot sells the token back at the inflated price, profiting from the price difference.
- Liquidity providers suffer an approximate loss of X% (based on slippage exploited).
- MEV bots or attackers gain the arbitrage profit extracted from the manipulated price.
Alice wants to add liquidity to the index fund with 100 IDX tokens and 1 ETH (current price: 1 ETH = 100 IDX).
She calls addLPAndStake with _slippage = 100 (10% tolerance), allowing the transaction to execute even if the price moves by up to 10%.
Bob detects Alice’s transaction in the mempool.
He front-runs it by buying 50 IDX tokens on the DEX, pushing the price to 1 ETH = 90 IDX (a 10% price increase).
Alice’s liquidity is added at the manipulated rate: 1 ETH = 90 IDX (within her 10% slippage tolerance).
She receives LP tokens based on the inflated price, effectively getting 10% fewer LP tokens than expected.
Bob’s Profit:
Bob sells the 50 IDX tokens back at the inflated price, netting a profit of ~5.55 ETH (arbitrage from the price difference).
Alice loses 10% of her expected LP tokens due to price manipulation.
Bob extracts value from Alice’s transaction, incentivizing further attacks.
No response