The transaction can be front-run or back-run by a MEV searcher, who can manipulate the order of transactions in a block to their advantage, thus extracting value from the user's transaction. This can be done by reordering transactions in a block to maximize the MEV searcher's profit.
Also, sellPoolTokens has a parameter called poolTokenAmount, which is the amount of pool tokens the user wants to sell. However, this is misleading, as the function actually calls swapExactOutput, and thus the parameter calculates the amount of WETH the user expects to receive. This can lead to the user spending more pool tokens than expected, either calculated or intended.
This vulnerability makes the user succeptible to MEV (sandwich attacks and frontrunning attacks).
Any user on the Ethereum network has the ability to watch for new transactions being sent to the network. When the attacker sees a large victim transaction that they want to front run come in, they can create a similar transaction that would move the market up. They then increase their gas fees to ensure that their order gets executed first. The attacker transaction executes, raising the price of the asset, and then the victim transaction executes at the higher price. The attacker is then free to exit the position immediately, pocketing the difference, having never exposed themselves to any risk.
Sophisicated front-runners will likely call these transactions from their own contract addresses to make sure they end up with the prices they expect, and don't collide with other front-runners.
Include this test in TSwapPool.t.sol
:
Foundry and manual review
Allow users to specify a slippage tolerance. This protects the user from executing a transaction in unfavorable conditions. Using TSwapPool::swapExactInput
within sellPoolTokens
instead of TSwapPool::swapExactOutput
(which currently has no slippage protection) would allow the user to specify a minOutputAmount
to set a floor in the amount of tokens the user is expecting to receive. This would protect the user from receiving fewer tokens than expected.
Use Flashbots Protect to avoid MEV attacks.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.