Introducing Minerva — VirtuSwap AI for liquidity optimization

Alex Zaidelson
8 min readMar 28, 2023

--

The problem

LPs are notoriously bad at providing liquidity, as follows from the lively online discussion (see References).

On UniSwap, the distribution of liquidity among pools is done entirely independently by LPs, and every pool is on its own.

Curve and Balancer introduced the Gauge model, where the protocol rewards are distributed between different pools according to gauge voting. Holders of the project’s vote-escrowed governance token can vote for one or more pools, and the distribution of protocol rewards between pools is determined accordingly. As a result, pools with higher rewards attract higher liquidity, and pools with lower rewards lose liquidity. Importantly, the allocation of rewards and resulting liquidity allocation among pools are not done to maximize the total pie for all LPs (something that a benevolent central planner would do), but instead as an outcome of “wars” among LPs, which have negative externalities in equilibrium. In other words, every pool is on it’s own. Overall, while this model is decentralized and democratic, it is largely fueled by greed and self-interest and prone for manipulation.

The VirtuSwap Orchestra of Pools

VirtuSwap is different from traditional AMMs in more than one way. The first one, is our unique reserve-based virtual pool technology (read more here).

The second, somewhat subtler one, is the fact that VirtuSwap is an orchestra of pools, and the pools cooperate to serve trades.

Indeed, two pools are required to construct a virtual pool, and the subsequent exchange of reserves also requires several pools to complete.

It appears that VirtuSwap DEX works best with a hub-and-spoke pool architecture. This means that there is one (or several) central asset(s), e.g. DAI, WETH or USDC, and there is a VirtuSwap pool between the Central asset and every other asset in the system.

VirtuSwap Hub-and-Spoke architecture with DAI as the central asset

This architecture allows the DEX to serve trades between any two assets in the system. So, the 8 pools in the example above allow serving 28 different pairs directly.

But what is the best orchestra? What is the optimal set of pools that will provide the best results for traders and LPs?

AI to the rescue

With a properly posed question, the advanced AI and optimization algorithms are capable of providing an answer.

The question we asked ourselves is as follows:

Given a certain amount of liquidity, and assuming that VirtuSwap is accessible through aggregators, what is the best configuration of VirtuSwap DEX that maximizes the total served trade volume and generates the most fees for our LPs?

To solve this complex optimization problem, we started developing the Minerva engine, named after the ancient Roman goddess of wisdom and also the sponsor of arts, trade and strategy.

How Minerva Works

Minerva - the Roman goddess of wisdom, justice, law and victory

Selecting the Assets

Minerva works on a per-epoch basis, calculating the optimal liquidity allocation for a day or a week ahead.

First, the algorithm selects a certain number of assets that need to be supported. This is determined by taking the top N of the “99 Percent” assets traded on DEXes through top aggregators on a given blockchain in the last epoch (e.g. last day or last week)., ranked by the total volume of indirect trades that occurred for those assets.

Once the list of assets is chosen, the actual optimization work begins.

Formulating the Optimization Problem

Mathematically, the basic liquidity optimization problem can be formulated as follows:

Were:

  • V(x) is the objective function — a simulation function calculating the total volume obtained by VirtuSwap pools on the market given a set of trades, a set of VirtuSwap pools and a set of other pools on the market
  • x is a vector, representing the amounts of liquidity placed in every one of the selected VirtuSwap pools
  • liq_i is the amount of liquidity deposited in VirtuSwap pool i
  • L is the total amount of liquidity available for distribution

The Simulation Function

The Simulation function is one of the key pieces of the Minerva engine. It simulates the behavior of a router such as 1Inch, Paraswap or KyberNetwork, finding the best way to route a given trade through a given set of pools.

For every epoch, the function receives information on all the trades expected in the upcoming epoch (estimated as the trades that occurred in the last epoch) and all the AMM pools available on the market, with their respective liquidities.

In the process of optimization, the function gets a certain distribution of liquidity to VirtuSwap pools, adds those VirtuSwap pools to the total set of pools available to aggregators, and performs the best possible routing of trades. Actually, it simulates what would have happened if a given set of VirtuSwap pools was accessible through the aggregators. The resulting target variable is the total trade volume that would have been served by VirtuSwap pools if they had a given amount of liquidity.

The goal of the optimization process is to find vector x (in other words, a distribution of TVL between VirtuSwap pools) that leads to the highest possible volume of trades, and thus, LP fees, served by VirtuSwap.

It should be noted that the calculation involves a large quantity of matrix operations and is quite computationally intensive. Running the Simulation on GPUs increases the performance by a factor of 20 relative to CPU.

Solving the Optimization Problem

