How VirtuSwap Reimagines DEXes: Part I

Evgeny Lyandres
5 min readJul 5, 2022

--

In our previous article, we illustrated a significant inefficiency plaguing existing DEXes — a large fraction of trades is indirect (“triangular”) due to a lack of native liquidity pools of sufficient size — leading to unnecessarily high costs of trading (duplicate fees, price impact, and gas). These excessive costs are of tremendous magnitude — around $500M in our estimation were wasted over the past 12 months just on Uniswap and its forks.

In this article, we explain how Virtuswap mitigates this problem. In one sentence, VirtuSwap uses a novel pool architecture, based on reserve-powered virtual liquidity pools, which solve the problem of triangular trading by making every trade direct — even in the absence of a corresponding pool, and generates up to 50% savings.

How VirtuSwap works

Let’s come back to our hypothetical example of a triangular trade. As in our previous article, assume that a user would like to buy MATIC and to sell USDC — however, the native MATIC-USDC pool does not exist. Pools WETH-MATIC and WETH-USDC do exist, leading to a triangular trade on a typical DEX, as illustrated in Figure 1.

Figure 1: Illustration of a triangular trade

A crucial difference between VirtuSwap and all other DEXes is that on VirtuSwap, in addition to two “main assets”, every pool allows accepting “reserves” of other assets. Think of several safe deposit boxes attached to the pool — each allowed to hold one particular asset — but which are empty at first, when the pool is established. For example, the WETH-MATIC pool can accept reserves of USDC, USDT, DAI, and WBTC, and WETH-USDC pool can accept reserves of USDT, DAI, WBTC, and MATIC. (These lists are just for the sake of an example; in reality pools can accept and hold reserves of many more assets.) Figure 1 describes the virtual-pool-based architecture.

Figure 2: VirtuSwap pool architecture

So now, when our trader wants to swap USDC for MATIC, she goes to the WETH-MATIC pool (i.e. the pool that contains the asset she wishes to acquire) and just deposits her USDC as a reserve (i.e. to the appropriate safe deposit box) of the WETH-MATIC pool.

Reserves are kept in the pools for a limited amount of time, exchanged back for the pool’s native assets from other pools’ reserves (more on that in the following articles).

Example of a trade on VirtuSwap

How do we know the price (or, more precisely, the AMM trading curve) based on which the trader will receive MATIC in exchange for USDC sent to the WETH-MATIC pool? Let’s go over an example using concrete numbers.

Assume that WETH-USDC pool contains 1,000 ETH and 1,000,000 USDC, and WETH-MATIC pool contains 500 WETH and 1,000,000 MATIC. Assume that the trader wishes to acquire MATIC for 10,000 USDC.

On Uniswap, this trade would amount to sending 10,000 USDC to the WETH-USDC pool, receiving 9.871 WETH based on the constant product formula used in Uniswap (after paying the 0.3% pool fee and around 1% price impact); and then sending 9.871 WETH to the WETH-MATIC pool, and receiving 19,304 MATIC (after paying the 0.3% pool fee and around 2% price impact). In addition to the overall trade cost (double fees plus double slippage of 20,000–19,304)/20,000=3.47%), the trader would have to pay the gas costs twice for the two legs of this triangular transaction.

Let’s come back to VirtuSwap. To enable trading via a reserve, we need to define a “virtual” USDC-MATIC pool. To avoid any possible exploits, VirtuSwap operates the most conservative virtual pools, which are based on the “lowest common denominator” between respective real pools. In our example, the lowest common denominator between WETH-USDC and WETH-MATIC pools is 500 WETH. Thus, a virtual USDC-MATIC pool, based on 500 ETH on each of the aforementioned real pools, “contains” 500,000 USDC and 1,000,000 MATIC.

From the trader’s perspective, there is complete indifference between trading on a real vs a virtual pool. In our example, the trader can sell 10,000 USDC on the virtual pool and receive 19,550 MATIC — resulting in 2.25% overall trade cost (fee plus price impact) and gas costs associated with only a single swap transaction.

In reality, since a trade via the virtual pool is just an abstraction, the trade has to happen on a real pool — via a reserve. Figure 2 describes a trade in which one of the base assets (MATIC) is taken from the pool and a reserve asset (USDC) is deposited into the pool reserve.

Figure 3: Trading via a reserve asset

Generalizations and conclusions

Abstracting from savings in gas, in this example the trade’s cost is reduced by 35%. The rate of reduction in trading costs depends on several factors, most important being the relative size of the pools used for a triangular trade on a standard DEX — the more similar the pool sizes used for a two-hop trade, the closer the savings on VirtuSwap to 50%; and if more than two hops are used on a standard DEX, VirtuSwap savings can be even larger.

The reality is somewhat more complex than the diagram in Figure 2, as oftentimes virtual pools can be created using various combinations of real pools. In case multiple virtual pools exist, VirtuSwap employs a smart routing algorithm (similar in spirit to Uniswap smart routing, but quite different in implementation) to minimize the overall cost of trading.

Importantly, the savings achieved from trading via VirtuSwap technology are robust to various modifications of constant-product AMMs, such as concentrated liquidity (as in Uniswap v3) and non-constant-product-based trading curves (as in Curve). In fact, savings obtained by trading on VirtuSwap are orthogonal to virtually any modification of a standard constant-function AMM technology. VirtuSwap V1 will be using the simple Constant Product formula, and we will be adding more sophisticated models in later versions.

To summarize, by using reserve-powered virtual pool architecture, VirtuSwap creates direct liquidity in places in which it did not exist before and makes trading more efficient.

In this article, we have described the benefits of VirtuSwap architecture to the traders. In the next article, we will be focusing on the gains to liquidity providers — which turn out to be significant as well!

Learn More and Join the Conversation:

--

--