Source-linked AI summary

An analysis of Uniswap markets

Guillermo Angeris, Hsien-Tang Kao, Rei Chiang, Charlie Noyes, Tarun Chitra

arXiv:1911.03380v7q-fin.TRcs.MAmath.OC

TL;DR

The paper asks whether simple constant product markets can provide reliable pricing despite their simplicity. It formally analyzes constant product and constant mean markets, derives arbitrage and robustness properties, and evaluates Uniswap through large-scale simulation. The results indicate close tracking of reference prices and stability across varied market conditions, while identifying limits from simulation timing and inaccurate market-movement penalties.

  • Problem

    The paper examines whether simple constant product markets can reliably track a reference market price and function as decentralized price oracles.

  • Method

    The paper combines formal analysis of arbitrage and related properties for constant product and constant mean markets with a large-scale agent-based simulation of Uniswap.

  • Results

    Constant product markets have strict no-arbitrage bounds that appear to hold in practice, while simulations show stability across a wide range of market parameters and conditions.

  • Takeaways & Limitations

    Uniswap can serve as a censorship-resistant price oracle when an external reference market has sufficient liquidity.

  • Takeaways & Limitations

    Discrete simulation timing can temporarily break no-arbitrage bounds, and inaccurate penalty functions do not guarantee reaching no-arbitrage in one round.

Abstract

from arXiv · show

Uniswap -- and other constant product markets -- appear to work well in practice despite their simplicity. In this paper, we give a simple formal analysis of constant product markets and their generalizations, showing that, under some common conditions, these markets must closely track the reference market price. We also show that Uniswap satisfies many other desirable properties and numerically demonstrate, via a large-scale agent-based simulation, that Uniswap is stable under a wide range of market conditions.

1 Introduction

Decentralized exchanges seek censorship-resistant cryptocurrency trading without the cost and complexity of traditional or off-chain order-book designs. The paper motivates Uniswap-like AMMs and analyzes their pricing properties, showing that they can closely track reference prices under common conditions.

  • Decentralized financial primitives expanded substantially in 2019, from less than $20 million of Ethereum-based assets in January to $750 million in December.
  • Comparison with other DEXs: Traditional order books are costly in smart contracts because they require large state and complicated matching logic for multiple order types.
  • Comparison with other DEXs: Off-chain trading designs introduce front-running, stale orders, latency arbitrage, and a more complicated threat model through their interaction with blockchain settlement.
  • Automated market makers: AMMs reduce exchange-state storage because their state depends on total deposited quantities, while pricing requires a single function evaluation.
  • Uniswap-like AMMs price assets from reserve quantities and marginal prices, without requiring changes to an asset’s total supply.
  • The paper focuses on constant product and constant mean AMMs, showing that Uniswap closely tracks reference prices and may serve as a censorship-resistant price oracle when external liquidity is sufficient.

2 Constant product markets

The paper formalizes constant product markets, analyzing arbitrage and showing that no-arbitrage conditions keep Uniswap prices close to a reference market price. It also establishes additional properties concerning fees, liquidity, manipulation, trade splitting, depletion, and robustness.

  • Market definition: A constant product market maintains reserves Rα and Rβ with product k, while trades update reserves and increase k when fees are present.Trades that produce nonpositive reserves are not fulfilled.
  • Optimal arbitrage: Under no-arbitrage conditions, Uniswap’s market price deviates from the reference market price by at most a factor of γ.The marginal price is defined by the price of an infinitesimally small trade and is obtained by differentiating the market formula.
  • Other conditions: Larger reserves reduce marginal cost changes, and the price gap becomes more precisely characterized when the reference market has greater reserves than Uniswap.The marginal cost change is strictly decreasing as Rβ increases when μ remains constant.
  • Other conditions: Manipulation costs scale linearly with reserve amounts, while Uniswap cannot be fully depleted through trading and its total reserves remain bounded below.Small price changes may nevertheless be relatively inexpensive because the manipulation cost scales quadratically when ε is small.
  • Extensions of the optimal arbitrage problem: The arbitrage problem is convex, so arbitrage can be efficiently performed across several Uniswap markets, while multi-step strategies cannot outperform the corresponding optimal trade in an infinitely liquid reference market.The paper also notes that a risky variant is analyzed separately and that a penalty function may prevent reaching no-arbitrage in one round.
  • Optimal arbitrage: Higher trade fees loosen the no-arbitrage price bounds, allowing Uniswap’s price to deviate further from the reference market price.For small fees, the paper gives an approximate form of the resulting bound.

