How do AMMs work ?
Automated Market Makers is a term that is widely known by the wide crypto community, but very few actually know what is under the hood and how the engine evolved over time. This in turn is great, as it showcases that AMMs have abstracted the underlying complexity away and with the help of powerful User Interfaces, they managed to make trading cryptocurrencies a seamless experience.
Most often AMMs are viewed as a scale, but that image doesn’t serve as an accurate representation because the goal of the AMMs is not to keep the balance, but to keep track of the amounts that are inside the respective pair’s liquidity pool to determine the price.
Hence we view them as an Abacus, that counts each time a trade is made and keeps a record of how the liquidity moved in the respective pair, all that without any entity to oversee or interfere with the operation.
The AMM Abacus has 3 main pieces that we are going to explain as following:
- The body of the Abacus | | representing the limits of the liquidity pool
- The rods of the Abacus : — : as the liquidity providers that enable the movement of the liquidity
- The beads of the Abacus -o-oo- that represents the liquidity, the tokens that are traded on the exchange
All the 3 components for a very powerful solution that revolutionized trading:
| — o-oo-ooo-|
|-ooo — oo-o-|
|-ooo-oo — o-|
| — o-oo-ooo-|
Let’s look at each of them briefly and understand how they work.
1. The body — Liquidity pools
Traditionally exchanges worked with orderbooks, where participants placed or executed orders to trade, but with AMMs users don’t trade against buyers and sellers, but against a pool of tokens — a liquidity pool. At the core liquidity pools are a shared pot of tokens locked in by the users and the price is determined by a mathematical formula.
TL&DR: A Liquidity Pool acts as a body that gives a precise boundary on how trading can happen based on how deep the liquidity for tokens is.
2. The Rods — Liquidity Providers
Previously exchanges either suffered from a lack of users and thus liquidity was very spread out and also very inconvenient to trade due to the price spikes or they had to use professional market makers that filled the gaps between trader’s orders to ensure a smooth trading experience.
Liquidity providers are the backbone of any AMM and they solve the above problem by placing the tokens from a pair inside a smart contract, that becomes like a rod on which the liquidity moves. Usually the liquidity is being kept track of through a LP (Liquidity provider) token representing shares within that pool.
TL&DR: Liquidity providers are users who deposit tokens into a Liquidity Pool to create a shared pot for trading against. That shared pot becomes a rod on which liquidity moves as people trade and each of the user’s tokens are kept track of using a token representing the shares of LP in that pool.
3. The beads — Liquidity
Liquidity is often referred to as the ability to exchange an asset for another without impacting the price substantially. In the context of AMMs liquidity is shared by the users and becomes instantly available in one concentrated pot, which is much more efficient than the spread out orderbook model. AMM exchange’s pairs are represented in the pool by a certain percentage weight and through trading the weights are moving like beads on the abacus and as such amounts and prices are being tracked upon.
TL&DR: Liquidity is shared by the users who deposit tokens into a pair, with the tokens becoming like beads that are being tracked on and with their movement in or out of the pool, the price adjusts.
Brief History of AMMs
The history of AMMs begins with Bancor in 2017, as one of the first solutions that were brought to production. It made use of all the above concepts with Liqudity Pools, Liquidity providers and Liquidity, but the difference is in the details.
Bancor uses a complex mathematical formula, that keeps track of token prices in relation to their native token BNT, as such when a trade is made the protocol first sells the first asset for BNT and then with that BNT buys the second asset. In this instance Liquidity providers are required to provide only 1 type of asset to a liquidity pool and everything is bridged by the BNT token.
A year later in 2018 we see the introduction of Uniswap, that utilized the same basic AMM concepts as Bancor but with twist, it got rid of the necessity for the BNT token and as such it required also fewer hops for a trade and thus improved the gas costs for a simple trade operation.
Uniswap made use of a simpler mathematical formula that allowed it to improve the original Bancor design, which was: x * y = k , where x is the amount of one token in the liquidity pool, and y is the amount of the other and those amounts combined must be constant and equal to the k. So in this simple way Uniswap was able to keep the value of a liquidity pool constant, resulting that the only factor that can change is the price of either assets against each other.
A new chapter: Maiar Exchange
The Elrond team introduced in April 2021 the Maiar Exchange a dedicated AMM platform that would take full advantage of the capabilities of the Elrond network.
As of this date, the Maiar exchange is still in development and close to seeing the first release, but with the details we know so far we can asses some of it’s features.
First of all, Maiar Exchange will make use of the classic formula x * y = k, in a way or another and will have similar features that Uniswap and other current AMM platforms have. But one thing is interesting to notice:
“The ability of any kind of value to become digital, liquid, instantly, and globally tradeable will give the world economy superpowers. Literally.” — elrond.com/blog/maiar-exchange
This small detail might unlock a lot of possibilities especially in the NFT and SFT trading field, as Elrond network makes use of smart accounts features that enables individual wallets to have similar functionalities as a smart contract when it comes to token interactions. As such we can truly witness game changing interactions with other types of tokens that enable new kind of trading through the Maiar exchange.
The other amazing things that will come with Maiar exchange will be the extremely reduced costs of trading and interacting with the protocol overall. As Elrond transaction cost is negligible and comes with great speed, it will enable new usecases for AMM like never seen before.
To get a glimpse we have a look at the recent comparison made by the Elrond community with the information available on May 2021.
This doesn’t take into account the optimizations that the Elrond team employs with the Maiar exchange in terms of costs and speeds, but it showcases how massive is the improvement.
We can add on top the recent MEX governance token economics and mechanics that will offer a broad and fair distribution for the community and will incentivize the Liquidity building into the Liquidity pools and thus create a positive feedback loop:
“More Trading Volume > Higher Market Makers (MM) Profits > More Liquidity Provided > Less Slippage & Tighter Spreads > More Trading Volume.” — elrond.com/blog/maiar-exchange-mex-tokenomics
In a further article of the series we will explain how Liquidity providing works and how the LP incentives for the maiar.exchange are structured.
AMMs are something very complex due to the clever way they solve the problem of liquidity, which involves advanced mathematics and smart contracts. But they have achieved major adoption due to the way the User Interface was developed, which simplified the trading process to the core and as such it made it available for everyone to exchange assets seamlessly and in a decentralized manner.
We at Istari look forward to the future that Elrond network and Maiar Exchange will bring in the decentralized exchanges space.