HawSwap: Application of Virtual Inventory in AMM

HawSwap
5 min readDec 4, 2020

Talking about the impermanent loss again

The term impermanent loss is a term that originated from Uniswap, which is a side effect of AMM (automatic market-making) mechanism based on ‘x * y = k’. Today we will explain it in a simple and understandable way:

Assuming that the current price of ETH is 400USDT, at this time, the liquidity of hundreds of millions of dollars is also distributed with ETH and USDT assets at a ratio of 1:400. In this case, many people feel that ETH has a lot of room for appreciation, so they would prefer to initiate exchange transactions in this liquidity pool. For example, they exchanged 40,000 USDT for 100 ETH, because according to the AMM liquidity pool, inventory determines the pricing mechanism. Such exchange slippage is very small. Compared with a pool with a capacity of hundreds of millions of dollars, 100 ETH has a very small impact and has a small impact on price changes.

Really as this investor expected: ETH quickly rose to 500USDT, so he benefited a lot. Then there is a question, where did the money he made come from? Yes, if the liquidity pool is not exchanged with him, this profit will still lie in the pool. In other words, if the convertor makes the right decision, although the USDT in the pool will increase as the price rises, but the ETH will decrease accordingly. When the price rises, the liquidity pool and the investors who made the right decision to share the price increase. Income! This is also the origin of impermanent losses, and the liquidity pool will naturally provide liquidity, which is also the foundation of this business.

Let’s take a closer look at how the price of the centralized trading platform is formed. It is generated based on the order book and transactions, and there will be smaller orders in the order book, which are distributed above and below the current transaction price in the form of sell and buy orders. Eager to make a deal or other market participants will take the initiative to eat these orders and turn them into deals, so the pricing is generated. In other words, the order book completes the pricing on a smaller scale, or the price discovery function. In contrast, Uniswap’s price discovery mechanism is slow and inefficient, especially when the scale of liquidity is too large. The same is true if the liquidity is too small.

What is Virtual Inventory

In order to increase the efficiency of liquidity price discovery, we cannot immediately change the pricing of inventory changes caused by the exchange but we could release them slowly based on quantity and time. That is to say, we could introduce a time dimension to gradually release inventory changes within a certain period of time. This principle is somehow like Newton’s law of cooling proposed by Newton in the 17th century: the cooling rate of an object is proportional to the temperature difference between its current temperature and room temperature. The amount of change and time are considered together to affect the inventory of liquidity.

Of which,

  • T(t) is a time (t) function of temperature (T). Calculus tells us that the rate of change in temperature(cooling) is the derivative T’(t) of the temperature function.
  • H represents room temperature, and T(t)-H is the temperature difference between the current temperature and room temperature. Since the current temperature is higher than the room temperature, this is a positive value.
  • The constant α (α>0) represents the proportional relationship between the room temperature and the cooling rate. The negative sign in front means cooling down. Different substances have different alpha values.

Finally, it can be simplified as:

Where the “cooling factor” is a value of your own choice. Assuming that the initial score of a new paper is 100 points and the “cooling” is 1 point after 24 hours, then the “cooling factor” can be calculated to be approximately equal to 0.192.

There are several different cooling curves:

Curve

Virtual inventory means that the ‘attenuation system’ can be calculated based on the amount of change (initial value), the final value (such as the final amount of change is 0), and the duration of the change. In this way, our inventory changes will be smoother, as if some inventory has been “virtualized” out.

The application of virtual inventory

In the process of exchange transactions, we use attenuation release to build virtual inventory as follows:

Swap Curve

Of which:

A: Initial balance

B: Virtual inventory relative to Swap within a certain period.

Vectors 0A, 0Q: A linear representation of the real price

Vector BC, DE, ZQ: Arbitrage trading based on virtual inventory.

Vectors XY, YZ, ZQ: Arbitrage trade conversion in the process of real balance.

Deposit & Withdraw Curve

Among them:

A: Initial balance

B: The real balance after deposit

X, M: Initial virtual inventory

Y, N: Virtual inventory after deposit

HawSwap

HawSwap will use the optimization algorithm of virtual inventory to convert part of the arbitrage opportunities that originally occurred in the pool into the income of liquidity holders. At the same time, some financial products will be designed and packaged to produce liquidity mining products with no losses of impermanence.

Please stay tuned.

--

--

HawSwap

A Decentralized Financial Infrastructure Protocol Advanced liquidity, Auction protocol, Option insurance $Haw $DeFi #Auction $HawSwap