The liquidity optimization problem is a class of computational problems that are notoriously difficult to solve in polynomial time. We determine it as an NP problem with the time complexity of O(n!) in the worst scenario.

We are using a combination of well-known and our own, proprietary, optimization algorithms to find the right solution.

We will be covering the exact inner workings of Minerva optimization algorithms at a later stage.

Preliminary results

The initial results of running Minerva on various scenarios show very promising results. It appears that optimized VirtuSwap DEX provides up to 5 times higher return on liquidity (i.e. amount of fees per dollar of liquidity) than the existing DEXes.

That is a very important result, meaning that the VirtuSwap model leads to greater capital efficiency for the 99 percent assets, and will attract more and more LPs, gradually serving a larger and larger share of the market.

It is worth noting that VirtuSwap benefits both traders and LPs — traders’ costs go down by up to 50%, attracting more and more volume, while LP profits are up to 5 times higher than in other models.

How Minerva will be used

The description above is purposefully a bit simplistic. In reality, VirtuSwap does not really manage the liquidity (it is deposited and withdrawn by LPs at their own accord). What the VirtuSwap DAO will control is the distribution of rewards among the pools. By directing more or less rewards to different pools according to Minerva recommendations, the DAO influences the TVL of the pools and can bring the distribution of liquidity in the system to a desired state.

At launch, the initial rewards distribution between the pools will be suggested by Minerva engine and approved by the DAO, and will afterwards be updated every epoch.

At a later stage, gauge voting may be introduced, and will be combined with the Minerva recommendations. For example, 50% of the protocol rewards may be distributed between pools according to the results of gauge voting, and another 50% according to Minerva recommendation, all subject to the discretion of the VirtuSwap DAO.

A combination of the two will allow VirtuSwap to find a balance between the “Common good” — total trading volume across the protocol (given that purely egoistic incentives are a classic case of the Tragedy of the Commons, which leads to inefficient allocation); while the second represents the “egoistic interest” or the right of individuals who contributed their funds for the benefit of the protocol, to use their voting power to try and receive benefits for their efforts.

The Path to Decentralization

The first release of Minerva engine is centralized and will be run by the VirtuSwap Foundation to assist the DAO in making informed incentivization decision making.

However, this is only the first step towards the fully decentralized future of Minerva.

Our vision is to gradually develop Minerva into a truly decentralized network, in several steps.

Step 1 — Distributing the calculation of the Simulation function between multiple workers. Workers would stake VRSW and perform part of the calculations in return for a reward. Honesty of the workers will be validated by the central node run by the DAO.

Step 2 — Introducing Validators to make validation of Workers distributed. Validators will also stake VRSW and get protocol rewards for their work.

Step 3 — Introducing additional Liquidity Distribution proposers. Anyone should be able to run a node that will propose optimal distribution of liquidity in current market conditions. Validators will reach consensus on which proposal is the best, and the winning proposer will be rewarded by a special reward every time they win. Note that the baseline proposer will still continue to be maintained by the DAO to guarantee that a good solution exists even if other proposers malfunction or become malicious.

A preliminary scheme of the future Minerva Network is shown below:

Minerva Network scheme

Later down the road, Minerva optimization services may be also opened up for other protocols. For example, we could envision protocols like Curve and Balancer using Minerva in parallel with their Gauge voting systems to make protocol rewards allocation more egalitarian and beneficial for the protocol as a whole.

Conclusion

In this introductory article, we briefly covered the goals of using the AI-based Minerva engine for reaching optimal distribution of liquidity, the basic principles of its operation and the path forward. Minerva liquidity optimization engine plays an integral role in VirtuSwap’s ability to greatly outperform other AMM-based DEXes by achieving lower trading costs and generating larger returns to LPs.

References

  1. Half of Uniswap v3 liquidity providers are losing money: New research https://cointelegraph.com/news/half-of-uniswap-v3-liquidity-providers-are-losing-money-new-research
  2. Uniswap Liquidity Provision: Is the Yield Worth the Risk? https://medium.com/gammaswap-labs/uniswap-liquidity-provision-is-the-yield-worth-the-risk-c45a4a850700

VirtuSwap is a new kind of DEX with unrivaled efficiency.

VirtuSwap team is comprised of finance professors and crypto veterans, and backed by industry heavyweights.

We are on a mission to make DEXes dominate the crypto trading landscape, and we are accomplishing it through research, financial engineering and data science.

Don’t forget to like and share.

Follow us on: Twitter | Discord | LinkedIn | Telegram | Medium| Website

--

--

Alex Zaidelson

CEO at SCRT Labs, Adviser at VirtuSwap, former CEO at Beam. Researcher, Builder, Believer.