PMM General Liquidity Framework
Last updated
Last updated
An efficient market is flooded with vast amounts of information that underpins market judgments on prices. However, blockchain's on-chain computational resources are limited, making it akin to trying to fit Mount Everest into a pocket when aiming to implement a highly flexible market on-chain.
Fitting Mount Everest into a pocket, while an extraordinary notion, has historical precedents in the realm of the internet, such as image compression and audio compression. The essence of compression lies in extracting the most crucial features while discarding unimportant details. So, what is the most vital feature of a market? The answer is liquidity.
Liquidity can be represented as a depth chart. In the following graph, the depth chart can be abstracted into two triangles, and describing these two triangles only requires the mid-price and the slope.
We focus on the right side of the sell-side trapezoidal depth, and its most prominent characteristic is that the more Base Tokens are bought, the higher the price becomes. Therefore, this linear depth can be represented as:
However, is linear really the best way to describe liquidity? Not necessarily. Linear description has two limitations:
In a real market, most liquidity concentrates near the mid-price, which the linear description does not reflect.
Even when the price deviates significantly from the mid-price, there should still be liquidity, but the linear description imposes upper and lower limits on the price.
To address these issues, we introduce non-linearity to the price curve. Without expanding the parameters, this makes the depth distribution more consistent with market dynamics and enhances flexibility.
The simplest non-linear solution is to use multiplication instead of addition:
In the above equation, k has a range of [0,1], determining the slope of the price:
When k=0, the price remains unchanged.
When k=1, the price slope degenerates to the previous version's formula.
As k increases, the price becomes more sensitive to changes. As k decreases, the price becomes less sensitive.
However, there is a small issue. In this case, P is the marginal price, and the integral of the marginal price is the quantity of assets a user needs to pay. The B0/B term introduces a logarithmic function after integration, which complicates subsequent calculations. To avoid this complexity, we further refine the formula:
By adding a square term outside of B0/B, the integration becomes a simple division.
Amazingly, when k=1, this curve is precisely the bonding curve defined by AMM. This coincidence gives us more reason to believe that this is an algorithm that touches the essence of the market.
Likewise, for the left side of the depth chart, we use a symmetric approach, replacing Base Tokens with quote tokens and multiplication with division:
By combining the depth charts from both sides, we obtain the complete version of the PMM algorithm, summarized as follows:
The PMM price curve is plotted by the following pricing formula:
The PMM algorithm is a highly compressed version of the Orderbook market, with simple parameters yet extreme flexibility. This empowers us with the ability to operate within the confines of a limited space as if we were tackling Mount Everest.
Where i is the first parameter, the "mid-price," and k is the second parameter, the "slope". represents the current Base Token inventory, while represents the initial Base Token inventory, and is used to represent the percentage of Base Tokens consumed. This formula allows the price to linearly increase as Base Tokens are sold.
This formula ensures that as decreases, P continues to increase until it approaches infinity. But how do we incorporate the influence of the slope? This requires some modification of the term. While keeping the numerical value of greater than or equal to 1, we scale it with a parameter to control the extent to which it is "greater than 1".
Where is defined to be the piecewise function below:
if
if
else