3 Constant mean markets

Constant mean markets generalize constant product markets by preserving a weighted geometric mean of reserves. The paper shows that most constant-product properties carry over, although general no-arbitrage conditions may be more complicated.

  • Definition: Constant mean markets preserve the weighted geometric mean of reserves, whereas constant product markets preserve the product of reserves.Constant product markets are the two-coin equal-weight special case of constant mean markets.
  • Market mechanism: Constant mean trading updates reserves under coin-specific fees while maintaining the market’s weighted-mean structure.Trading coin j for coin ℓ uses a fee parameter γj and updates the corresponding reserves and mean constant.
  • Optimal arbitrage problem: The optimal arbitrage problem represents external purchases with Δ and inter-coin trades with Λ, and its equality constraint admits an equivalent convex relaxation.The relaxation follows from concavity and monotonicity of the weighted geometric mean.
  • Properties: Nearly all constant-product conditions and properties extend to constant mean markets, except the constant-product no-arbitrage condition.The paper also identifies nondecreasing product constants, no-depletion, and increasing liquidity with increasing reserves.
  • No-arbitrage conditions: General constant mean no-arbitrage conditions lack a clear closed-form solution and are expected to be more complicated than pairwise necessary conditions.Simple pairwise conditions can be derived, but they are not sufficient in general.

4 Agent-based simulation of Uniswap markets

The paper evaluates Uniswap through an agent-based simulation coupling the contract with stochastic reference markets and several agent types. Across varied conditions, simulations support the theoretical bounds, while liquidity-provider outcomes depend strongly on market returns.

  • Simulation setup: The simulation uses Gauntlet DSL, Python bindings, and a simulated Ethereum blockchain to configure and execute agent interactions with Uniswap.Environment state updates each time step, and positive-utility actions are submitted as blockchain transactions.
  • Simulation setup: Agents trade against either the Uniswap contract or a stochastic market model, with reference prices updated each time step using a power-law process.The reference model includes mean returns and volatility, while arbitrageurs use a risk-penalized objective to account for execution noise.
  • Agent types: The simulation includes arbitrageurs, liquidity providers, and traders, with arbitrageurs targeting deviations between Uniswap and the reference market.Liquidity providers include fixed initial providers and rational providers using portfolio optimization over α, β, and UNI.
  • Results: The results suggest that the theoretical results hold in practice under a wide variety of market conditions.This is the paper’s broad experimental conclusion from the agent-based simulations.
  • Results: No-arbitrage bounds hold under substantial noise and drift when trades are not large, and the marginal Uniswap price remains within the predicted bounds.Figures compare low-noise, low-drift conditions with large negative drift and moderate noise.
  • Limitations: Discrete simulation ordering can temporarily break no-arbitrage bounds when a trader acts last and arbitrage has not yet occurred.Despite this artifact, the final simulated price still tracks the market price.
  • Results: Initial liquidity providers generally have negative utility, becoming positive only when mean market returns are close to zero.Transaction fees can produce positive expected value when providers do not fall behind an equivalent portfolio of the underlying coins.

5 Conclusion

