A Brief Study of CFMM (Constant Function Market Makers)

How does it work?

It is best explained here [PDF], There are mainly two roles in the market:

  1. Liquidity Providers (LP): They deposit a pair of coins into the pool, and willing to let others interact with the pool for a fee.
  2. Traders/Arbitrageurs: They swap coins directly on the exchange rather than interacting with a counterparty. With the coins they got, they may sell on other exchanges to make profits.

First Step

Quite simple, let’s say Alice wants to establish a pool and to be the first liquid provider. She holds a combination of 1ETH + 100 USD. Now she deposits it into the pool to start her journey as the market maker.

Z = X * Y

Scenario #1: ETH price increases

A trader finds out the price of ETH/USD in the pool is cheaper than outside exchanges, and buys some cheap ETH from the pool, here are his steps:

Trader buys from the pool of ETH
  1. Total 0.4 ETH is bought from the pool, 66.67 USD is paid. (166.67 USD per ETH)
  2. The last 0.1 ETH actually costs 238.2 USD.
  3. The next buyer of ETH will pay even higher (> 238.2 USD per ETH)
  1. If he manages to sell the 0.4 ETH he bought at the price of 238.2 USD (on other exchanges for example, Binance), he makes a profit of: 0.4 * 238.2–66.67 = 28.61 USD.
  1. Holds 0.6 ETH + 166.67 USD = 0.6 * 238.2 + 166.67 = 309.59 USD
  2. The above is paper wealth, he may not cash out as high as 238.2 USD/ETH
  3. If he doesn’t provide liquidity, instead holds his “1ETH+100USD” combination, he achieves a sum of 1 ETH+100 USD = 238.2 + 100 = 338.2 USD

Scenario #2: ETH price decreases

The ETH price decreases. The trader sell his ETH to the pool to make a profit, here is how he does it:

The trader sells ETH to the pool
  1. Total 0.4 ETH is sold for 28.58 USD. ( 71.45 USD per ETH )
  2. The last 0.1 ETH sold at price 55 USD.
  3. The next seller will get a much lower bid than 55 USD.
  1. If he manages to buy some ETH back on other exchanges with the 28.58 USD he gained, at the low price of 55 USD/ETH, then he can buy back 0.4 ETH (costs 22USD), and make a profit of 6.58 USD.
  1. Currently holds 1.4 ETH + 71.42 USD = 1.4 * 55 + 71.42 = 148.42 USD
  2. If he doesn’t provide liquidity, instead holds his “1ETH+100USD” combination, he achieves a sum of 1 ETH+100 USD = 55 + 100 = 155 USD
  3. The difference of 155–148.42 = 6.58 USD = the profit the trader makes.

Conclusion

With the price of ETH moves either direction, the liquid provider always suffers a sense of “loss” than the most simple strategy: “HODL”. And it is clear that the difference goes into the pocket of the trader as profit.

  1. If the market is stable, or can come back to the original price, AMM is working.
  2. If the pool is big enough, one cannot easily move the price on the pool.
  1. Impose a transaction fee: take 0.3% of fee, and award it to the liquid provider. The more the traders trade, the more fees are collected.
  2. Have an incentive token alongside: fees can be in the form of a new incentive token. And the token sale can compensate the liquid providers.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store