What are automated market makers?
Decentralized exchanges where one trades with a smart contract, not other people
Automated market makers, or AMMs, are a class of decentralized exchanges that rely on mathematical formulas to set the price of a token. Like normal exchanges, they have various trading pairs: for example, Ether (ETH) to Dai.
But there are no buy or sell orders, and traders don’t need to find someone else to sell their coins to. Instead, a smart contract acts as the maker in an exchange transaction. The concept is similar to quick-swap services like ShapeShift and Changelly, but the difference is that the company’s reserves are replaced with liquidity pools based on smart contracts.
A liquidity pool contains two assets in a trading pair. The relative percentage of each token in that pool is what determines the theoretical price of a particular asset. The first live AMM was Bancor, launched in 2017, but the most popular platforms today are Uniswap, Curve, Kyber and Balancer.
Why do these exchanges exist?
They make providing liquidity much simpler and cheaper
Automated market makers are an attempt to work around the performance restrictions of smart contract blockchains, especially Ethereum. Before AMMs came into prominence, decentralized exchanges built on Ethereum, like EtherDelta or 0x, attempted to use a classical order book mechanism.
However, they suffered from liquidity issues, as placing each order required spending gas and waiting for block confirmation times. Ethereum’s low throughput also meant that only a small number of transactions could be submitted before the blockchain would be completely swamped by these orders.
This was especially problematic for market makers, the liquidity providers on order book exchanges. “Making” a market typically requires constantly adjusting buy and sell orders to the latest price, even if they do not get filled. When each submitted order costs money and time, they may lose more than they gain from the bid-ask spread, which is the difference between the highest offered buy price and lowest sell price.
AMMs make providing liquidity cheaper and simpler through a completely automated one-time process — hence the name. Even average users can pitch in with their liquidity, while doing so on traditional exchanges requires advanced technical knowledge.
How do smart contracts automate trading on AMMs?
A mathematical formula defines the price of a particular token
When trading on an AMM, users interact with the liquidity pool. Under the hood, when the user instructs the smart contract to perform a trade, the contract sends their tokens, such as ETH, to the liquidity pool. A mathematical formula then decides how many tokens from the other side of the pair — for example, Dai — they should receive in return.
The simplest practical formula is X multiplied by Y equals K, where the X and Y represent the amount of each token in the pool and K is a predefined constant. This equation defines a hyperbola: a smooth geometric shape that approaches both infinity and zero at its extremes but never quite reaches them.
Each trade has some amount of slippage — how much the size of the order affects the ultimate price at which a token was bought or sold. The hyperbola shape means that slippage will be low with small orders, but with large orders, slippage rises exponentially. Uniswap is known for using this simple formula, but other platforms may use more complicated math to fine-tune the slippage.
How does one use an automated market maker?
Connect the wallet, and confirm the transactions
Using an AMM protocol is quite simple: Users visit the protocol’s website or other front ends, connect a DeFi-enabled wallet to the protocol, choose the asset they wish to buy or sell, hit “swap,” and confirm the transaction on their wallet.
Providing liquidity works similarly to trading. After connecting a wallet, users can go to the “liquidity provider” section and select how much they want to commit to the pool. In most protocols, they need to have both types of assets available. For example, if ETH is trading for 400 Dai, they will need to simultaneously provide 1 ETH and 400 Dai.
After confirming the transactions, users receive a token representing their ownership in the liquidity pool. It can then be transferred to anyone or redeemed once again for the underlying tokens, plus any fees they might have accumulated.
Why are AMMs becoming popular?
Decentralization and permissionless use are powerful improvements
Automated market makers are, arguably, already solving the biggest obstacle to the widespread adoption of decentralized exchanges: liquidity. Without that issue, the natural benefits of a DEX can shine through.
Unlike traditional centralized exchanges, there are no gatekeepers that could exclude projects or users. AMM protocols are permissionless and do not require users to set up specific accounts or pass stringent Know Your Customer checks. A wallet address is all that is necessary to interact with the protocols.
From the perspective of a project, DEXs are also a great way to release a token to the market and bootstrap liquidity. There are no listing fees or admission criteria, as anyone, even an outsider, could set up a liquidity pool for any token.
Democratizing the act of providing liquidity also means that the project’s fans and holders can help create a liquid market on new tokens without requiring the assistance of specialized market makers. Finally, AMM decentralized exchanges generally have very simple interfaces, as they do not need to pack advanced order options or price charts into one dashboard.
What are the risks and limitations of AMMs?
Bugs, improper pricing and impermanent loss
Despite some positive qualities, AMMs present certain risks and limitations. Hacks and vulnerabilities have already affected exchanges such as Uniswap and Balancer, where some liquidity providers saw their money stolen due to complex smart contract interactions. On the other hand, traders are exposing their strategy for the world to see, enabling front-runners to get their orders in first and exploit legitimate users.
Related: Figuring Out Who’s to Blame for DeFi’s Persistent Security Issues
Automated market makers also cannot exist without traditional order book exchanges being relied upon for arbitrage. The mathematical formulas, despite their elegance, cannot truly represent market sentiment. Arbitrage traders are necessary to correct the pricing of assets in an AMM, but this results in the issue of impermanent loss on many platforms.
In a nutshell, arbitrage traders make a profit by bringing the price in balance, but this profit is extracted from the liquidity providers. Despite the trading fees they receive, liquidity providers may actually lose money if the price moves too far in a certain direction. The loss is “impermanent” because the price could always move in the opposite direction, but in practice, this will not always happen.
While there are certain improvements being made, the volume and liquidity of AMMs still pale in comparison with the largest centralized exchanges. Gas congestion in the summer of 2020 also showed that they are starting to hit their use ceiling, and better scaling solutions will be required in the future to facilitate further growth.