The paper concludes that constant product markets and generalizations combine simple design with theoretical properties that appear to hold across diverse simulated conditions. It therefore views their use as price oracles as initially sound, while leaving broader mechanism generalization for future work.

  • Conclusion: Constant product markets and their generalizations exhibit strict no-arbitrage bounds that appear to hold in practice.The conclusion bases this assessment on simulations spanning a wide range of market parameters and conditions.
  • Conclusion: The paper considers constant-product markets as price oracles at least initially sound within the conditions studied.The conclusion is limited to the paper’s supported scope rather than a universal guarantee.
  • Future work: A broader class of automated market makers may satisfy the same properties, but exploring that generalization remains future work.The paper presents this as a suspected extension rather than an established result.

A The Uniswap arbitrage problem is convex

The arbitrage problem is formulated as a convex optimization, enabling optimal solutions and extensions to interacting constant product markets. Under infinite liquidity, the analysis establishes that no arbitrage occurs when the Uniswap trade is zero.

  • A The Uniswap arbitrage problem is convex: The arbitrage problem becomes convex after expressing one reserve change as a function of the other.The construction uses the convexity of x 7→1/x and composition with an affine function.
  • A The Uniswap arbitrage problem is convex: Because the problem is one-dimensional, convexity is not immediately useful but supports efficient evaluation of optimal m-stage strategies across interacting constant product markets.The same observation also motivates simple generalizations of the arbitrage formulation.
  • A The Uniswap arbitrage problem is convex: The concave objective reaches its constrained maximum either in the interior or at the boundary nearest the unconstrained maximum.This reduces the analysis to the unconstrained problem over [0, +∞), where optimal points satisfy a zero derivative.
  • A The Uniswap arbitrage problem is convex: Under an infinitely liquid market, strict convexity implies no α →β arbitrage, with the optimum occurring at ∆α = 0.Swapping α for β yields the same no-arbitrage result in the general case.

A.1 Extensions to Uniswap arbitrage problem

The arbitrage formulation extends by adding convex penalties and by modeling market response through a decreasing marginal price function. These additions preserve convexity under the stated conditions.

  • A.1 Extensions to Uniswap arbitrage problem: Adding any convex function f: R^2_+ → R that is nondecreasing in its second argument yields another convex optimization problem.The formulation uses variables ∆α ∈ R and ∆β ∈ R.
  • A.1 Extensions to Uniswap arbitrage problem: The extended problem is equivalent to the earlier formulation because the objective decreases with respect to ∆β, making the first inequality constraint tight at optimum.Convexity follows from maximizing a concave objective subject to convex constraints.
  • A.1 Extensions to Uniswap arbitrage problem: A market response model uses a decreasing marginal price m for trading α into β, with m(0) = m_p, so the slippage cost is convex.Convexity follows because the derivative of the cost function is −m, which is increasing.

B Derivation of price gap

The price-gap derivation rewrites the reserve-based trade expression using the constant product structure and a reciprocal expansion. This produces the nearly final approximation used for the paper’s price-gap result.

  • B Derivation of price gap: ∆β = Rβ∆α γ(Rβ − ∆α) gives the reserve-based trade quantity for β as a function of ∆α.
  • B Derivation of price gap: Dividing numerator and denominator by Rα > 0 and applying (1 − x)^−1 = 1 + x + O(x^2) yields the nearly final result.
  • B Derivation of price gap: The resulting expression is then used to obtain the statement given in (7).

C Uniswap portfolio value under Brownian dynamics

The portfolio-value analysis models the market price with geometric Brownian motion and evaluates liquidity-provider payoffs under that dynamics. A replication argument links the required growth rate to a no-arbitrage fee.

  • C Uniswap portfolio value under Brownian dynamics: The market price trajectory m_t is assumed to follow geometric Brownian motion with drift µ and volatility σ.W_t is a standard Brownian motion, and m_1 is normalized without loss of generality.
  • C Uniswap portfolio value under Brownian dynamics: The analysis uses moments of a log-normal random variable to evaluate quantities under the Brownian-price model.
  • C Uniswap portfolio value under Brownian dynamics: A no-fee liquidity-provider payoff can be replicated with less initial capital than required in the constant product market.This implies the constant product portfolio value must grow at a rate specified in the analysis.
  • C Uniswap portfolio value under Brownian dynamics: The choice of γ producing growth at rate e 8 σ2 is identified as the no-arbitrage fee.A volatility-harvesting replication strategy shows that such a γ exists under mild conditions on µ and σ.

