The mathematical principle of PMM
The price curve described by the PMM is defined as follows
The most important thing for a trader is the average transaction price. The average transaction price is the integral of the marginal price
. So the average price can be found by knowing the shift of the horizontal coordinate and the corresponding integral of the curve. The next example is the case of
This case corresponds to the case where the user is given a Base Token to sell and the average price is found
The above equation can be modified slightly to obtain the average transaction price as follows
This case corresponds to the case where the user is given a Quote Token to pay and the average price is found
is known ， we can transform the above equation into a standard quadratic equation by solving.
, we round off the sign (there is a strict derivation here), yielding
Meanwhile DODO V2, on the above equation calculation, focuses on verifying the special cases of ,
, to support the constant price curve as well as the bonding curve of the standard AMM.
The constant reference
are the current inventory, i.e., the dependent variable. In order to determine this price curve, we also need to know these four parameters
However, these four parameters are not independent of each other, and given any three of them, the fourth one can be calculated.
The process of calculating the fourth parameter is called "parametrization" and is done whenever the parameter changes. "DODO chooses the "long return rule", which is a rule that aims at eliminating all longs.
When the inventory is shifted, one of the two assets of the pair must be more than the equilibrium value and the other less than the equilibrium value. This corresponds to the pool holding a long position in one asset and a short position in the other asset.
The "long reversion" priority is to return the long-side assets to their equilibrium values. Once the long-side asset returns, the asset value is deemed to be the new equilibrium value, regardless of the short-side asset. That is, the short side takes a profit or loss.
Suppose the current state is
is a long side and
a short side. We do not move
and use the value before the fixed parameter directly. That is, we know the parameters
, and need to solve for the last parameter
By definition, when the inventory returns, the new inventory is
and we use directly as the new equilibrium value, i.e.
. Then it is possible to organize the formula into the standard form of the quadratic equation.
Eliminating the negative roots yields the reset of
Similarly, if the long positions are accumulated in
, then we need to solve for
When the system parameters are constant, the price curve is also constant. Even if the inventory changes, it does not matter, just wait for the market environment and the system parameters to match again, the inventory can return to equilibrium. In other words, the gain/loss due to inventory changes is just a "floating gain/loss", and the term "impermanent loss" has been coined to describe this phenomenon.
The same is true for the PMM algorithm, which is similar to the AMM algorithm if the parameters remain unchanged and there is no fixed parameter process. However, in practice, one often needs to make adjustments to the price curve. Under the "long return to parametric" rule, the equilibrium value on the short side is reset. The reset equilibrium value may be larger, which is equivalent to a profit accrual. It may also become smaller, which is equivalent to a loss accrual. Each accrual is converting an unrealized floating profit/loss into a real profit/loss.
Each time you set a participation, it is a single accrual, the purpose of which is to eliminate additional positions in time to avoid excessive losses. As for when and how to adjust the curve, it is a matter of opinion, and we hope that developers and traders can make the most of this framework.