In traditional financial markets, trading is primarily conducted through order book systems, where liquidity providers place buy and sell quotes to facilitate trades. These markets face significant challenges due to the presence of high-frequency traders (HFTs). One critical issue is "sniping stale quotes." Liquidity providers maintain quotes around an equilibrium price, but when market conditions change, these quotes can become stale. HFTs race to exploit these stale quotes before liquidity providers can cancel them, leading to inefficiencies. In anticipation, liquidity providers widen their spreads to protect themselves, which reduces overall market liquidity.
To address these inefficiencies, the financial industry has explored the concept of batching trades. Instead of continuous trading, time is divided into discrete intervals or batches. Orders arriving within the same batch are processed without prioritizing speed, encouraging traders to compete on price rather than speed. Batching trades eliminates latency races in traditional finance by changing the nature of competition between arbitrageurs.
CFAMMs trading at a loss whenever there is a rebalancing event similar to sniping stale quotes".
Traders are routinely exploited by attackers, most commonly via sandwich attacks in which an attacker front-runs a victimโs swap with the same swap and then back-runs it with the opposite swap.
Proposed Design: High-Level Overview
The proposed design leverages batching to enhance trade fairness and efficiency, while expanding the design possibilities for AMMs to create more dynamic and effective liquidity provision mechanisms. It incorporates two key elements: Batching and a Function-maximizing AMM.
Batching Trades:
Off-Chain Collection: The system collects trading intents off-chain, which reduces the load on the blockchain and allows for more efficient trade processing.
Batch Processing: Once trades are collected, they are batched together. Within a batch, trades are settled peer-to-peer as much as possible to maximize efficiency. Any remaining trades that cannot be settled directly are processed through an AMM that is accessible only to the batch.
Uniform Pricing: By ensuring that all trades within the same batch for the same token have the same price, we eliminate opportunities for traders to exploit price differences, thereby enhancing market fairness and stability.
Expanded AMM Design Space:
Path Independence: In traditional AMMs, ensuring path independence is crucial to prevent traders from gaining an unfair advantage by splitting their trades. Our batching mechanism naturally prevents this type of exploitation, allowing us to explore a broader range of AMM designs.
Function-Maximizing AMM: An FM-AMM refers to a type of automated market maker (AMM) that maintains clearing-price consistency. This means that for every trade executed within this AMM, the average price is designed to be equal to the marginal price after the trade is completed. This flexibility allows the AMM to adapt more dynamically to market conditions, potentially providing better liquidity and more efficient trading outcomes.
This innovative AMM design aims to maximize a specific function of its liquidity reserves with each trade. The simplest version of this is maximizing the product of the reserves, but the design can be extended to maximize any function of the reserves.
The function-maximizing AMM
Properties of an FM-AMM
Comparative Analysis: Comparing the FM-AMM to its CPAMM counterpart reveals notable disparities. While the FM-AMM generates twice the price impact per trade, it also implements a passive investment strategy, wherein the total value of reserves is evenly distributed between assets. This strategic positioning enhances the FM-AMM's efficacy in capital deployment and risk management.
Why batching trades is necessary?
FM-AMM vs CFMM (similar fee structure)
For the largest and most traded Uniswap v3pools, providing liquidity is unprofitable as trading fees don't compensate for arbitrage losses.
In pools with less-traded tokens, results vary, with Uniswap v3 outperforming FM-AMM on some pairs, but the absolute difference in cumulative returns is generally small.
FM-AMM fees
Fee and Arbitrage: Higher fees can also reduce the likelihood of arbitrageurs rebalancing the pool.
Optimal Fee: In many cases, a zero fee is optimal, leading to more frequent rebalancing and potentially higher returns. However, exceptions exist where a positive fee might be better.
FM-AMM with noise trading
Heimbach et al. (2024) identifies 30% of the total volume on Unswap v3 as non-atomic arbitrage. Also, according to labeling by https://zeromev.org/, sandwich attack and atomic arbitrage volume correspond to 6% of Unswap v3 volume. When extrapolated from Unsiwap v3 in general to the studied pools, then in each of the pools studiedFM-AMM, approximately 60% of trading volume is noise trading.
The Function Maximizing AMM (FM-AMM) addresses key challenges faced by Automated Market Makers (AMMs). It enables anyone to submit trades in batches, encouraging competition among traders. This competition acts as a self-correcting mechanism, ensuring FMโAMM always trades at the equilibrium price set by a larger market. This eliminates opportunities for arbitrage and manipulative tactics like leverage and sandwich attacks. Within a batch, all trades occur at the same price, further preventing manipulation. Even strategic attempts to move prices across batches are thwarted by arbitrageurs seeking to exploit any price discrepancies.
Maximizing Objective Functions: A defining aspect of the FMโAMM lies in its objective-driven trading approach. By maximizing an objective function. The FMโAMM strategically executes trades to optimize outcomes.
If the objective function is defined as the product of the two liquidity reserves, then for a given price p, the FM-AMM determines the amount x token to supply by solving the optimization problem:
xFMโAMMโ(p)=argmaxxโ[(Xโx)(Y+pโ x)]
pFMโAMM(x)โกp(x)=xYโ2xโpCPAMM(x)=xYโxโ
A traditional CPAMM always trades along the same curve given by Yโ X, while the FMโAMM trades as to be on the highest possible curve.
The FMโAMM's trading function is all about keeping things balanced in the market. It uses a carefully designed trading algorithm to make sure that the amount of assets available for trading is in line with what people want to buy and sell. This helps to keep prices stable and fair. Additionally, the FMโAMM can work with different investment strategies where the amount of money put into each investment stays the same.
pโ (XโxFMโAMM(p))=Y+pโ xFMโAMM(p).
In other words, for a given p, the values of the two liquidity reserves are equal after the trade. Therefore, an FMโAMM with product function trades to implement a passive investment strategy, in which the total value of the two reserves is equally split between the two assets (that is, a passive investment strategy with weights 1/2,1/2.
CFAMM's are path-independent: splitting a trade into multiple parts and executing them sequentially does not change the average price of the trade. This property does not hold for an FMโAMM because traders can get better prices by splitting their trade. In fact, by splitting their trade into arbitrarily small parts, traders pay approximately the same price as on the corresponding CFAMM.This is why an FMโAMMโs trading function can be implemented only if trades are batched.
Comparison between the cumulative returns of a simulated FMโAMM with those of the corresponding Uniswap v3 pool.
The FMโAMM's trading fee matches that of the Uniswap v3 pool being compared.
In most high-volume pairs, providing liquidity on the FMโAMM consistently outperforms Uniswap, except for the ETHโUSDT 0.05% pool where returns are approximately equal.
Even if the FMโAMM receives only 30% of Uniswap v3's total trading volume as noise trading, it can outperform Uniswap. This scenario seems plausible given the likelihood of noise trading on Uniswap being higher than 30%.
Fee and Rebalancing: Higher fees in an FMโAMM lead to smaller rebalancing trades that occur at the new equilibrium price.
Path Dependence and Return: The frequency of rebalancing impacts LP returns. A single large batch trade may offer less benefit than multiple smaller trades that "move the FMโAMM up the curve."
Comparison with Uniswap v3: The default fee used in the FMโAMM simulation might not be optimal.A zero fee for the MATICโETH pair outperformed the same fee used in Uniswap v3.
In all the pools studied, the return of providing liquidity on an FMโAMM exceeds that of providing liquidity on Uniswap as long as FMโAMMโs noise trading volume exceeds 3030% of the volume of the corresponding Uniswap pool, which under approximation corresponds to 50% of that Uniswap poolโs noise trading volume.
Batching serves as an off-chain component of the AMM, collecting trades and settling them both peer-to-peer and on the FMโAMM as a single transaction. However, this introduces a vulnerability: the malicious "batch operator".Since the batching process occurs off-chain, this entity has the responsibility of collecting and settling trades. While the smart contract managing the FM-AMM can prevent manipulation by limiting the batch operator to one transaction per block, the operator retains discretion over which transactions are included in the batch. This discretion could be exploited by the batch operator to suppress trades and act as the sole arbitrageur, maximizing their profits. Just as the first arbitrageur reaches a CFAMM after an equilibrium price change, the batch operator holds the exclusive power to rebalance the pool and exploit this opportunity. However, the loss that FMโAMMโs LP's may face from a malicious batch operator are half of the losses that CPAMMโs LPs routinely face from arbitrageur. It is also possible to introduce punishments on the batch operator in case it misbehaves. There could be social punishments such as LPs withdrawing their liquidity, (and hence making FMโAMM useless), automated slashing of dedicated funds, or even legal remedies if the batch operator is a legal entity.
FMโAMM leverages trade batching to achieve several advantages. By eliminating the need for path independence and fostering competition among arbitrageurs, FMโAMM captures profits previously enjoyed by arbitrageurs, improves returns for liquidity providers, and eliminates sandwich attacks. Simulations show that FMโAMM can outperform existing AMMs like Uniswap v3. Furthermore, FMโAMM has the potential to significantly reduce MeVin DeFi by eliminating arbitrage profits and potentially mitigating liquidation MeV in lending protocols.