D Splitting trades is always more expensive

Sequentially splitting a trade produces less total output than executing the aggregate trade at once, under the constant product market’s feasibility conditions.

  • D Splitting trades is always more expensive: The aggregate trade yields more output than performing the component trades sequentially.The comparison follows from the reserve changes after the first trade and feasibility of the second trade.
  • D Splitting trades is always more expensive: After the first trade, reserves become Rα + ∆α and Rβ −∆β.These updated reserves determine the feasibility and output of the subsequent trade.
  • D Splitting trades is always more expensive: The first trade remains feasible after the reserve update, yielding (Rα +γ∆α)(Rβ −∆β) = RαRβ.This equality is used in the argument establishing the sequential-trade inequality.
  • D Splitting trades is always more expensive: The inequality relies on positive remaining β reserves and the elementary relation for y > x ≥0 with z > 0.The proof explicitly invokes Rβ −∆β > 0 together with the stated inequality.

E Cost of manipulation

The paper derives the cost of manipulating Uniswap’s price relative to an infinitely liquid reference market, then bounds that cost while noting the current constants are loose.

  • E Cost of manipulation: The manipulation-cost analysis assumes an infinitely liquid reference market with ∆β = mp∆α and derives a no-fee lower bound that remains valid with fees.The analysis treats the no-fee case as a lower bound for the fee-bearing case.
  • E Cost of manipulation: An attacker increases the Uniswap price by adding ∆β coins and removing ∆α coins from the pair.The reserve invariant is used to characterize the required trade.
  • E Cost of manipulation: The attacker receives ∆α = Rβ(1 −(√1 + ε)−1)/mp, which determines the attack’s total cost.Here C(ε) denotes the cost of carrying out the attack for one time period.
  • E Cost of manipulation: C(ε) is twice differentiable, increasing, and satisfies C(0) = 0 over 0 ≤ε ≤1, enabling a lower-bound derivation.The proof also uses that C′′(ε) is decreasing on this interval.
  • E Cost of manipulation: The resulting bounds are tight up to a constant multiplicative factor, but their current constants are very loose and mainly theoretical.The tightness follows from the asymptotic behavior of C(ε) as ε approaches zero and infinity.

F The arbitrage problem in constant mean markets

The paper reformulates the constant mean arbitrage problem as a convex optimization problem and notes its log-log convexity as a possible route to broader AMM mechanisms.

  • F The arbitrage problem in constant mean markets: The reformulated problem uses nonnegative trade variables ∆i and auxiliary variables Λij.The constraints specify ∆i ≥0 and Λij ≥0 across all indexed markets and assets.
  • F The arbitrage problem in constant mean markets: Any optimal solution of problem (18) is optimal for problem (12).The equivalence connects the reformulated optimization to the original arbitrage problem.
  • F The arbitrage problem in constant mean markets: The first inequality constraint is tight at every optimum because the objective and weighted geometric mean vary monotonically in opposite directions.This monotonicity argument establishes equality at an optimal point.
  • F The arbitrage problem in constant mean markets: Because the weighted geometric mean is concave, problem (18) is convex.The concavity property supplies the key optimization structure used in the reformulation.
  • F The arbitrage problem in constant mean markets: Problem (12) is also log-log convex after an obvious change of variables, suggesting a way to characterize AMM mechanisms with useful no-arbitrage bounds.The paper presents this broader characterization as a possibility for future work.
Loading 1911.03380v7…