A Brief Study of CFMM (Constant Function Market Makers)

How does it work?

  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

Z = X * Y

Scenario #1: ETH price increases

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 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

  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.

--

--

--

Passion in computer science.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

The Reentrancy Strikes Again — The Case of Lendf.Me

7 Top NFT Certifications for Professionals in 2022

7 Top NFT Certifications for Professionals in 2022

Blockchain Week in Review: Week of January 10, 2020

The Long term Vision for The Acumen protocol!

Profede - A Decentralized Marketplace Solution for Working Professionals

ETH Price Prediction for 2022

Honey w/ Your Tea — Issue #3

On the Rocks with Daniel Chong, Co-Founder of Harpie: Meet the Man Who’s Protecting your Crypto

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
A Byte Ahead

A Byte Ahead

Passion in computer science.

More from Medium

Hotpot V3 49th Weekly Report

Deploy: Solana validator or RPC on StackPath

Applications of Staking Options in Decentralized Finance

7 “Captain Hindsight” DeFi Lessons