Automated Market Makers (AMMs) represent a class of decentralized exchange mechanisms that rely on a fixed mathematical formula to price assets. Popular AMM protocols utilize a constant function approach which is deterministic in design. However, these designs are plagued with issues such as impermanent loss, slippage costs, and market risk incomputability. These issues result in a relatively high price impact of trades for users and relatively high fees to compensate liquidity providers for the associated risks. More specifically, the design allows arbitrageurs to siphon off value from traders and liquidity providers in these AMM protocols.
We would like to make the case for the development of a new class of AMM designs based on stochastic pricing that would dynamically adjust to market information. The stochastic design would function like a profit maximizing market maker which we could solve through optimal control theory. This design would help to mitigate various problems in current AMM mechanisms such as decreasing price impact of trades, more efficient use of provided capital, and decreased impermanent loss for liquidity providers.
AMM Design Weaknesses
Angeris and Chitra (2022) find that under sufficient conditions and under fairly general assumptions, agents who interact with constant function market makers are incentivized to correctly report the price of an asset in a computationally efficient way. They provide sufficient conditions for these CFMMs to be well-behaved, in the sense that agents are incentivized to correctly report asset prices and can never drain the assets of the CFMM by only trading with the given CFMM. The CFMM constitutes thus a sufficient functioning mechanism for (decentralized) trading purposes. There are, however, a few core problems including deterministic slippage costs, impermanent loss for liquidity providers, and improper accounting of market risk. These problems result in higher price impact of trades and increased fees (to compensate liquidity providers for the risk). More specifically, the problems contribute to the siphoning of value from AMM traders and liquidity providers to arbitrageurs.
The primary risk of liquidity providers is impermanent loss (IL) which constitutes the difference in value over time between depositing tokens in an AMM versus simply holding those assets. This loss occurs when the market-wide price of tokens inside an AMM diverges in any direction. Since AMMs do not automatically adjust their exchange rates, an arbitrageur is required to buy the underpriced assets or sell the overpriced assets until the prices offered by the AMM match the market-wide price of external markets. The profit extracted by arbitrageurs is siphoned from the pockets of liquidity providers, creating a loss. LP positions in current AMM designs are de facto short volatility investments. Current AMM designs compensate liquidity providers for this risk of impermanent loss by relatively high fees. However, Loesh et al. find that most passive LPs in Uniswap – except for professionally active “flash LPs” who provide intra-block liquidity – lost money relative to just holding the asset due to impermanent loss. Implementing range orders only partially solves this problem as the impermanent loss is just capped at the lower end of the range.
The price, which is determined by the bonding curve, follows a deterministic function and as a result slippage costs follow a deterministic function as well. Prices are a (constant) function of the amount of tokens and are thus relatively deterministically predictable based on the inventories. From the lack of dynamic price adjustments AMMs could be seen as rather “static”. This deterministic slippage leads to a deadweight loss that arbitrageurs can capture at the expense of users. This deterministic slippage cost could also lead to front-running and miner extractable value (Angeris et al, 2022). Furthermore, conventional AMM designs do not properly account for market risk as price discovery happens in a rather naive way. AMM designs de facto assume price arbitrage to make AMM prices efficient. More specifically, the price discovery depends on cross-exchange arbitrage rather than a pricing oracle for reference prices. The market risk is paid by the users and liquidity providers and there is no proper computation of market risk within the pricing of the AMM mechanism. It should be noted that this market risk (incomputability) creates a hedging difficulty.
Finally, the vAMM construct inherits similar weaknesses as a result from its deterministic bonding curve design. Some have argued that due to path independence, vaults have enough collateral to renumerate traders. However, this assumes that undercollateralized positions would be liquidated on time before losing money which is not always the case during market volatility. Because of this undercollateralization most vAMMs have an insurance pool to pay for these losses. You could argue that the vAMM is a victim of adverse selection by traders in this case. The vAMM inherits the same impermanent loss as the conventional AMM construct only the traders would bear the costs instead of LPs.
Why Stochastically Dynamic AMMs?
AMMs have been a popular trading venue as they have the advantage of decentralization and continuous liquidity. Traditionally market makers provide inventory and help determine prices by matching supply and demand in an auction-like game. In AMMs, liquidity providers supply the asset inventory and the prices are determined by the pricing algorithm. The advantage of this is that users obtain immediate liquidity without having to find an exchange counterparty, whereas liquidity providers receive fees for this service. AMMs allow for an exchange to occur immediately which could be important for low liquidity assets. This makes the AMM design interesting for relatively new protocols to launch crypto tokens while allowing for a simple trading environment without the need of active market makers to provide liquidity. Traders have an disincentive to post orders in thin markets as they would reveal information with little benefit which relates to the no-trade theorem of Milgram and Stokey.
You could view market making as a series of actions where an equilibrium is found that balances supply and demand. The rules of the auction are fixed by the exchange, and in the case of AMMs these rules are executed by a smart contract. Although there are some issues in current AMM designs, tools within Web3 provide an opportunity for built-in mechanism design within smart contracts. One can argue that the biggest innovation of smart contracts was the ability to enforce design mechanisms and thus directly implement market design. The goal of market design is to help reduce some of the negative externalities and inefficiencies preventing markets from achieving efficient first best outcomes. As argued by Robinson and Konstantopoulos, Ethereum is a dark forest as it is an adversarial environment where code is law and weak designs are exploited. We argue that you could directly implement more advanced mechanism design considerations through smart contracts, and thus solve the current problems in AMMs through old-fashioned mechanism design.
To understand how a stochastic design could help with some of the problems in AMMs, we would need to take a closer look at impermanent loss. Milionis et al. (2022) define impermanent loss in different ways: as cost of commitment for giving up future optionality, as the cost of arbitrage against the pool, and as an information cost due to the unavailability of correct market prices. For simplicity, we could view impermanent loss as the loss of liquidity providers because external arbitrageurs harness gamma convexity gains on every round trip in a self-financed arbitrage strategy against the AMM. It should be noted that the gains of external arbitrageurs are stochastic in this case because different paths ending up at the same spot go through different realized volatility. In a limit order book market makers would dynamically adjusts their hedge portfolio for a given percentage move in the spot and harnesses the cash gamma. AMMs have generally failed in protecting users from toxic order flow of arbitrageurs where especially unsophisticated users are taken advantage of. The evidence tends to show that passive LPs have received the short end of the stick. As argued by Cohen (2022), providing ambient liquidity (liquidity that is not very actively managed) on volatile tokens is a negative expected value strategy in AMMs.
We would argue that the AMM mechanism would need to manage the positions while allowing LPs to provide passive ambient liquidity. You could apply a stochastic framework in an optimal control problem that decides on the market maker’s optimal actions in terms of quoting prices. This way the effective bonding curve would be more dynamic on market circumstances. In this construct one is essentially solving for an optimal control problem as one is deciding on the market maker’s optimal actions in terms of his expected PnL, under certain risk constraints. This design would allow for passive LP participation where the liquidity is managed by the AMM protocol. A stochastic design tackles the previously discussed problems in AMMs. The impermanent loss for liquidity providers is solved through the stochastic mechanism that actively manages LP positions. The slippage costs adjust by order size and actions like front-running of trades can be mitigated. Market risk is taken into account in the market oracle based pricing mechanism as prevailing market conditions such as volatility impact the market making behavior. Stochastic bonding curves can improve price discovery by allowing the market to adapt to changes in supply and demand in a more responsive way.
Stochastic Models for Optimal Market Maker Behavior
One could construct a stochastic framework to derive a solution that describes optimal behavior of a market maker. As aforementioned, one would be solving an optimal control problem in deciding the market maker’s optimal actions or policies. This is similar to the work of Chitra et al. (2022) who discuss DeFi mechanisms from an optimal control point of view through a stochastic model. The market maker aims to maximize his expected period profit-and-loss (PnL) subject to various (risk) constraints. There are other approaches to this problem such as one implemented by Swaap Labs where they have designed a constant geometric AMM which embeds a stochastic spread mechanism. We would argue, however, that one needs to incorporate a framework that solves for optimal market making behavior. There is substantial previous work on stochastic models for optimal market making behavior including the seminal paper of Avellaneda and Stoikov (2008). Other authors have extended the model to incorporate inventory constraints, directional alpha views, mutually exciting order arrivals, and regime switching. These frameworks can be applied to derive optimal market making behavior in AMM protocol designs.
We would first need to define the price dynamics of the spot process where you would need to assume a distribution which allows to construct a stochastic process with tunable moments. In addition to the price dynamics you need to specify the dynamics of order arrivals. Finally you would need to define the market maker’s utility function in terms of his PnL. This would represent the market maker's problem which you would like to optimize where you could use stochastic optimization methods. Stochastic optimization deals with the challenge of finding optimal decisions in dynamic systems affected by random noise. A central tenet of optimal control theory is the use of optimization techniques to determine the control input that minimizes or maximizes a certain performance criterion, typically expressed as a cost or utility function. An optimal control problems typically involve a dynamic system, which can be described by a state equation and a control input. In optimal control theory, these can be solved by deriving the Hamilton-Jacobi-Bellman (HJB) equations, which are partial differential equations (PDE) that characterize the value function associated with the optimal control problem. In cases where a closed-form solution exists, these are typically solved by guessing an appropriate ansatz, substituting the optimal controls for the verification equation, and solving the equations via Feynmann-Kac representations. However, in most settings and specifications of dynamics, the optimal policy needs to be derived numerically. Yet, under certain assumptions, minimum tick size constraints, closed-form approximations may be amenable.In the limit the stochastic AMM should thus be efficient if the design solves for the HJB equation which gives a necessary and sufficient condition for optimality. It should be noted that the simplicity comes from approximating the solution by a closed-form solution. For example, Kim et al. (2023) have derived analytical approximations for an optimal market making model for HashCurve protocol.
If you want to talk about ideas around NFTs, DeFi or protocol design, feel free to shoot me a message! @HashCurveKris