From CoWs to Multi-Chain AMMs: A Strategic Optimization Model for Enhancing Solvers

By 0xbrainjar

We are pleased to share that we have had a paper accepted for presentation at the 2024 IEEE Cybermatics Congress. Our paper is titled “From CoWs to Multi-Chain AMMs: A Strategic Optimization Model for Enhancing Solvers”. The authors are Zeshun Shi of the Cybersecurity Group at Delft University of Technology as well as myself and Sydney Sweck of the Composable Foundation.

This paper describes how we developed an optimization model for solvers on the Mantis framework. We were further able to demonstrate the efficacy of this model via testing. Below, I break down our research process and findings.

Problem Statement

The cross-chain DeFi ecosystem is rapidly evolving and complex, making it often difficult for users to navigate. An intents-based framework, such as Mantis, provides an opportunity to streamline this experience while also providing users with best execution. A solver network is critical to optimizing execution of intents on such a framework.

Thus, the present research sought to:

  1. Create a strategic optimization model for a blockchain-based token exchange platform (such as Mantis), optimized for better transaction outcomes
  2. Incorporate the principles of Coincidence of Wants (CoWs) and multi-chain Automated Market Makers (AMMs) to enhance this model?
  3. Validate this model’s effectiveness

Background & Definitions

Relevant concepts and definitions to the present research are as follows:

Cross-Chain Interoperability: Asset exchanges and communication between disparate ledgers, extending to synchronized transactions across multiple blockchain ecosystems. (1)

Intents: Expressions of what a user wants to achieve when interacting with a blockchain protocol. (2)

  • Parts of transactions, requiring other parts as complements to form a final transaction satisfying a user’s constraints
  • Off-chain signed messaged that encodes which state transitions a user wants to achieve
  • Examples: “transfer X asset from blockchain A to blockchain B”, or “trade X asset for Y asset”

Solvers: Entities that compete to determine an optimal solution (in the form of a transaction execution pathway) for a user’s intent. (3)

Coincidence of Wants (CoWs): An economic phenomenon where each party possess an item that the other party desires. (4)

  • These parties can exchange these items directly to meet their wants
  • No 3rd party intermediary is needed, eliminating fees that the exchanging parties would otherwise pay

Automated Market Makers (AMMs): Entities that automate market making to maintain a constant presence to buy/sell assets, improving market efficiency. (5)

Constant Function Market Makers (CFMMs): A subset of AMMs using smart contracts and predefined trading algorithms. (6)

  • Subsets of CFMMs include constant sum, constant product, and constant mean

Methods

With an intent settlement framework like Mantis in mind, an optimization model for CoWs was devised, which:

  • Dictates decision-making among users
  • Integrates individual utilities of a set of trading orders, factoring in each order type (limit-buy or limit-sell) and relevant parameters
  • Implements constraints based on the CoWSwap model (7)

The objective of the optimization model is shown below:

With the aforementioned objective in mind and relevant constraints and optimizations applied, we created an algorithm for solvers to optimize intent settlement:

We then apply the algorithm under a range of experimental conditions:

Solver setup: Experiments used the Gurobi Optimizer v.9.5.1. The model uses Python.

Order details (Table 1): Orders are represented as tuples consisting of buy/sell token indices j and k, buy and sell limits xm and ym, exchange rate π, and order type t (where ‘b’ indicates a limit-buy order and ‘s’ indicates a limit-sell order).

|623.902350038082x272.0000000000001

CFMM configuration (Table 2): Experiments involved 5 simulated CFMMs. Each was on a different blockchain with fixed transaction costs, fees, token indices, and specific reserves.

Results

Results for the simulations are depicted in the three figures below, with some of the most important findings discussed in the text:

Figure 1: Different simulation experiments applied to the optimization model of CoWs

The first row of graphs in Figure 1 depicts how objective values relate to order buy and sell limits under various scenarios. Objective value decreases with increasing buy limits in the first figure, and increases with increasing sell limits in the second figure. This indicates that lower buy limits and higher sell limits may result in more favorable outcomes.

The second row of graphs in Figure 1 depicts the relationship between clearing prices and other factors. These four figures show that changes in the sell limit have less of an impact on the clearing price than changes in the buy limit.

