  Trading through decentralized exchanges (DEXs) has become crucial in today's
blockchain ecosystem, enabling users to swap tokens efficiently and
automatically. However, the capacity of miners to strategically order
transactions has led to exploitative practices (e.g., front-running attacks,
sandwich attacks) and gain substantial Maximal Extractable Value (MEV) for
their own advantage. To mitigate such manipulation, Ferreira and Parkes
recently proposed a greedy sequencing rule such that the execution price of
transactions in a block moves back and forth around the starting price.
Utilizing this sequencing rule makes it impossible for miners to conduct
sandwich attacks, consequently mitigating the MEV problem.
  However, no sequencing rule can prevent miners from obtaining risk-free
profits. This paper systemically studies the computation of a miner's optimal
strategy for maximizing MEV under the greedy sequencing rule, where the utility
of miners is measured by the overall value of their token holdings. Our results
unveil a dichotomy between the no trading fee scenario, which can be optimally
strategized in polynomial time, and the scenario with a constant fraction of
trading fee, where finding the optimal strategy is proven NP-hard. The latter
represents a significant challenge for miners seeking optimal MEV.
  Following the computation results, we further show a remarkable phenomenon:
Miner's optimal MEV also benefits users. Precisely, in the scenarios without
trading fees, when miners adopt the optimal strategy given by our algorithm,
all users' transactions will be executed, and each user will receive equivalent
or surpass profits compared to their expectations. This outcome provides
further support for the study and design of sequencing rules in decentralized
exchanges.
