Maniswap V3 is an AMM for prediction markets that modifies

to use**Uniswap V3**βs concentrated liquidity.

## The basic idea

Liquidity providers (LPs) can provide capital within a specified probability range on a prediction market and earn fees on trades conducted in that range.

By concentrating capital within a range, LPs can avoid situations where informed actors or news releases cause the probability to suddenly converge to 0 or 1. This allows them to more efficiently provide capital, meaning more liquid markets in general.

Maniswap V3 uses the same trick as

of parameterizing the pricing curve in terms of the current probability to allow the more efficient deployment of capital.## How it works

- The probability range (0%, 100%) is divided into a number of discrete ticks or buckets.
- Every whole percentage increment from 1 to 99 is a bucket
- [1%, 2%), [2%, 3%), β¦ [98%, 99%)
- The tails are divided into 10 buckets each:
- (0%, 0.1%), [0.1%, 0.2%), β¦ [0.9, 1%)
- [99%, 99.1%), β¦ [99.9%, 100%)
- LPs can place a range order of a certain capital amount over a given probability range, e.g. $100 on [30%, 33%), to provide liquidity to the market.
- Every time a range order of $r is created, a new liquidity pool of (b YES, b NO) shares is allocated
- LPs can withdraw their order at any time to receive (y YES, n NO) shares
- Market orders use the aggregate of all the liquidity provided by range orders containing the current market probability.
- Trade execution within a bucket:
- Suppose the current market probability is p.
- A market order to buy YES shares comes in.
- Deduct $f in fees from the gross amount (using whichever fee scheme you prefer), and call the remainder $b.
- Find all the range orders whose range contains p.
- Next, we calculate the liquidity l of each range orderβs liquidity pool P
- If $P_i = (y_i, n_i)$, then the liquidity is equal to $l_i = min(y_i, n_i)$
- Find the total liquidity L, which is just the total quantity of dollars in this bucket:
- Now, we use the Maniswap pricing function with the parameter p set to the current market probability to find y, the number of YES shares to return for the order:
- The new market probability is
- We then update each orderβs liquidity pool by linearly interpolating the change in YES and NO shares and adding in the fees $f:
- A large market order that moves the probability by several percentage points will need to be broken up into smaller orders and processed bucket by bucket.

$L = \Sigma l_i$

$(b - y + L)^p (b + L)^{1-p} = L$

$p_{new} = \frac {p(b +L)} {(1-p)(b - y + L) + p(b +L)}$

$P_i^{new} = (l_i\frac{b- y +L +f}{L} + y_i - l_i,\space l_i\frac{b +L +f}{L} + n_i - l_i)$