Finally, the third row of graphs in Figure 1 depicts the number of tokens transacted in relation to buy and sell limits as well as exchange rates. For limit-buy orders, as the buy limit increases, the number of tokens increases, peaks, and then falls (shown in the first and second figures of the row). For limit-sell orders, the number of tokens transacted remains more stable (shown in the thirds and fourth figures of the row)

Overall, Figure 1 depicts the complex interplay of various market conditions and the objective value.

Figure 2: Different simulation experiments applied to the optimization model of CoWs for different CFMMs

Figure 2 depicts the impact of various market conditions on the optimization model when applied to different types of CFMMs. The first row of diagrams in this figure depicts a constant product market maker (using Uniswap v2 as an example). The second row depicts a constant sum market maker. The final row depicts a constant mean market maker (using Balancer as an example).

Under similar data settings, all three CFMMs exhibit similar trends, though Balancer achieves the highest objective value overall. Notably, objective value decreases with increased blockchain transaction costs (as shown in the first column of diagrams in Figure 2), tighter trade volume limitations (as shown in the second column of diagrams in Figure 2), and increased commission fees (as shown in the third column of diagrams in Figure 2). Objective value increases with increased reserves (as shown in the fourth column of diagrams in Figure 4), highlighting the importance of sufficient liquidity.

Figure 3: Completion Rates of CoWs Versus CFMMs for Executing Trades Under Various Order Constraints

In Figure 3, the blue bars represent trade execution under various conditions using CoWs order matching alone. The red bars represent trade execution using our optimization model to leverage CFMMs. Under different experimental conditions, our optimization model is able to significantly improve order completion rates (by 26.1% to 46.1%) compared to using CoWs alone.

Conclusion

In our paper “From CoWs to Multi-Chain AMMs: A Strategic Optimization Model for Enhancing Solvers”, we created a novel strategic optimization model for enhancing solvers that facilitate cryptocurrency intents using CoWs and multi-chain AMMs. This model works for the Mantis cross-chain intent settlement framework, but can be applied to other solver networks.

Benefits of this model include:

  • It reduces dependency on centralized mechanisms
  • It enhances privacy and security
  • It improves user outcomes and market fairness significantly (26.1% to 46.1% improvement in order completion over using CoWs alone)

Overall, this experiment demonstrates the positive impact an optimization algorithm implemented by solvers can have on order execution. Moreover, this research provides us with a specific, proven algorithm that we can incorporate into solvers on the Mantis network.

In the future, we plan to expand on this work by enhancing the solver algorithm with more sophisticated decision-making and adjustments. Furthermore, we will work with the Picasso Network to extend cross-chain functionality to include more blockchains.

For even more details of this experiment, keep an eye out for the complete paper, which we will share upon publication.

References

  1. S. Ou, Weiand Huang, J. Zheng, Q. Zhang, G. Zeng, and W. Han, “An overview on cross-chain: Mechanism, platforms, challenges and advances,” Computer Networks, vol. 218, p. 109378, 2022. Available: https://www.sciencedirect.com/science/article/pii/S1389128622004121
  2. C. Goes, A. Sun Yin, and A. Brink. (2022) Anoma: a unified architecture for full-stack decentralised applications. Accessed: Nov. 6, 2023. [Online]. Available: whitepaper/whitepaper.pdf at main · anoma/whitepaper · GitHub
  3. Introduction: Cow Protocol. Accessed: Nov. 6, 2023. [Online]. Available: Solving auctions | CoW Protocol Documentation
  4. Coincidence of Wants. Accessed: Nov. 6, 2023. [Online]. Available: Coincidence of Wants | CoW Protocol Documentation
  5. V. Mohan, “Automated market makers and decentralized exchanges: a DeFi primer,” Financial Innovation, vol. 8, p. 20, 2022. Available: Automated market makers and decentralized exchanges: a DeFi primer | Financial Innovation
  6. G. Ramseyer, M. Goyal, A. Goel, and D. Maziéres, “Augmenting batch exchanges with constant function market makers,” 2023. In Conference on Economics and Computation (EC ’24), July 8–11, 2024. Available: https://arxiv.org/pdf/2210.04929
  7. CowSwap: First CoW Protocol UI. Accessed: Nov. 6, 2023. [Online]. Available: GitHub - cowprotocol/cowswap: 🐮 CowSwap: First CoW Protocol UI