- [[#Overview|Overview]]
- [[#Links|Links]]
- [[#Challenges for AMMs|Challenges for AMMs]]
- [[#Empirical Findings|Empirical Findings]]
- [[#Mathematical Formulations|Mathematical Formulations]]
- [[#Wuxing Correspondence Table|Wuxing Correspondence Table]]
This section summarizes the key points from the paper "[[Quantifying Price Improvement in Order Flow Auctions]]" by Bachu, Wan, and Moallemi.
- [[Quantifying Price Improvement in Order Flow Auctions]]
- [[Framework for Price Improvement in OFAs]]
- [[Execution Quality in OFAs]]
The paper identifies several challenges faced by Automated Market Makers (AMMs) on blockchain systems like Ethereum:
- [[Fragmented Liquidity]]: AMMs encounter issues with [[Fragmented Liquidity]]
- Susceptibility to Adversarial Strategies: AMMs are susceptible to [[Adversarial Strategies]] that can extract value from the system.
- Unpredictable Trade Executions: AMM [[Unpredictable Trade Executions]] can be unpredictable.
These challenges have led to significant financial losses in the ecosystem, with studies estimating that [[Inefficiencies and Adversarial Strategies in AMMs]] have extracted over $540 million USD from the AMM ecosystem over 32 months.
The methodology was applied to historical data from OFA interfaces like [[1Inch]] and [[Uniswap]], revealing that:
-
Price Improvement Findings: OFAs, particularly those utilizing RFQ-informed onchain Dutch auction systems (like 1Inch Fusion and UniswapX), can achieve significant price improvements compared to traditional AMMs.
-
Attribution Findings: The majority of price improvements on both 1Inch and Uniswap interfaces are achieved through better routing and access to additional liquidity sources. OFAs like 1Inch Fusion and UniswapX show a small but non-zero amount of gas overhead compared to traditional AMMs like Uniswap Classic, translating to 0.5-1 basis points of degradation. The interaction between gas efficiency and priority fee savings also contributes a decent amount to the overall price improvements.
-
Comparison Findings: At the interface level, the Uniswap interface provides significantly higher price improvements than the 1Inch interface, except for a few blocks prior to settlement. Both interfaces demonstrate statistically significant positive price improvements compared to the common baseline across a range of block offsets.
The key mathematical formulations presented in the paper are:
-
Price Definition:
-
For transactions where the input or output token is the gas token (e.g., ETH/WETH):
$$p = \frac{o}{i + g(b + f)}$$ -
For transactions where gas is internalized by the OFA:
$$p = \frac{o}{i}$$ The paper presents the following price definitions:
-
-
For transactions where the input or output token is the gas token (e.g., ETH/WETH):
$$p = \frac{b' - b}{a - a'} = \frac{o}{i + g(b + f)}$$ Where:
-
$p$ is the realized price -
$b'$ and$b$ are the post-trade and pre-trade balances of the output token -
$a'$ and$a$ are the post-trade and pre-trade balances of the input token -
$o$ is the amount of output token received -
$i$ is the amount of input token provided -
$g$ is the amount of gas used -
$b$ is the base fee per gas -
$f$ is the priority fee per gas
-
-
For transactions where gas is internalized by the OFA:
$$p = \frac{o}{i}$$ Where:
-
$p$ is the realized price -
$o$ is the amount of output token received -
$i$ is the amount of input token provided
-
These price definitions ensure that the transaction costs, including gas fees, are properly accounted for when calculating the realized price of a trade. This allows for a consistent comparison of prices across different OFA systems, regardless of how they handle gas costs.
-
Price Improvement (PI):
$$\pi = \frac{p - p'}{p'}$$ - Where
$p$ is the realized price and$p'$ is the counterfactual baseline price The paper defines price improvement (PI) as:
Where:
-
$\pi$ is the price improvement -
$p$ is the realized price of the trade -
$p'$ is the baseline or counterfactual price
The baseline price
Where
The baseline is primarily generated by calling the Uniswap Classic routing API with historical blockchain state data to simulate a counterfactual trade at the settlement time of the actual trade.
This definition of price improvement allows for a consistent comparison of the realized trade price against a reasonable baseline, taking into account the specific blockchain conditions at the time of settlement.
The paper also introduces the concept of price improvement over time:
Where
-
Price Improvement Attribution:
$$\pi = \pi_{routing} + \pi_{gas} + \pi_{fee}$$ - Where:
-
$\pi_{routing}$ represents PI from routing optimization -
$\pi_{gas}$ represents PI from gas optimization -
$\pi_{fee}$ represents PI from priority fee optimization The paper proposes a model to attribute the price improvement ($\pi$ ) into three components:
-
Where:
-
$\pi_{routing}$ represents the price improvement through optimizing liquidity access. This captures the benefits of including more liquidity sources in the routing compared to the baseline. -
$\pi_{gas}$ captures the savings from reduced gas costs compared to the baseline. This reflects the trade-off between accessing sufficient liquidity and managing the transaction's cost-effectiveness. -
$\pi_{fee}$ accounts for the impact of different priority fee settings compared to the baseline. Higher priority fees can offset the gains made through efficient trading and routing strategies.
To compute these attribution components, the paper uses a Taylor series expansion of the price function
Where
This attribution model allows the paper to quantify how much of the overall price improvement can be attributed to the OFA's decisions regarding routing optimization, gas efficiency, and priority fee settings, providing granular insights into the sources of price improvement.
The authors apply this attribution model to the empirical analysis of the 1Inch and Uniswap interfaces, demonstrating how it can be used to compare and optimize the performance of different OFA systems.
- PI Attribution Model: Using a Taylor series expansion:
Where
The paper's PI attribution model is described as follows:
The price function
-
$o$ is the output token amount -
$g$ is the gas used -
$f$ is the priority fee per gas
The price improvement
Where
To attribute the price improvement
Where:
represents the price improvement due to routing optimization (
represents the price improvement due to gas optimization (
represents the price improvement due to priority fee optimization (
The paper then aggregates these components to obtain the overall price improvement:
This attribution model allows the authors to quantify the relative contributions of routing, gas, and priority fee decisions to the overall price improvement achieved by different OFA systems. By breaking down the price improvement in this way, the paper aims to provide OFA implementers with direct insights into how they can optimize their systems to improve trading outcomes for users.
-
Price Improvement over Time:
$$\rho(p; p', \Delta t) = \frac{p - p'(\Delta t)}{p'(\Delta t)}$$ - Where
$\Delta t$ is the time offset from the settlement time The paper introduces the concept of price improvement over time, denoted as$\rho(p; p', \Delta t)$ , where:
Here:
-
$p$ is the realized price of the trade -
$p'(\Delta t)$ is the counterfactual or baseline price at a time offset$\Delta t$ from the settlement time -
$\Delta t$ is the time offset from the settlement time
This definition allows the evaluation of price improvement at different time points relative to the settlement time, capturing the impact of execution speed and timing differences between OFA systems.
For example, when
This time-dependent price improvement metric is particularly useful for comparing OFA systems that may have different execution speeds or timing strategies. It allows the researchers to understand the tradeoffs between faster execution and potentially better prices that may be achieved with a slightly longer execution time.
By incorporating the time dimension, the paper's framework provides a more comprehensive evaluation of the OFA systems' performance, going beyond just the price improvement at the settlement time and considering the dynamic nature of the trading environment.
-
Baseline Generation:
$$B: (i, t) \rightarrow (o', g')$$ - Where
$B$ is the baseline function that maps input amount$i$ and time$t$ to the counterfactual output amount$o'$ and gas used$g'$ The paper describes the process of generating the baseline for comparison against the OFA systems as follows:
Baseline Function
The steps involved in generating the baseline are:
-
API Call for Route Calculation:
- For each completed swap, the authors initiate a request to the Uniswap Classic routing API, providing the input amount
$i$ and the state of the blockchain for several blocks surrounding the settlement block. - The routing API determines the optimal route through Uniswap pools that maximizes the output token amount, net of gas fees, and provides the corresponding calldata.
- The API also provides an estimate of the gas costs associated with executing the transaction.
- For each completed swap, the authors initiate a request to the Uniswap Classic routing API, providing the input amount
-
Simulation via Tenderly:
- The calldata obtained from the routing API is then input into the Tenderly blockchain execution simulator.
- The simulation is performed with a fixed priority fee of 0.1 Gwei and the block number corresponding to the settlement block.
- Tenderly processes the inputs and returns the simulated output, including the amount of gas consumed and other relevant metadata.
This baseline generation process ensures that the counterfactual price
The paper notes that this baseline is chosen because the Uniswap Classic routing API aggregates a significant portion of the total on-chain liquidity, and it underpins the Uniswap interface, which is a major trading platform.
These mathematical formulations provide the foundation for the framework described in the paper to evaluate and compare the price improvement performance of different OFA systems.
The realized price formula can be interpreted through the lens of Wuxing theory as follows:
-
Routing Efficiency (
$\pi_{routing}$ ) - Wood (木) -
Gas Optimization (
$\pi_{gas}$ ) - Fire (火) -
Priority Fee Optimization (
$\pi_{fee}$ ) - Metal (金)
The baseline generation function can be interpreted through the lens of Wuxing theory as follows:
- Optimal Route Calculation - Wood (木)
- Gas Cost Estimation - Fire (火)
- Simulation - Water (水)
These mappings can be added to the Obsidian documentation to provide a comprehensive view of how traditional Wuxing elements are integrated into various financial metrics and formulas across the codebase. This approach not only aids in understanding the mathematical models but also enriches them with philosophical insights, making the analysis more robust and multidimensional.