Automated market makers (AMMs) have caused a huge stir in the cryptocurrency industry due to their ability to create markets via smart contracts. Due to their simplicity and efficiency, AMMs have solidified their position within the decentralised finance (DeFi) space.
DeFi, which aims to decentralise financial services, has exploded on smart contract networks such as Ethereum and Binance Smart Chain. As a result, AMM protocols such as Uniswap, Curve Finance and Balancer have seen an exponential increase in use.
An AMM can be thought of as an algorithm that instantly finds liquidity for those wishing to buy or sell a digital asset.
To complete trades, the algorithm uses liquidity pools, which are composed of cryptocurrencies lent to the protocol by liquidity providers. This removes the need for a “middleman” type of exchange like traditional market-making methods.
To understand automated market makers, it can be useful to look at traditional market makers first.
Traditional market makers
For traditional markets, such as gold, stocks or oil, market makers provide liquidity so that investors can buy or sell an asset close to the publicly quoted price.
This basically means that they will match a buyer to a seller. A buy order and a sell order need to match for a trade to occur. These orders sit within an order book. In global finance, with multiple market makers and millions of investors, the order book exchange is a very elegant system.
Applying the scenario to cryptocurrencies, if an investor wants to sell a token, the traditional market maker finds a buyer so that the token can be sold. If an investor wants to buy a token, the market maker finds a seller so that the token can be bought.
Market makers in the financial industry have always been large financial organisations or institutions that quote the buy and sell prices for each asset. These organisations take on the risks associated with buying and selling assets from investors. To cover these risks, traditional market makers charge a “spread” on each asset covered.
A seller is quoted a “bid” price that is slightly lower than the market price. In comparison, a buyer is quoted an “ask” price that is slightly higher than the market price.
Going back to cryptocurrencies, if the market maker buys a token from a seller for €50 and sells it to a buyer for €55, they will have made a €5 profit. Powerful computing allows millions of transactions like this to be performed daily. This provides the liquidity to keep the financial markets moving.
When applying smart contracts to the traditional market maker process, the execution time is extremely long. It can also be very expensive. This is where automated market makers come in.
Automated market makers
Automated market makers are smart contracts that provide liquidity in the DeFi ecosystem via liquidity pools, rather than the traditional order book system.
On an AMM protocol, such as Uniswap or Curve Finance, digital assets are traded by an automated algorithm against the liquidity held in the liquidity pools. This means digital assets can be swapped at any time. The exchange price of a token is determined by the AMM.
AMM protocols hold no capital, are open 24/7 and most offer investors a level of trustlessness and decentralisation, unlike traditional financial services.
In a traditional order book, liquidity is provided from buy and sell orders. Those providing liquidity through orders are often referred to as “makers”. Makers wait for a market “taker” to agree to the order. Once that occurs, the exchange can complete.
With AMM protocols, there are no makers. There are no prior orders in the system. There are only takers looking to exchange a specific cryptocurrency pair.
- A trader comes to an exchange such as Uniswap to trade 1 ETH for AAVE.
- The Uniswap AMM evaluates the current balance between the ETH and the AAVE in the liquidity pool and calculates an exchange price of 1 ETH to 6.005 AAVE.
- The trader accepts the price, completes the exchange and receives their 6.005 AAVE minus fees.
The AMM uses the liquidity pools to automatically complete the cryptocurrency exchange, without the need for another trader.
When enough token pairs are available on an exchange, the AMM can trade between any two of the tokens listed, even if the two tokens do not exist in the same liquidity pool.
If a trader wanted to exchange AAVE for DAI, the AMM could trade DAI for ETH and then ETH for AAVE in a single transaction.
Liquidity pools are pots of cryptocurrency assets lent to the protocol by liquidity providers.
AMMs work better when liquidity is high. For example, if more DAI are deposited, the token becomes more liquid and becomes easier to exchange. Liquidity is encouraged by offering interest on any deposits made to liquidity providers, with the interest rates increasing when liquidity drops. Thus, there is always a financial incentive for lenders to participate.
Incentives to lend cryptocurrencies historically included a share of the transaction fees. More recently, DeFi protocols have offered token rewards in return for lending cryptocurrencies. This is often referred to as “yield farming”.
One of the best things about DeFi is that anyone holding tokens built on the Ethereum blockchain (ERC-20 tokens) can become a liquidity provider on certain AMM protocols and receive a return on their investment.
Liquidity pools can be a useful way to earn a return on your cryptocurrency holdings, but storing cryptos can come with the risk of impermanent loss.
Impermanent loss is a loss that may be caused by holding tokens in an AMM as compared to holding tokens in your wallet.
Because the pool needs the value of both tokens to remain balanced, any change in the price of one token will cause a change in the balance of the pool. As a result, your liquidity provider token now entitles you to a different number of coins as when you originally deposited, as the value between the two coins has to remain balanced.
So for example, if the price of ETH goes up in an ETH-DAI pool, you may walk away with less ETH than you deposited, since the amount (not value) of ETH coins in the pool has to reduce in order for the value of ETH in the pool to stay even with DAI.
- Uniswap. Striving for an open and accessible marketplace for all, Uniswap uses an AMM mechanism to calculate the price of tokens based upon the ratio of the tokens in the liquidity pools. Any user can provide liquidity.
- Kyber Network. One of the original AMM protocols in the marketplace, Kyber Network’s liquidity pools are managed by professional market makers instead of a set algorithm, allowing for control of liquidity pools when volatility strikes. Entry to liquidity pools is more restrictive.
- Balancer. Balancer is comparable to Uniswap but hosts a broader range of features including multi-token pools, dynamic pool fees and custom pools ratios. Multi-token pools are a unique feature that can behave like an index in the cryptocurrency space.
- Curve Finance. A decentralised exchange focused on the trade of stablecoins. By focusing on stablecoins, Curve Finance is able to offer minimal fees and a low amount of slippage on trades.
- SushiSwap. This decentralised exchange is known for its community governance model and innovation of DeFi projects such as Onsen (liquidity pools that last longer and feature more pairs). Dig into the history of SushiSwap for more information.
Although a brilliant innovation, AMMs come with associated risks that users should be aware of before using.
One of the key risks that plague smart contract users is the vulnerability to being hacked. Uniswap and Balancer have both experienced hacks where liquidity deposits were stolen. Not all protocols have safety procedures in place to cover such losses.
In order to maintain prices, arbitrage traders are a necessary function of AMM protocols. If an imbalance occurs within a liquidity pool, usually due to high volatility, exchange prices will begin to slip from the standard market price. Arbitrage traders take advantage of that price difference and bring ratios in the liquidity pool back to a balance. This means liquidity pools are reliant on them.
Pros and cons of AMMs
- Anonymity. No KYC information is required to use an AMM protocol.
- 24/7 markets. As the protocols are controlled by smart contracts and algorithms, so markets can be traded 24 hours a day.
- No centralised entity. AMMs and liquidity pools remove the need to match buyer to seller, which removes the need for a centralised exchange.
- Vulnerable to hacks. Like any smart contract protocol, AMMs are vulnerable to hacks from outsiders, which can result in the loss of liquidity.
- Impermanent loss. If an asset deposited as liquidity spikes in price, there is a risk that upon withdrawal a liquidity provider will have lost money in relation to current market value.
- Higher gas prices. Activity that takes place via AMM can increase the gas prices on the associated blockchain network.
- Reliance on arbitrage traders. Arbitrage traders are required to keep liquidity pools balanced.