*Shortlink: **bit.ly/maniswap*

Maniswap is Manifold Market’s automated market maker (AMM) for binary prediction markets.

Maniswap is based on a modified version of Uniswap, designed to allow the more efficient deployment of liquidity. The original idea for Maniswap was suggested by Pepe, a user of Manifold Markets.

## Uniswap for prediction markets

You can think of a prediction market as a place to trade shares in an event, which will pay out if an event does or does not happen.

Imagine a prediction market created for the question: “Will it rain in Manhattan on May 10th, 2025?” A YES share of this market will pay out $1 if rains in Manhattan on the specified date; a NO share will pay out $1 if it does not. Shares that do not pay out on the specified date immediately become worthless.

The price of a YES share thus corresponds to the market’s estimate of the event’s probability. If a YES share for this market is trading at $0.35, the market believes there is a 35% chance the event will occur.

An AMM can be used to facilitate trades between different parties for this market. Conceptually, a trade placed using an AMM works like this:

- A trader believes the true probability of an event is higher than the chance implied by the current price of YES shares, so they place an order to buy $10 worth of YES shares.
- The AMM receives the order, and converts the $10 into 10 YES shares and 10 NO shares. (Since 1 YES share + 1 NO share always equals $1, the AMM can always issue shares in equal amounts for cash they receive.)
- The AMM adds the new shares to their pre-existing liquidity pools of YES and NO shares.
- The AMM uses a formula based on the number of shares in the liquidity pool to figure out how many YES shares to give back to the trader in return for his $10 wager.
- The trader now has some number of YES shares which will pay out if the event happens.

One of the simplest ways an AMM can process these transactions is to use a Uniswap-style constant-product formula.

Suppose that there are *y *YES shares and *n *NO shares in the AMM’s liquidity pool. The AMM will adjust shares in the pool such that their product is held constant (*k):*

For example, if the AMM initializes the pool with 3 YES shares, and 2 NO shares, the initial constant will be 6. If someone wants to buy $1 of YES, the AMM will update the pool to 4 YES, 3 NO. Since the product of 4*3 is not 6, the AMM will figure out how many YES shares to remove to restore the condition, (4-x)(3) = 6. In this case, x=2, which means the trader will get 2 YES shares back for their $1, and the AMM’s resulting liquidity pool will be 2 YES, 3 NO.

Notice that when a trader buys YES, the number of YES shares in the liquidity pool decreases. In other words, the higher the probability, the lower the number of YES shares.

In a Uniswap-style market-marker, the market probability (i.e. the probability implied by the current prices of shares) is given as:

## The problem: leftover shares

Suppose you have $100 and are trying to initialize an AMM’s liquidity pool to be at an implied 33% probability using Uniswap.

If you only have $100, then that means that you can put up at most 100 YES shares and 100 NO shares. To get the right probability with this constraint, you must create the liquidity pool with 100 YES shares and 50 NO shares (since 50/(100+50) = 1/3).

But notice that if you started with $100, you still have 50 NO shares left over. This is unfortunate. Ideally, you would prefer to deploy all of your capital to subsidizing the market, not just when the initial probability is 50% (which is the only case when you can deploy 100 YES, 100 NO).

## The solution: Maniswap

The solution is to modify the Uniswap constraint to make it parametrized in terms of the initial probability.

Suppose you want to want to initialize the probability at *p.* Instead of the simple constant-product formula, use

With the corresponding market probability of

This will allow you to allocate all 100 YES and 100 NO shares of your original $100 subsidy at any probability you choose!

More importantly, the farther the initial probability is in the extremes (0.1% or 99.9%), the better the liquidity and the lower the price-jumpiness you will observe versus Uniswap.

This system—known as as Maniswap—can be thought of as a generalization of Uniswap. Notice that when p = 50%, the systems are the same:

As constant-function market makers, both Uniswap and Maniswap can also be understood in geometric terms, as an AMM moving up or down a hyperbola or hyperbola-like pricing curve. The parameter *p *changes the curvature to concentrate liquidity where it’s needed:

### Liquidity provision

Market participants often want to provide liquidity in order to subsidize prediction markets they are interested in, or to earn fees.

One of the big benefits of Maniswap is that it makes it easy for traders to inject liquidity efficiently without generating any leftover shares.

Suppose a trader wishes to inject $100 into the liquidity pool of a market trading at an implied probability of P. The AMM takes the trader’s $100, turns it into 100 YES and 100 NO shares, and adds those shares to the pool. In order to preserve the current probability, we must solve for a new constant value p, while holding the probability P constant:

The more capital we inject at probability P, the closer the parameter p will converge toward it.

If a trader wishes to withdraw their capital from the pool, we calculate the share of the YES pool an NO pool they are owed based on how much capital they committed.

One complication is that the parameter *p *may be significantly different from when the liquidity was provided. To find the trader’s current share of the pool (for a certain amount of capital $*l)*, we calculate the change in liquidity using the shares in the pool at the time of liquidity provision along with the current value of *p:*

The trader then receives YES shares and NO shares, which are withdrawn from the pool.

### Fees

One way to incentivize liquidity provision is to charge fees on each trade and inject the fee amount directly into the liquidity pool.

Manifold’s fee schedule is currently: 13% * (1 - post-bet probability) * trade amount. Of that 13%, 6% goes to the liquidity pool, 6% goes to the creator, and 1% to the Manifold platform.

This fee is then converted into equal number of YES and NO shares and added to the liquidity pool after changing the parameter *p, *using the procedure described above.

Liquidity providers are then eligible to earn these fees after redeeming their shares in the pool.

# Further reading

Constant Function Market Makers: DeFi’s “Zero to One” Innovation (Berenzon 2020)

Constant Function Market Makers: Multi-Asset Trades via Convex Optimization (Angeris, et al. 2021)