AMMs: Automated Market Makers (for Beginners)

DeFi’s inventive new way to trade against liquidity pools

A UniSwap Liquidity Pool containing WBTC/ETH

What is liquidity? Liquidity is the ability to trade an asset quickly for fiat currency without affecting its price.

The last part in italics is important and largely under-emphasized. If you have 1,000,000 tokens, shares of a stock, or barrels of oil that are valued at X price, then your value is 1,000,000*X, right?

Not necessarily. In the case of the oil hypothetical situation, you and I would probably have a tough time finding enough buyers to sell 1 million barrels of oil in the short term. Probably long term too for that matter.

The same goes for stocks. When a person owns a large chunk of stocks in the market, selling them all at once is pretty difficult because there aren’t enough buyers demanding 28% of the market’s supply of that stock in a given instance in time. If there was enough demand, the buyer certainly wouldn’t want to sell anyway.

Traditional Order Book

Trading requires that there are a high volume of traders to provide the liquidity for transactions. The conventional trading system using Limit Order Books that match market makers with market takers requires that there are a high number of traders in the market for efficient trading.

Market makers place a limit buy or sell order in the book, and when a taker matches the other side of the trade with USD, the transaction is executed. But imagine a scenario in which you are trying to sell a token at market price, but market takers are scarce, and the ones who are trading only want a small portion of what you are offering?

In this case, price bounces up and down rapidly to meet the order limits. The seller is able to unload a small portion of the token to one buyer, and the price drops consequentially. The value of the remaining tokens in the seller’s portfolio has just depreciated at the snap of a finger.

Order book matching requires a lot of participants in the market to efficiently generate the liquidity necessary for stable price action.

In response to the issue of liquidity scarcity in DeFi’s 24/7 trading model, Vitalik Buterin created the concept of AMMs — trading against a liquidity pool consisting of two assets rather than trading in a matching system.

The idea revolves around a constant formula:

Constant Formula: Token_Price(A)*Token_Price(B) = k

K is a constant, meaning that the overall value of the liquidity pool doesn’t change when trading occurs, but the value of the two assets changes in response to the increase/decrease in the supply of each that results from the trade.

If I trade against a liquidity pool that consists of ETH and BTC in a 50/50 supply ratio, I am either trading BTC for ETH or vice versa. There are more complex pools comprised of different token variations, but this example should illustrate the concept. If I trade 2 ETH for BTC, the supply of ETH decreases and BTC increases, at which point an algorithm calculates the new prices of the assets.

But wouldn’t this make the markets for ETH and BTC in liquidity pools different from those same token markets on other exchanges? Yes and no.

Liquidity pools attract Liquidity Providers (LPs) by setting interest rates that reflect the supply and demand of the tokens in the pools, therefore, offsetting the disparity between two tokens. This generally allows the market price of each token to stay relatively tethered to the market averages.

Slippage is a term used to refer to inefficiencies in liquidity that skew prices due to large trades that imbalance the ratio of the two tokens in the pool. DeFi exchanges like UniSwap have protocols that the user can place to limit the amount of slippage in a trade, so that if the target price changes significantly, the trade will expire after a certain amount of time. Trades can also be cancelled in the same way that a trader can cancel a limit order in the matching system.

DeFi has made some incredible strides as of late, offering more and more advanced products to users that are attracting LPs away from traditional passive income options, like savings accounts with central banks.

I’ll be writing about DeFi in more depth in the near future, so follow me if you’re interested in learning more about alternative trading and lending options to traditional finance.

I blog about: technology, philosophy, logistics & supply chain, crypto, blockchain, social science and anything else I find interesting.