🤖 AI Summary
This work addresses the challenge of securely quoting constant-product automated market makers in cross-chain or sharded environments, where non-atomic transaction sequences—particularly concurrent pending liquidity provision and withdrawal—undermine safety guarantees. Under the assumption that P ≠ NP, the paper establishes for the first time that no polynomial-time approximation algorithm with a fixed approximation ratio exists for this secure quoting problem. To overcome this theoretical hardness, the authors propose two efficient algorithms whose approximation ratios depend adaptively on input characteristics. Through rigorous computational complexity analysis, virtual pool modeling, and approximation optimization, the study not only delineates a fundamental lower bound on the problem’s inherent difficulty but also delivers practical, deployable solutions that achieve strong empirical approximation performance in real-world scenarios.
📝 Abstract
Automated market makers exchange assets through liquidity pools whose quoted prices depend on their reserves, with constant product pools being the most common. When such pools reside on different blockchains or shards, a sequence of swaps cannot in general be executed atomically. Aanes et al. introduced lock-swaps and retroactive constant product liquidity pools to provide price guarantees for such a setting. A retroactive pool implicitly maintains a virtual pool for each possible execute/cancel resolution of its active locks. In the presence of active locks, serving a new swap request requires computing a safe quote; a quote with an output that does not exceed the minimum possible output, taken over all virtual pools. The quote being safe is a hard constraint ensuring the integrity of the pool. A soft constraint is to make the quote as close to the minimum possible output as possible. Aanes et al. gave a simple and efficient algorithm for computing the exact minimum when unresolved provides and reclaims of liquidity do not coexist, showed by an explicit example that the algorithm fails in general, and left the computational complexity of the general case open. In this paper, we show that unless P is equal to NP, there is no polynomial time algorithm that computes in the general case a safe quote with any fixed multiplicative approximation ratio (e.g., 50%) relative to the exact minimum. This seems like a severe obstacle for deployment of the lock-swap functionality. However, we also present two simple and practical algorithms for computing safe quotes that have input-dependent approximation ratios that are likely to be satisfactory in practice, thus circumventing that obstacle.