AMM: Automated Market Maker for decentralized trading

Key Points

  • AMM = Automated Market Maker = DEX protocol to buy or sell assets without 3rd party broker by automating pricing, order placement and settlement 


References


Key Concepts



Liquidity Pools Overview

https://www.yieldmonitor.io/what-is-a-liquidity-pool/?gclid=CjwKCAiAk--dBhABEiwAchIwkQ7mxFwrHLroYZ89-sGRoyAmvk3seG2n3F-my6NTGPuOR0LUymggChoC89QQAvD_BwE

Liquidity Pools are crowd-sourced collections of digital assets locked in a smart contract. They support DEXs by providing liquidity for traders to swap between currencies.

Users who supply assets to a Liquidity Pool are financially rewarded for providing liquidity

Essentially, liquidity pools are a collection (pool) of tokenized assets through which traders and investors can buy and sell those specific assets (liquidity). The funds are locked within a smart contract and an algorithm manages the automated transactions (Automated Market Maker (AMM)) of assets for buyers and sellers within that specific liquidity pool.


AMM - Automated Market Maker Model


This style of order processing is not a viable solution for blockchains, primarily due to:

  • transaction speed (far too many orders to place, process, or cancel)
  • gas fees would be cost prohibitive for market makers to justify participating
  • relying on a sole market maker is not particularly decentralized

To solve this problem, and keep the nature of these financial transaction processes more decentralized, the Liquidity Pool and, subsequently, the Automated Market Maker (AMM) was created. AMMs are DEX protocols that rely on algorithms to price assets and facilitate trades. They leverage funds from the Liquidity Pools to do so.

Think of traditional order books as a type of centralized or peer-to-peer (P2P) tool, and an automated market maker as a decentralized tool or “peer-to-contract” (P2C) model. Through an AMM, a user (buyer or seller) makes a trade directly with the protocol via the Liquidity Pool.



AMM notes

https://finance.yahoo.com/news/regulators-bringing-multichain-era-close-212022558.html

Liquidity becomes an issue as well. Polling Automated Market Makers (AMM) for their sample prices by volumes of proposed swaps on different token pairs shows how quickly liquidity drops off once you leave the Ethereum blockchain. Even within public Ethereum, trading is highly concentrated among the top tokens. Tokens without liquidity are much more vulnerable to price manipulation.

Insufficient liquidity in an inadequately regulated market is one of the main reasons the Securities and Exchange Commission has rejected applications for bitcoin (BTC) exchange-traded funds (ETF). The last year has shown, time and again, that crypto asset prices are often manipulated. So these concerns are unlikely to go away and will increasingly deter firms for interacting with, or transacting upon, less-liquid ecosystems.


What is AMM? Coindesk

https://www.coindesk.com/learn/what-is-an-automated-market-maker/


Centralized Market Maker Model

A market maker facilitates the process required to provide liquidity for trading pairs on centralized exchanges. A centralized exchange oversees the operations of traders and provides an automated system that ensures trading orders are matched accordingly. In other words, when Trader A decides to buy 1 BTC at $34,000, the exchange ensures that it finds a Trader B that is willing to sell 1 BTC at Trader A’s preferred exchange rate. As such, the centralized exchange is more or less the middleman between Trader A and Trader B. Its job is to make the process as seamless as possible and match users’ buy and sell orders in record time.

Liquidity, in terms of trading, refers to how easily an asset can be bought and sold. High liquidity suggests the market is active and there are lots of traders buying and selling a particular asset. Conversely, low liquidity means there is less activity and it is harder to buy and sell an asset.

exchanges must ensure that transactions are executed instantaneously to reduce price slippages.

DEX trading market maker model

DEXs promote autonomy such that users can initiate trades directly from non-custodial wallets (wallets where the individual controls the private key.)

DEXs replace order matching systems and order books with autonomous protocols called AMMs. These protocols use smart contracts – self-executing computer programs – to define the price of digital assets and provide liquidity. Here, the protocol pools liquidity into smart contracts. In essence, users are not technically trading against counterparties – instead, they are trading against the liquidity locked inside smart contracts. These smart contracts are often called liquidity pools.

Examples of AMMs include Uniswap, Balancer and Curve.

For AMMs:

  • Trading pairs you would normally find on a centralized exchange exist as individual “liquidity pools” in AMMs. For example, if you wanted to trade ether for tether, you would need to find an ETH/USDT liquidity pool.
  • Instead of using dedicated market makers, anyone can provide liquidity to these pools by depositing both assets represented in the pool. For example, if you wanted to become a liquidity provider for an ETH/USDT pool, you’d need to deposit a certain predetermined ratio of ETH and USDT.

the value of trading pairs is maintained at a constant level:    ( A.price ) * ( B.price  ) = K

The algorithm adjusts the prices to match K

example

To understand how this works, let us use an ETH/USDT liquidity pool as a case study. When ETH is purchased by traders, they add USDT to the pool and remove ETH from it. This causes the amount of ETH in the pool to fall, which, in turn, causes the price of ETH to increase in order to fulfill the balancing effect of x*y=k. In contrast, because more USDT has been added to the pool, the price of USDT decreases. When USDT is purchased, the reverse is the case – the price of ETH falls in the pool while the price of USDT rises.

CoinDesk - Unknown


Liquidity pool price may not match real market price

When large orders are placed in AMMs and a sizable amount of a token is removed or added to a pool, it can cause notable discrepancies to appear between the asset’s price in the pool and its market price (the price it’s trading at across multiple exchanges.) For example, the market price of ETH might be $3,000 but in a pool, it might be $2,850 because someone added a lot of ETH to a pool in order to remove another token.

For AMMs, arbitrage traders are financially incentivized to find assets that are trading at discounts in liquidity pools and buy them up until the asset’s price returns in line with its market price.

Liquidity Pool fees on transactions

As an incentive, the protocol rewards liquidity providers (LPs) with a fraction of the fees paid on transactions executed on the pool. In other words, if your deposit represents 1% of the liquidity locked in a pool, you will receive an LP token which represents 1% of the accrued transaction fees of that pool. When a liquidity provider wishes to exit from a pool, they redeem their LP token and receive their share of transaction fees.

Yield farming for staking liquidity pools

deposit the appropriate ratio of digital assets in a liquidity pool on an AMM protocol. Once the deposit has been confirmed, the AMM protocol will send you LP tokens.

impermanent losses in stakes

One of the risks associated with liquidity pools is impermanent loss. This occurs when the price ratio of pooled assets fluctuates.

this loss is impermanent because there is a probability that the price ratio will revert. 


chain link on AMM overview

https://chain.link/education-hub/what-is-an-automated-market-maker-amm#:~:text=Automated%20market%20makers%20(AMMs)%20are%20a%20type%20of%20decentralized%20exchange,trade%20directly%20through%20the%20AMM.


Improving AMM Models With Hybrid, Dynamic, Proactive, and Virtual Solutions

The above limitations are being overcome by innovative projects with new design patterns, such as hybrid automated market makers, dynamic automated market makers, proactive market makers, and virtual automated market makers.

 Curve AMMs—known as the stableswap invariant—combine both a CPMM and CSMM using an advanced formula to create denser pockets of liquidity that bring down price impact within a given range of trades.




Potential Value Opportunities



Potential Challenges



Candidate Solutions



Step-by-step guide for Example



sample code block

sample code block
 



Recommended Next Steps