Sandwich attack is one of the main concerns for large DeFi traders, and it's very common in AMMs. The price in AMMs is determined by the token balances in the liquidity pool, the exploiter sniffs out the pending transactions on the network and front-runs the victim's trade to push the price up. The victim buys at a higher price of asset Y, then the attacker sells at a higher price. As a result, it causes loss for the victim.