Walraswap: equilibrium-based decentralized exchange integrating external AMM liquidity

arXiv:2310.12255 · q-fin.MF, econ.TH · Submitted 2023-10-18 · Read on arXiv

Listen

Radio episode about this paper

Transcript

Introduction to the show: ident: Quantitative Finance. The day in quantitative finance: models of markets, risk and prices.

Ruth: I'm Ruth.

Warren: And I'm Warren, here with Iris.

Ruth: We're looking at the paper: "Walraswap: equilibrium-based decentralized exchange integrating external AMM liquidity".

Warren: Here's the gist of the paper. Consider a finite set of trade orders and automated market makers (AMMs) at some state The solution is based on Brouwer’s fixed-point theorem This paper proposes a solution to finding an equilibrium price vector to execute all the orders jointly with corresponding optimal AMMs swaps.

Ruth: The Core Problem and Approach The primary focus of that paper is an algorithm to compute Brouwer’s fixed-point This article addresses a problem that is currently central in the context of public blockchains.

Warren: The aim is to protect end users through a system that executes the trade orders in a commutative manner.

Ruth: The solution is obtained as a walrasian equilibrium

15: of a pure exchange system constructed from the original trade orders plus virtual trade orders associated to the AMMs.

Title and authors: Ruth: The paper we're discussing is "Walraswap: equilibrium-based decentralized exchange integrating external AMM liquidity." We're seeing how they approach this problem of finding a joint equilibrium for trades and AMMs.

Warren: It’s about using Brouwer’s fixed-point theorem to find that equilibrium price vector, which allows them to execute all the orders simultaneously with the optimal AMM swaps.

Iris: What I find interesting is how they model the behavior of the automated market makers, treating them as passive machines rather than active agents in this specific analysis.

Ruth: That’s right. They don't consider the liquidity providers behind AMMs; they focus on the auctioneer, who has a balance for each token starting at zero.

Warren: The paper suggests that the chosen AMM swaps must be such that there isn't another choice that increases the auctioneer’s balance of every token, at least one of them strictly.

The paper's summary: Ruth: To summarize what this paper is proposing, they are building a system where every order in the batch gets executed at the relative price determined by that equilibrium vector.

Warren: This means they’re aiming for a fair market execution across all trade orders and AMM swaps simultaneously, which helps with optimal resource allocation when handling large sets of trades.

Iris: They're defining an admissible supply function, which has two key conditions: it must be continuous and satisfy the Walras law where the sum of the supply values for each token is zero.

Ruth: And they introduce a stricter condition for this function, called a strict supply function, which guarantees that there is a price vector where the total value of all those orders equals zero.

Warren: The main result hinges on showing that if you have such a strict supply function, then there must exist a price vector p where the net value of any trade is zero.

The paper's improvements: Ruth: One significant improvement they highlight is how this approach helps mitigate maximal extractable value, or MEV. They compute that price vector p such that the final price at each AMM, given by the right derivative of the return function, aligns with that price vector.

Warren: By doing this, they claim to eliminate arbitrage opportunities and protect end users from MEV exploitation because if prices were discrepant, it would mean there's an opportunity to slightly modify amounts for a better outcome.

Iris: They also model the AMM operation using concave functions, which means the right derivative exists at every point and is decreasing, allowing them to precisely calculate the optimal swap amounts for each token.

Ruth: And they connect this back to virtual agent allocation by assigning a specific virtual agent to each AMM based on a relationship called hC equals hfc g c equals gfc.

Conclusion: Warren: So, wrapping up, the paper "Walraswap: equilibrium-based decentralized exchange integrating external AMM liquidity" provides a method for finding an equilibrium price vector to execute all orders jointly with corresponding optimal AMM swaps.

Ruth: It achieves this by using Brouwer’s fixed-point theorem on a strict supply function, which is what guarantees that there's a price vector where the net value of every trade is zero.

Iris: From my side, the work is interesting because it focuses on identification; they are checking that the variation they are using actually does the work and that this equilibrium condition is indeed what we need to satisfy.

Warren: The limitation they point out is that their analysis assumes AMMs are passive machines, not agents participating in the auction themselves, which allows them to achieve price coherence between orders and swaps.

Ruth: So, while it's a solid mathematical framework for finding this equilibrium, the paper notes that treating AMMs as active agents would lead to incompatibility with the price coherence assumption they want to maintain.

Iris: That's a fair point; their view that AMMs are not agents and don't need to receive the same effective price as trade orders is what enables them to fulfill price coherence.

Sergio Andrés Yuhjtman

q-fin.MF, econ.TH

Submitted: 2023-10-18

Updated: 2026-11-03

License: http://creativecommons.org/licenses/by/4.0/

