What are AMMs?
In contrast to the traditional centralized exchange trading, where traders are matched based on their buying and selling prices, Automated Market Makers (AMMs) don’t rely on order books.
Instead, it employs a smart contract to mathematically define the price of crypto tokens and automatically execute a crypto trade according to supply and demand.
An AMM incorporates three significant elements to function:
- Liquidity Providers – traders who supply funds to the liquidity pool
- Liquidity Pool – a collection of cryptocurrency asset pairs
- Algorithmic formula – a mathematical equation that determines the token pricing in the liquidity pool
Moreover, AMMs balance the supply of tokens in the liquidity pool, cracking the challenge of getting traders to transact regularly by incentivizing them with assets in exchange for being Liquidity Providers (LPs).
How Do AMMs Work in DEXs?
The traditional centralized exchanges are moderated by order books, where traders are paired according to their buy and sell prices. In contrast to DEXs, cryptocurrency assets depend on a pricing algorithm or a mathematical formula.
Liquidity pools utilize different algorithms based on the DEX protocols; however, they all set the price algorithmically.
Among the top liquidity pool platforms like Uniswap and Sushiswap, for example, use the following formula:
x * y = k
The Riverex Pool platform comparatively employs an identical formula where ‘x’ indicates the value of token ‘A’, ‘y’ represents the value of token ‘B’ being traded in the liquidity pool, and ‘k’ is constant. The AMM algorithm ensures that the product of the traded tokens or assets in the liquidity pool always remains the same.
How Does a Liquidity Pool Work?
Crypto liquidity pools essentially function through AMMs, which automatically complete a trading transaction in a trustless and permissionless system. Therefore, users primarily trade crypto assets with liquidity pools rather than a peer-to-peer transaction.
To provide liquidity to a pool, traders or Liquidity Providers (LPs) either create and deposit or add values of two tokens or coins into the collection. As more LPs contribute tokens to the pool, the prices are adjusted through AMM’s pricing algorithm, which guarantees the pool is consistently liquid.
For example, if you want to trade BNB for Ethereum, you must create or access a BNB/ETH liquidity pool to initiate a transaction. The system then creates a smart contract to execute the trade. When you buy ETH, the ratio of ETH rises, and the price drops while BNB’s price increases.
What is the Function of Liquidity Providers in a Pool?
Liquidity Providers (LPs) guarantee sufficient liquidity in the pool to support the trading activity and provide a consistent quantity of traders in the DEX, thereby offering a swift and efficient transaction.
LPs who supply funds and lock their tokens to the liquidity pool earn a percentage/reward from any trading activity, which can be considered a passive income. However, the profits for liquidity providers differ depending on the platform.
To become a liquidity provider, one should create or deposit values of both assets presented in the pool. If a user initiates a new liquidity pool, both assets must be funded, regardless of their value.
When a pool is created, the first user who funds the liquidity pool for a specific pair determines the token price, depending on how many tokens are established.
A peer-to-peer (P2P) protocol is a transaction between two traders without intermediaries.
In an AMM protocol, traders don’t need another trader to complete a transaction. It is a peer-to-contract (P2C) solution to execute a trade between a user and a smart contract, where assets are valued corresponding to a mathematical pricing algorithm.
Slippage is the difference between a cryptocurrency’s quoted (expected) price and paid (actual) amount presented in percentage of the transaction’s total swap value after it has been executed.
In an AMM protocol, slippage results from liquidity changes on both assets; the pricing algorithm will then determine the price difference. It indicates the maximum price movement traders are willing to agree to.
Slippage Tolerance, on the other hand, is the parameter that specifies the highest bearable price for a trade. Accordingly, the trade is not validated once a transaction is initiated with a higher price than the set threshold.
In the Riverex platform, the default slippage tolerance is set at 0.03%. However, users can adjust the amount of slippage from 0 to 100%, depending on the amount they are willing to accept.
Why Does Slippage Occur?
Slippage is an inevitable reaction from any transaction in an AMM mechanism. To illustrate, when LPs fund the liquidity pool, they earn rewards from any trading activity that happens subsequently.
The assets collected are used to provide liquidity for all the transactions made in the DEX. When a token swap takes place, the number of tokens in a particular liquidity pool decreases while the corresponding token being swapped increases in volume.
Prices in the liquidity pool are based on the number and value of accumulated tokens transacted. When a transaction occurs, the AMM protocol algorithmically and mathematically defines the token prices. Therefore, slippage occurs when the amount of liquidity fluctuates, giving the price difference of the transaction after a trade.
How Does Slippage Work?
Slippage happens when a trader accepts and settles for a different token price than initially quoted. Therefore, the trader often gets a lower profit caused by the market liquidity upon completing the order. Sometimes, the slippage is possibly favorable to the trader or may even experience a trade loss.
During a trade transaction, the token with higher total liquidity between all created pools denotes a cheaper price considering a higher supply. On the contrary, if the token’s total liquidity is lesser during the transaction period, it signifies a higher price.
That being the case, traders can expect a notable difference between the market and pool price. Traders can estimate a higher price slippage when the size of a single transaction is larger. It further results in a broader asset ratio proportion or margin change considering the relatively low liquidity of the other asset involved.
Simply put, the formula for an acceptable slippage percentage is:
More liquidity = Less slippage
Thereby, in an AMM protocol, incentivizing the LPs is one strategy that motivates traders to constantly contribute funds to the liquidity pool, attracting more volume to the DEX platform.