TL;DR
You can think of an automated market maker as a robot that is always willing to provide a price between two assets. Some use simple formulas like Uniswap. Meanwhile, Curve, Balancer and others use a more complicated formula.
Not only can you perform trustless trading using AMM, but you can also host it by providing liquidity to a liquidity pool. This essentially allows anyone to become a market maker on an exchange and get paid for providing liquidity.
AMM has truly made history in the world of DeFi due to its simple and easy-to-use nature. The decentralized market that makes it possible is the most basic vision of crypto.
Introduction
Decentralized Finance (DeFi) has attracted high interest in Ethereum and other smart contract platforms, such as Binance Smart Chain. Yield farming has become a popular way of distributing tokens, tokenized BTC is growing on Ethereum, and flash loan volumes are skyrocketing.
Meanwhile, automated market maker protocols like Uniswap continue to see competitive volumes, high liquidity, and increasing user numbers.
However, how does this exchange work? Why is market setting for the latest trending coins so quick and easy? Can AMM be completely separated from the traditional order book exchange? Let's find out.
What is an automated market maker (AMM)?
Automated market maker (AMM) is a type of decentralized exchange (DEX) protocol that relies on mathematical formulas to determine asset prices. Rather than using order books as on traditional exchanges, asset prices are determined based on pricing algorithms.
This formula can vary depending on the protocol. For example, Uniswap uses x * y = k. x is the number of one token in the liquidity pool and y is the number of other tokens. In this formula, k is a fixed constant. This means that the total pool liquidity must always be the same. Other AMMs will use other formulas for specific targeted uses. However, what they all have in common is that AMM determines prices using an algorithm. This is quite confusing at the moment, but don't worry. Hopefully everything will make sense by the end of this article.
Traditional market making processes usually work with companies that have large resources and complex strategies. Market makers help you get good prices and tight bid-ask spreads on order book exchanges, like Binance. Automated market makers decentralize this process and allow anyone to create markets on a blockchain. How do they do this? Keep reading.
How does an automated market maker (AMM) work?
AMM works similarly to an exchange order book in that there are trading pairs – for example, ETH/DAI. However, you do not need to have a counterparty (another trader) on the other side to execute a trade. Instead, you interact with a smart contract that “makes” the market for you.
On decentralized exchanges like Binance DEX, trading occurs directly between users' wallets. If you sell BNB for BUSD on Binance DEX, there is someone else on the other side of the trade buying BNB with his BUSD. We can call this a peer-to-peer (P2P) transaction.
In contrast, AMM can be considered peer-to-contract (P2C). There is no need for a counterparty as in the traditional version, as trading occurs between the user and the contract. Since there is no order book, there are also no order types in AMM. The price obtained for an asset you want to buy or sell will be determined by a formula. However, it is worth noting that some future AMM designs may overcome this limitation.
Even though there is no need for counterparties, someone still has to create the market, right? Correct. Liquidity in smart contracts must still be provided by users who are called liquidity providers (LP).
What is a liquidity pool?
The liquidity provider (LP) adds funds to the liquidity pool. You can think of a liquidity pool as a large pile of tradable funds. In return for providing liquidity to the protocol, LPs earn fees from trades that occur in the pool. In Uniswap, LPs deposit the equivalent value of two tokens – for example, 50% ETH and 50% DAI into the ETH/DAI pool.
Wait a minute, so anyone can be a market maker? Correct! It's quite easy to add funds to a liquidity pool. Rewards are determined by protocol. For example, Uniswap v2 charges a 0.3% fee to traders who enter LP directly. Other platforms or forks may charge less to attract more users to their pool.
Why is attracting liquidity important? Based on the way AMMs work, the greater the liquidity in a pool, the less slippage a large order can cause. In return, this can attract more volume on the platform and vice versa.
Slippage issues will vary with different AMM designs, however, this is very important. Remember, prices are determined by algorithms. Simply put, the price is determined by how much the ratio between the tokens in the liquidity pool changes after a trade occurs. If the ratio changes by a wide margin, there will be large slippage as well.
To understand it better, imagine you want to buy all the ETH in the ETH/DAI pool on Uniswap. Unfortunately, that's impossible! You'll have to pay an exponentially higher premium for each ether, but still won't be able to buy everything from the pool. Why? Because the formula x * y = k. If the x or y value is zero, meaning there is no ETH or DAI in the pool, then the formula will no longer make sense.
But the discussion about AMMs and liquidity pools does not end here. There is one more thing to keep in mind when providing liquidity to an AMM – losses are not permanent.
What is impermanent loss?
Impermanent loss occurs when the price ratio of deposited tokens changes after you add them to the pool. The greater the change, the greater the impermanent loss. This is why AMMs work best with pairs of tokens that have similar value, such as stablecoins or wrapped tokens. If the price ratio between the pairs remains within a relatively small range, impermanent losses can also be ignored.
On the other hand, if the ratio changes a lot, then the liquidity provider would be better off holding onto tokens rather than adding funds to a pool. That said, Uniswap pools like ETH/DAI that are quite exposed to impermanent losses have been quite profitable due to the trading fees they collect.
Thus, impermanent loss is not the right name to call this phenomenon. “Impermanent” assumes that if the asset returns to its original price when deposited, the loss is mitigated. However, if you withdraw your funds at a different price ratio than when you deposited them, the loss is permanent. In some cases, trading fees can mitigate these losses, but it is still important to consider the risks.
Be careful when depositing funds into an AMM and make sure you understand the impact of impermanent loss. If you want to get a more in-depth overview of impermanent loss, read Pintail's article about it.
➟ Want to start your crypto adventure? Buy Bitcoin on Binance!
Closing
Automated market makers are an important part of the DeFi environment. Basically this system allows anyone to create a market smoothly and efficiently. Even though it has limitations compared to order book exchanges, the overall innovation it brings to the crypto world is invaluable.
AMM is still in its early stages. Currently known and used AMMs such as Uniswap, Curve, and PancakeSwap have an elegant design, but their features are quite limited. There will be many more innovative AMM designs in the future. This should lower fees, reduce friction, and ultimately provide better liquidity for every DeFi user.