Importance score: 76/100

The gist: Consider a finite set of trade orders and automated market makers (AMMs) at some state The solution is based on Brouwer’s fixed-point theorem This paper proposes a solution to finding an…

Key concepts

Walrasian Equilibrium
This is the goal: finding a stable price vector where the net value of every trade is zero. It means all supply (orders) perfectly matches all demand (AMMs) at a single, consistent price point, allowing for simultaneous execution.
Fixed-Point Method
This mathematical tool helps find the equilibrium. In this context, it means finding a specific price vector 'p' that satisfies the conditions where the supply and demand functions meet exactly at that point.
AMM Function Properties
AMMs are modeled using concave functions. These functions must be increasing, bounded above, and have a decreasing right derivative. This mathematical structure allows the system to precisely calculate optimal swap amounts based on current prices.

Terminology

Summary

Consider a finite set of trade orders and automated market makers (AMMs) at some state The solution is based on Brouwer’s fixed-point theorem This paper proposes a solution to finding an equilibrium price vector to execute all the orders jointly with corresponding optimal AMMs swaps. p. 0

Where the paper says it

Walraswap: a solution to uniform price batch auctions Sergio Andr´es Yuhjtman, Flashbots Abstract Consider a finite set of trade orders and automated market makers (AMMs) at some state. We propose a solution to the problem of finding an equilibrium price vector to execute all the orders jointly with corresponding optimal AMMs swaps.

The Core Problem and Approach

The primary focus of that paper is an algorithm to compute Brouwer’s fixed-point This article addresses a problem that is currently central in the context of public blockchains. The aim is to protect end users through a system that executes the trade orders in a commutative manner. p. 0

Where the paper says it

One of the answers to the MEV phenomenon was the design and adoption of applications that allow to execute trade orders in batches, possibly including AMM swaps in those batches [11], [4], [1]. The aim is to protect end users through a system that executes the trade orders in a commutative manner.

The solution is obtained as a walrasian equilibrium[15] of a pure exchange system constructed from the original trade orders plus virtual trade orders associated to the AMMs. p. 1
Where the paper says it

In sections 2, 3, 4, 5, 6 we develop the technical details to answer to this question affirmatively. The solution is obtained as a walrasian equilibrium[15] of a pure exchange system constructed from the original trade orders plus virtual trade orders associated to the AMMs.

Theoretical Framework for Equilibrium

Fixed-point methods lie at the heart of mathematical economics Equilibrium price vectors are expressed as fixed points of an appropriate function. The supply functions must satisfy two basic conditions: (0) φ(λp) = φ(p) ∀λ > 0, ∀p ∈ Pn, and (1) φ(p) · p = 0 which means that the net value of any trade must be zero. p. 1

Where the paper says it

The absolute value |φi(p)| indicates the amount to be sold or bought if the prices are p. They satisfy two basic conditions: φ(λp) = φ(p) ∀λ > 0, ∀p ∈ Pn meaning that only relative prices are meaningful, and p · φ(p) = 0 which means that the net value of any trade must be zero (the tokens bought must exactly compensate for the tokens sold).

Furthermore, for a strict supply function, there is a p ∈ Pn such that φ(p) = 0. p. 2
Where the paper says it

Definition 2. An admissible supply function φ is said to be “strict” if it satisfies ψi(p) < 0 for pi = 0, for every i ∈ In.

Modeling AMM Behavior

An AMM function is a map R≥0 f−→ R≥0 with the following properties: (a) it is increasing, (b) f(0) = 0, (c) it is bounded above, and (d) it is concave. The right derivative exists at every point x ≥ 0 and ∂+f−−→ R≥0 is decreasing and right continuous. p. 5

Where the paper says it

The following properties hold: (I) The right derivative exists at every point x ≥ 0. Moreover, R≥0 ∂+f −−→ R≥0 is decreasing and right continuous.

The map hf −−→ R≥0, hf (r) = min(x ≥ 0/∂+f(x) ≤ r) is decreasing and continuous. p. 5
Where the paper says it

lim∞ ∂+f = 0. (III) The map R>0 hf −−→ R≥0, hf (r) = min{x ≥ 0/∂+f(x) ≤ r} is decreasing and continuous.

The Final Equilibrium Condition

The argument from the last paragraph is a strong motivation for the question: is it possible to find a vector p such that all of the auctioneer balances are nonnegative after the operation? The resulting surplus function si(p, hC,p) ≥ 0 where each term is positive or zero by proposition 5. p. 8

Where the paper says it

(b) If φ is a strict supply function, there is a p ∈ Pn such that si(p, hC,p) ≥ 0 for every index i. Moreover, there is a p such that the i-th surplus function takes the form si(p, hC,p) = X out(c)=i fc ◦ h c (pin(c)/pi) − g c (pi/pin(c)) where each term of the sum is positive or zero.

