📗 PMM Algorithm

Introduction #

DODO uses the Proactive Market Maker (PMM) algorithm to provide liquidity for its various services.

The PMM is an inventory management strategy. When the quantity of an asset decreases, the PMM algorithm automatically increases the price quoted for this asset in anticipation of buying back the missing inventory from the market.

A Simple Example #

Let's use a simple example to illustrate how PMM works. The following example numbers are not exact, but are mentioned just to help you understand how the algorithm works.

Peter's boss gives him $100 and 10 apples. There are people in the market who buy and sell apples, and Peter has to satisfy these people's buying and selling needs with the inventory he has on hand. In more technical terms, this is called "providing liquidity to the apple market".

The boss tells Peter that the apples are about $10 each and then goes home to rest, leaving Peter to wait for customers. Someone buys an apple from Peter, and Peter decides to increase the price a little bit and sells it to him for $12. The $2 is the so-called "slippage". At this point, Peter's inventory is $112 and 9 apples. That is an increase of $12 and a decrease of 1 apple.

Peter automatically places an order to buy one apple at $11 (slightly above market price), expecting to buy back an apple as soon as possible to make up the shortfall. Soon Peter buys back the apple for $11, leaving Peter with $101 and 10 apples in stock, a net increase of $1 and 0 apples. Although it cost $1 more, the extra $2 received through the slippage was enough to make up for it, and Peter helped his boss make a net profit of $1.

The PMM algorithm acts like Peter did in the above scenario, and you are Peter's boss. What Peter does (in a nutshell) is provide liquidity while maintaining a healthy inventory by actively adjusting prices.

Price Curve #

To better explain how the PMM manages inventory, we need to introduce the Price Curve Simulator. This tool allows you to see exactly how the price of an asset changes when its inventory changes.

This depth chart consists of two roughly triangular (though not necessarily symmetrical) shapes, representing bids (buy orders) on the left and asks (sell orders) on the right, along the price x-axis and the depth y-axis. The two triangles can be mathematically described by two parameters, mid price and slope, or how “steep” the triangle is.

If you adjust the parameter kk, you will find that: the larger the value of kk, the steeper the curve, the more sensitive the price is to the quantity of inventory, and the larger the trading slippage. The smaller the value of kk is, the smoother the curve, and the less sensitive the price is to the quantity in stock, which makes for less slippage as well.

This parameterkk, which we call the slippage factor, is the key to the PMM algorithm and allows market makers to concentrate liquidity around a certain price. The smaller it is, the more liquidity is concentrated and the better the price at which traders can trade.

Using Smart Contracts to Provide Liquidity #

DODO has implemented the EVM smart contract version of the PMM algorithm, in which the concept of orders does not exist. Instead, it is replaced by the supply and consumption of liquidity.