How DexModule7579 works
Last updated
Last updated
The attacker uses a MEV attack to insert his transactions into the queue in front of you. For this reason, the asset price for you will differ from the expected one.
The DexModule7579 facilitates asset swaps on the uniswap v3 with built-in protection against MEV (Maximal Extractable Value) attacks, specifically designed for account abstraction. When account invokes DexModule7579, it passes not only the swap parameters but also the allowed deviation between the asset’s spot price and the oracle price stored in the target pool. This deviation is calculated as the average over a specified time period, ensuring that the swap can be fulfilled without slippage tolerance while still reverting in case of the slippage attack.
Note: To successfully protect against MEV attacks, it is necessary to increase the maximum number of price and liquidity observations. Pay attention to the cardinalityInit
function in the tests. You can find more information about oracle's work in the Uniswap Oracle documentation.
You want to exchange Ether for USDC. But before your swap, a MEV attack was committed, which will not allow you to make an exchange at the desired price. The module has built-in protection against MEV attacks. The current spot price is compared with the weighted average price for the last 60 seconds, if the delta is greater than the deviation threshold, then there will be no exchange.