2 (V). This condition ensures that the chosen AMM swaps at our solution have to be such that there does not exist another choice that increases the auctioneer’s balance of every token, at least one of them strictly. p. 1
Where the paper says it

The chosen AMM swaps at our solution have to be such that there does not exist another choice that increases the auctioneer’s balance of every token, at least one of them strictly. This condition is known to be equivalent to the existence of a price vector such that the final price at each AMM (given by the right derivative of the return function1 ) is in accordance with that price vector.

Computational Aspects and Comparison

The auctioneer system has to decide which tokens it will allow in the auction Another way to further reduce the running time of the algorithm in practice is to lower the dimension n by restricting the topology of the exchange graph, so that it is possible to divide and parallelize the problem. The comparison with recent work shows that our point of view is that AMMs are not agents and there is no apparent reason why the swaps should receive the same effective price as agents. This allows us to fulfill price coherence, which is desirable as we explained in the introduction. p. 0

Where the paper says it

1 Introduction Fixed-point methods lie at the heart of mathematical economics. Equilibrium price vectors are expressed as fixed points of an appropriate function.

p. 0
Where the paper says it

1 Introduction Fixed-point methods lie at the heart of mathematical economics. Equilibrium price vectors are expressed as fixed points of an appropriate function.

The convex method proposed in section 5 of “Augmenting Batch Exchanges…” is not likely to be applicable to compute the solution expressed by theorem 6. p. 0
Where the paper says it

These questions were previously considered in [16] and [12]. Our method is closely related to the algorithm proposed in [12], so we include a comparison between both in section 8.

1 (b).

Conclusion and Application

Corollary 6.2 provides a sufficient condition to apply theorem 6. p. 9

Where the paper says it

We are particularly interested in the case where φ = X θ∈O θ for a set O whose elements are continuous limit sell orders and continuous limit buy orders. The following corollary provides a sufficient condition to apply theorem 6.

1 to such φ, with any system of AMMs on n tokens. p. 0
Where the paper says it

If the AMMs are ignored, we can choose an equilibrium for the system given by the trade orders only. Ignoring the AMMs is intuitively suboptimal as suggested from the following simple examples for the case of two tokens and only one AMM available that operates this pair.

The necessity of the strictness condition is highlighted by the example at remark 2 after theorem 2. p. 9
Where the paper says it

