Polkamarkets uses an Automated Market Marker (AMM) algorithm similar to that used by Uniswap and other DEXes. It is based on the Constant Product Market Maker (CPMM), which was originally created by Uniswap, and later adapted as Fixed Product Market Maker (FPMM) by Gnosis for usage in prediction markets.
The all-important constant function in Polkamarkets AMM makes it so that the number of shares a market’s liquidity pool always forces a balance in the number of shares of each outcome in the market — when an imbalance is introduced (by adding or removing shares to any pool), outcome prices change and shares are redistributed between the trader or liquidity provider, and the share pools.
These functions are responsible for the most important aspects of the markets: liquidity and price setting.
Pool Share Calculation Function
The number of shares in each pool is determined using this all-important constant function:
So, for example, in a market with two outcomes, the function would be:
Whereas in a market with five outcomes, we’d get:
Outcome Price Calculation Function
Price calculation in a binary outcome market
In a binary outcome market (a market with only two outcomes), the formula used to determine outcome prices is the following:
Price calculation in a multiple outcome market
In a market with multiple outcomes, the formula becomes a bit more complex. Before we can calculate the outcome prices, we must first calculate their relative weight.
To be clear, this same formula works for outcome price calculation in a binary outcome market as well, but is not necessary.
To calculate the Price Weight for a given outcome, we multiply the number of shares available in the pool of every other outcome.
Once we have the Price Weight of every Outcome, we can determine the price on an outcome.