Automated Market Maker and Liquidity Pool

rdiv.finance
4 min readJan 26, 2021

What Is an Automated Market Maker (AMM)?

An automated market maker (AMM) is a type of decentralized exchange (DEX) protocol which is based on a mathematical formula to price assets. Instead of using an order book like a traditional exchange, assets are priced in accordance with a pricing algorithm.

This formula can vary with each protocol. In this formula, k is a fixed constant, meaning that the pool’s total liquidity constantly must stay the same. Other AMMs will use other formulas for the particular use cases they target. The difference between all of them, however, is that they determine the prices algorithmically. If this is a bit confusing right now, don’t worry; hopefully, it will all come together in the end.

How does an automated market maker (AMM) work?

An AMM works similarly to an order book market because there are trading pairs — for example, ETH/DAI. However, you do not have to get a counterparty (another trader) on the other hand to create a trade. Instead, you interact with a smart contract which”makes” the marketplace for you.

On a decentralized market like Binance DEX, trades occur directly between user wallets. If you sell BNB for BUSD on Binance DEX, there’s somebody else on the other side of the trade purchasing BNB with their BUSD. We can call this a peer-to-peer (P2P) transaction.

By comparison, you could think of AMMs as peer-to-contract (P2C). There’s no need for counterparties in the traditional sense, as trades happen between users and contracts. Since there’s no order book, there are also no order types on an AMM. What price you get for an asset you want to purchase or sell is determined by a formula instead. Even though it’s worth noting that some future AMM designs may counteract this restriction.

So there’s no need for counterparties, but someone still needs to create the market, right? Correct. The liquidity in the intelligent contract still must be given by users called liquidity providers (LPs).

What is a liquidity pool?

Liquidity providers (LPs) add funds to liquidity pools. You could think of a liquidity pool as a big pile of funds which traders can trade against. In return for supplying liquidity to the protocol, LPs earn commissions from the trades that occur in their pool. In the case of Uniswap, LPs deposit an equivalent value of two tokens — for example, 50 percent ETH and 50 percent DAI into the ETH/DAI pool.

Hang on, so anyone can become a market maker? Indeed! It’s quite easy to add funds to a liquidity pool. The rewards are dependent on the protocol. By way of example, Uniswap v2 charges traders 0.3% which goes straight to LPs. Other platforms or forks may charge less to attract more liquidity providers to their pool.

Why is bringing liquidity important? Because of the way AMMs work, the more money there is at the pool, the less slippage large orders may incur. That, in turn, may draw more volume to the platform, etc.

The slippage problems will vary with different AMM layouts, but it is definitely something to keep in mind. Remember, pricing is determined by an algorithm. In a simplified way, it’s determined by how much the ratio between the tokens in the liquidity pool changes after a trade. If the ratio varies by a wide margin, there is going to be a large amount of slippage.

Well, you could not! You would have to pay an exponentially greater and higher premium for each additional ether, but still never could buy it all from the pool. Why? It’s because of the formulation x * y = k. If either x or yis zero, meaning there is zero ETH or DAI in the pool, the equation doesn’t make sense anymore.

What is impermanent reduction?

Impermanent loss happens when the cost ratio of deposited tokens changes after you deposited them at the pool. The bigger the change is, the larger the impermanent loss. This is why AMMs work best with nominal pairs that have a similar value, such as stablecoins or wrapped tokens. If the cost ratio between the pair remains in a relatively small selection, impermanent reduction is also negligible.

On the other hand, if the ratio changes a lot, liquidity providers might be better off simply holding the tokens rather than adding funds to a pool. Nevertheless, Uniswap pools such as ETH/DAI which are very exposed to impermanent loss have been profitable due to the trading fees that they accrue.

That said, impermanent loss isn’t a excellent way to name this phenomenon. “Impermanence” supposes that when the assets revert to the costs in which they were originally deposited, the losses are mitigated. However, if you withdraw your funds in a different price ratio than when you deposited them, the losses are very much permanent. In some cases, the trading fees might mitigate the losses, but it is still important to take into account the risks.

Be cautious when depositing funds into an AMM, and ensure you recognize the consequences of impermanent loss.

Closing thoughts

Automated market manufacturers are a staple of the DeFi space. They enable essentially anyone to create markets seamlessly and economically. While they do have their limitations in contrast to purchase book exchanges, the overall innovation they bring to crypto is invaluable.

The AMMs we all know and use today like Uniswap, Curve, and PancakeSwap are elegant in design, but quite limited in features. There are likely many more advanced AMM designs coming in the future. This should result in lower prices, less friction, and better liquidity for every DeFi user.

--

--

rdiv.finance

Simple, Fast and Safe Deflationary Yield Generation #DeFi #YieldFarming #LiquidityMining #Deflationary