An automated market maker (AMM) is a decentralized exchange (DEX) protocol that uses a mathematical formula to calculate the price of a given Asset/Asset-Pair, instead of a traditional order book like most exchanges use. Traditional market makers usually use vast resources provided by traders on their platform to guarantee a good price and to keep the bid-ask spread minimal. AMM are the decentralized variant of this. With AMM's everybody can set up a market for a given Asset-Pair without needing those vast resources big exchanges like Binance or others use.
There are a lot of different protocols like Uniswap, Curve, Kyber Network, or Pancakeswap for example; however they all share the same method on how they calculate those prices: algorithmically.
The formula can vary by each protocol. Uniswap for example uses the simple x*y=k.
- x= amount of tokens in the first liquidity pool
- y= amount of tokens in the second liquidity pool
- k= fixed constant (which makes the total liquidity of both pools always stay the same)
The formula other protocols will use can wildly differ in complexity and goals depending on the specific use cases they target.
How does it work?
Basically an AMM is like a traditional order book which uses trading pairs like BTC/USDC. The difference from a traditional order books is that you don't need another trader to make the trade happen. You completely rely on the protocol (smart contract) and its limitations to make the market price for you. So instead of a P2P (Person 2 Person) you make essentially a P2C (Peer-to-Contract) trade.
So who exactly provides the counterpart? In our case the USDC if you want to trade Bitcoin? That's where liquidity providers come into play:
Liquidity providers add funds to liquidity pools. In case of Uniswap the liquidity providers in our example provide an equivalent value of two tokens (50% of BTC and 50% of USDC) into the Liquidity Pool (BTC/USDC) at the current market value.