Modeling Trade Size for Arbitrage Between Constant-Product Pools
Summary
The document asks how to choose the trade size that maximizes profit when exploiting a price difference between two constant-product market-making pools. Because each pool’s quoted rate changes with the amount traded, a small trade can receive a different average price from a large one. The questioner illustrates how buying a large share of a finite pool can sharply raise the purchase cost as liquidity is depleted.
The answer recommends modeling the price as a function of position size and then finding the relevant extremum analytically or by inspection, rather than testing sizes incrementally. It suggests that the described price curve may be nonlinear, but does not derive a constant-product swap equation, combine the two pools’ pricing curves, or calculate a profit-maximizing trade size. The response also cautions that the question’s market-making terminology and theoretical setup may not map directly to a real exchange. Consequently, this is a high-level modeling direction, not a complete sizing method; fees, slippage, execution constraints, and changing pool reserves are not worked through.
Key ideas
- In a pool with size-dependent pricing, trade volume changes the effective price received.
- Arbitrage sizing can be framed as optimizing profit over a modeled trade-size function.
- Analytical optimization may avoid checking candidate volumes one at a time.
- The response does not provide a complete constant-product formula or a calculated optimal size.
- Real implementations must account for exchange mechanics and execution costs that the discussion omits.
Tags
Full text
# Answer by Chris (score 3, accepted) # How can I calculate the amount of volume to use to ensure highest profit on an arbitrage trade of two Constant Product Market Making exchanges? If there exists an arbitrage opportunity between two Constant Product Market Making exchanges, how can you confidently determine the maximum volume to use in order to ensure highest profit? I can imagine incrementing and testing various values, but it seems extremely inneficient. As an example: These exchanges do not have an orderbook, but rather provide a varying rate that depends upon the volume of the input. A rough example would be the following: If I were to buy 1 share of AAPL, I would get it for $174.13. If I were to buy 2 shares of AAPL, I would get it for less, maybe $174.10. The rates are derived from the amount of liquidity in the market (imagine a pool of AAPL stock). If there are 1000 AAPL in the pool, and you tried to buy 999 of them, the price would be in the millions of dollars, because you will have effectively depleted the pool. ## Answer by Chris (score 3, accepted) https://quant.stackexchange.com/a/44343 You're kind of asking for a specific answer to a fundamentally nebulous question. First, a 'constant product market marking exchange' isn't a real thing. From the link you included, it looks like the paper talks about a theoretical framework, potentially rooted in something real, but theoretical nonetheless. To answer more generally, based on the mechanics you described, you can model this. From what you've said, I imagine price/share, if plotted price as Y and position size as X would look like a parabola of some kind (highest price would occur for very small positions and very large positions, approach infinity for purchase of the entire market). You can pretty easily find the minimum price by inspection or using analytical methods if you want to get picky.
Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.