RFS Apply
Request for Startups

Relic: ML-Enabled AMM

2024-08-01

State of AMMs

Automated Market Makers (AMMs) have become a cornerstone of decentralized finance, enabling seamless trading of digital currencies; AMMs like Uniswap and Curve process billions of dollars in volume weekly. However, many current AMM designs face a common challenge: inflexibility around pool fees. Traditional AMMs like Uniswap V3 rely on fixed fee tiers (e.g., 0.05%, 0.3%, 1.0%) set at pool creation. This static approach fails to adapt to the rapid shifts in market conditions that are characteristic for many of the assets trading on these AMMs.

The rigidity of current AMM designs leads to suboptimal outcomes for both liquidity providers and for traders. In volatile markets, fixed fees may not adequately compensate liquidity providers for their risk. Conversely, during periods of low volatility, high fixed fees can deter traders, reducing overall trading volume and liquidity. This one-size-fits-all approach limits the efficiency and attractiveness of AMMs in an ecosystem that demands adaptability, as well as encouraging fragmented liquidity by forcing the creation of multiple pools for the same asset pair.

Introducing Relic

Enter Relic, a prototype we’ve created of an AMM that leverages Ritual’s infrastructure to use machine learning for dynamically adjusting pool parameters in real-time. By integrating predictive models directly into the AMM’s core functionality, Relic creates a more responsive and efficient trading environment.

Relic animated

At the heart of the Relic prototype is a model that predicts future market volatility for an asset pair. This model analyzes a wide range of market indicators, sourcing data both on and off-chain, to forecast volatility for the next period. Based on these predictions, Relic can adjust fees dynamically and atomically at the time of the swap transaction by leveraging the SPCs Ritual’s infrastructure provides. Even with a simple model that predicts volatility, pools open themselves up to a wider range of fee strategies.

One strategy could lower fees during predicted high volatility periods to optimize for better user experience and for the highest number of swaps, ultimately increasing protocol revenue. This means a more seamless and cost-effective swapping experience. Another could do the inverse, adjusting fees upward in periods of high volatility to better compensate liquidity providers for their increased risk. This kind of optionality when creating pools ensures that the AMM remains attractive to both traders and liquidity providers across various market conditions.

Looking Forward

While this example implementation focuses on volatility-based fee tier adjustment, in general the design space for ML models used in conjunction with AMMs is vast. There are a number of other ideas that have caught our interest in terms of future features and mechanisms. For example, another common factor that can impact LVR (loss-versus-rebalancing) on pools and affect LP accrued fees are the types of order flow coming in for that pool. Generally speaking, LPs are exposed to more LVR when dealing with toxic order flow and this can erase much of the profits accrued through fixed trading fees. Training a machine learning model to discriminate/classify order flow accurately, we could dynamically update the fee tier of the pool depending on the type of order flow we expect to encounter. By accurately increasing fees on toxic order flow, while reducing fees for uninformed order flow, we are minimizing LVR for the LPs, while also making swaps cheaper for your average retail participant.

There are many other interesting angles to explore, such as implementing loyalty programs or volume-based rebates, and incorporating more complex market indicators and on-chain data into these models. We are also interested in the model marketplace that could emerge in the kind of AMM protocol where multiple pools for the same asset can be differentiated in their performance through the underlying model that drives the pool’s fee strategy. Additionally, by paying a portion of these pool fees as a performance fee to the provider of the model, we align the incentives to ensure our platform has the best modelers competing to optimize our pools. The variety that this kind of diversified model ecosystem provides an AMM means that it can serve a much broader range of participants (LPs, retail, informed flow, etc), all with differing goals, without having to necessarily take the tradeoffs that would be required in a fixed system.

Interested in building this all the way? Make sure to apply to Altar.