On the other hand, for buy orders and supply functions coming from AMMs we have lim∞ g = 0 (see proposition 5. The necessity of the strictness condition is highlighted by the example at remark 2 after theorem 2.

4. In blockchain applications, a system running batch auctions will typically perform executions periodically. p. 0
Where the paper says it

Walraswap: a solution to uniform price batch auctions Sergio Andr´es Yuhjtman, Flashbots Abstract Consider a finite set of trade orders and automated market makers (AMMs) at some state. We propose a solution to the problem of finding an equilibrium price vector to execute all the orders jointly with corresponding optimal AMMs swaps.

For a general continuous map from the n-dimensional simplex to itself, Scarf developed an algorithm for computing a fixed point. p. 0
Where the paper says it

In “The approximation of fixed points of a continuous mapping” [13], Herbert Scarf observed that the pure exchange case can be solved by means of Brouwer’s fixedpoint theorem, so there is no need to resort to the more general Kakutani’s fixed-point theorem. As indicated by its title, the primary focus of that paper is an algorithm to compute Brouwer’s fixed-points.

The auctioneer system has to decide which tokens it will allow in the auction. p. 7
Where the paper says it

See figure 1. (d) We associate to the system C the supply function φ C = X c∈C φ c 6 Uniform price batch auction with AMMs available Given a set of trade orders and AMMs operating on n tokens, we want to establish the existence of a price p ∈ Pn such that the prescribed operation on the orders and AMMs at price p can be performed without providing tokens from any other source.

The following proposition gives the underlying general statement for these type of situations. p. 7
Where the paper says it

If the set of trade orders is O we can represent the supply function for each order simply as an element θ ∈ O. In the following theorem we have in mind the case where φ has the form φ = X θ∈O θ Notice that the theorem allows very general trade orders: there are no monotonicity or differentiability conditions and each of them might operate more than two tokens.

Comparison with Recent Work

We will now focus on the differences between [12] and our work. Probably the most important difference in the premises is that they treat AMMs as agents participating in the auction, so that AMM swaps will receive the same effective price as trade orders. p. 7

Where the paper says it

See figure 1. (d) We associate to the system C the supply function φ C = X c∈C φ c 6 Uniform price batch auction with AMMs available Given a set of trade orders and AMMs operating on n tokens, we want to establish the existence of a price p ∈ Pn such that the prescribed operation on the orders and AMMs at price p can be performed without providing tokens from any other source.

This assumption leads to their theorem 1. p. 1
Where the paper says it

If q ̸= p then it would not be true that p is the fair market price, since for some pair of tokens it would be possible to get a better price by using the AMMs. A similar and more rigorous statement is that for a given p, under the assumption that the utility of the tokens is linear and dictated by the vector p, 2 the choice q = p maximizes the utility for the auctioneer (theorem 6.

6 which states that this treatment for AMMs is incompatible with the price coherence assumption, i. p. 1
Where the paper says it

If q ̸= p then it would not be true that p is the fair market price, since for some pair of tokens it would be possible to get a better price by using the AMMs. A similar and more rigorous statement is that for a given p, under the assumption that the utility of the tokens is linear and dictated by the vector p, 2 the choice q = p maximizes the utility for the auctioneer (theorem 6.

e. the condition that there is a price vector that determines the final prices of AMMs. p. 8
Where the paper says it

Figure 1: illustration of how a virtual agent is chosen for each AMM in the proof of theorem 6. The vector p determines the slope of the blue line, while q represents the final prices of the AMMs.

On the other hand, our point of view is that AMMs are not agents and there is no apparent reason why the swaps should receive the same effective price as agents. p. 1
Where the paper says it

We think of AMMs as passive machines. On the other hand, we will consider the utility from the point of view of the auctioneer.

This allows us to fulfill price coherence, which is desirable as we explained in the introduction.

Acknowledgements

thanks to Christoph Schlegel from Flashbots for informing us about the paper [12] and the use of fixed-point methods to obtain equilibrium points in mathematical economics. The references listed at the end provide context for the mathematical foundations used throughout the paper. p. 0

Where the paper says it

As indicated by its title, the primary focus of that paper is an algorithm to compute Brouwer’s fixed-points. This article addresses a problem that is currently central in the context of public blockchains.

Green — the paper says it, and the page is printed. Red — no passage carries it, so treat that sentence as unverified. The same check runs on your own text: check a summary against its source, $5.

Improvements for AI systems

  1. Improvement of Batch Trade Execution via Walraswap Equilibrium Finding

The improved system can find an equilibrium price vector p such that every order in the batch is executed at the relative price determined by that vector, ensuring a fair market execution across all trade orders and AMM swaps simultaneously. This allows for optimal allocation of resources when executing large sets of trades.

  1. Improvement of Maximal Extractable Value (MEV) Mitigation

The system can compute a price vector p such that the final price at each AMM (given by the right derivative of the return function1) is in accordance with that price vector, thereby eliminating arbitrage opportunities and protecting end users from MEV exploitation.

  1. Improvement of AMM Operation Modeling

The system can model complex Automated Market Makers using concave functions where "the right derivative exists at every point x >= 0 and R>=0 ∂+f --> R>=0 is decreasing," allowing for the precise calculation of optimal swap amounts hC,p.

  1. Improvement of Virtual Agent Allocation

The system can assign a specific virtual agent to each AMM based on hC = hfc g c = gfc and then compute the resulting surplus function si(p, hC,p) which is guaranteed to be non-negative because each term is positive or zero by proposition 5.2 (V).

  1. Improvement of Trade Order Handling

By using continuous limit sell and buy orders, the system can accurately represent complex trading strategies as a strict supply function φ, ensuring that a root p such that φ(p) = 0 exists to satisfy the equilibrium condition.

Abstract

This article advocates the development of a decentralized exchange protocol for Ethereum based on Walrasian equilibrium. Building on previous work (arXiv:2111.02719, arXiv:2210.04929), it develops a mathematical framework that incorporates liquidity from independent automated market makers (AMMs). Trade orders are represented by continuous monotonic pairwise supply functions and external AMMs are represented by concave swap functions. Under a connectivity condition, we establish the existence of a common clearing-price vector and external swaps that jointly fulfill the prescribed orders while leaving a nonnegative surplus of every token. External AMMs execute ordinary swaps according to their own pricing rules, including swap fees. For the selected clearing-price vector, the prescribed external swaps maximize the value of the batch surplus. We also establish structural properties of equilibrium, including invariance of individual net trades across equilibria, and formulate equilibrium computation as a convex optimization problem. We then outline Walraswap, an exchange protocol for Ethereum with off-chain batch construction and on-chain settlement. Its proposed governance and solver accountability mechanisms aim to encourage public order disclosure and discourage censorship. The protocol design explores how the mathematical construction could support decentralized trading with reduced opportunities for maximal extractable value.

Sources

Related papers