Automated market makers (AMMs) are decentralized exchanges (DEXs) that do not follow a particular order book but use an algorithm to price a trading pair.

A prime example of an AMM is Uniswap (UNI), which has seen a huge surge in the number of users and trading volume following the crypto and DeFi sector boom of 2021.

As mentioned previously, AMMs make use of a mathematical formula to price assets, unlike traditional crypto exchanges that use order books. In the case of Uniswap, the algorithm used is x * y = k, where x is the amount of token A in the liquidity pool, while y is the amount of token B in the same. The variable k is constant since the total volume of the liquidity pool has to remain constant.

Other AMMs use more complex algorithms depending on the use case the entire platform is built with.

To understand it better, take the example of ETH/USDT. AMMs also make use of trading pairs like traditional exchanges, and the person using the platform does not require the presence of a counterparty (another trader) on the other side to make a trade. This is because AMMs follow the peer-to-contract (P2C) protocol, which works quite differently than the popular peer-to-peer model (P2P).

Therefore, users of AMMs initiate their orders with a contract that "makes" the markets for them. Meanwhile, in P2P, users initiate an order that is then fulfilled by another user.

P2C happens between users and contracts. As a result, there is no need for an order book, and there are also no order types in an AMM. It is a complex mathematical algorithm that decides how and when you get to buy or sell a cryptocurrency.

Now, AMMs are not fully independent of users. They still require people to create liquidity that remains constant. This is done by liquidity providers or LPs. To put it straight, LPs are responsible for adding funds to the AMM so that the overall liquidity does not change. This ensures that there is a shortage of liquidity in the protocol.

LPs are incentivized via rewards. Therefore, if a user provides his tokens for liquidity purposes in an AMM, say, Uniswap, they will get a return percentage as yield, and this yield can be withdrawn. So, taking the example of the above trading pair, ETH/USDT on Uniswap, LPs deposit an equivalent value of two tokens — 50% ETH and 50% USDT in this case — in the pool.

Now any layman could point out the fact that an attack could just drain the liquidity of the AMM of one of the tokens in a trading pair and wreak havoc among the users. However, this is not possible because, in the case of Uniswap, the equation x * y = k only works until either of them is not zero. If any of the variables tends to zero, the algorithm won't make sense anymore.

The usage of AMMs by LPs to gain rewards is quite limited to stablecoins or wrapped tokens. This is because pairs like ETH/USDT are subject to impermanent loss or the money a crypto investor loses when they lock their tokens at a different value and withdraw them at a lower price.

The crypto market is extremely volatile, and losses are very much common. If a user locks their tokens in the Uniswap LP for the pair ETH/USDT and the price of ETH crashes 10%, they will get a reward. But it won't be enough to cover the impermanent loss, and as a result, some might think they are better off holding the tokens.

Therefore, LPs are more in number for stablecoins and wrapped tokens since the price ratio between the pair remains in a relatively small range, making the impermanent loss negligible.

However, calling this loss impermanent is not very correct since if the tokens are withdrawn and then swapped for some other token, the loss becomes permanent.

Illustration shows representations of cryptocurrency Bitcoin