Automated Marketer

What Is An Automated Marketer (AMM)? Familiarity With The Beating Heart Of Decentralized Exchanges

Definitely By Now The Name “Decentralized Exchange You May Have Heard, And You May Be Wondering, How Exactly Do Decentralized Exchanges Work, And How Do They Differ From Regular Exchanges?

Automated Marketer, It is clear that digital currencies, like any other asset, need an environment for exchanges. In other words, these currencies need a “market” in which to buy and sell. In the first generation of digital currency exchanges, the same “Centralized exchanges method of exchanges is straightforward and understandable.

Exchange offices record users’ purchase orders and sales orders in a section called the order book and matched them with each other; In this way, transactions between buyers and sellers are done through the brokerage of exchange offices.

But in decentralized exchanges that do not have access to users’ assets, how can orders be completed?

This is where the Automated Market Maker, or AMM for short, comes into play.

Centralized digital currency exchanges operate under the supervision of one person or group of individuals. These exchanges directly control users’ assets, and users are required to deposit their assets into the exchange wallet to make transactions. At the same time, centralism and institutions’ access to individual assets is contrary to the inherent nature of digital currencies.

Due to these problems, decentralized digital currency exchanges or DEXs came into being to allow the direct exchange of digital currencies without requiring users to authenticate and without keeping users’ assets in safe deposit boxes. Of course, in this article, we do not intend to talk about all aspects of decentralized exchanges; Rather, our focus is on one aspect: how to price and liquidate digital currencies in decentralized exchanges.

In this article that helps an article Collected from Binance Academy, you will learn:

  • What is an order book in centralized exchanges, and what are its challenges?
  • What is an automated market maker (AMM), and on what basis does it work?
  • How do automated marketers determine asset prices?
  • What is the meaning of price slippage in decentralized exchanges?
  • What is a liquidity pool, and what is the role of liquidity suppliers in it?
  • And What is the impermanent loss in AMM-based exchanges?

Automated marketers at a glance

Since this article is relatively long and specialized, we will briefly describe automated marketers and their work.

The automated marketing algorithm is, in fact, an alternative to traditional bookstores. Before the advent of decentralized exchanges based on automated marketers, buying and selling orders were stored in centralized exchanges’ databases. A matching engine mechanism linked similar buying and selling orders together.

For example, if you want to buy 1 bitcoin for $ 10,000, you place your purchase order at an exchange. On the other hand, Bitcoin sellers place their sales orders at the prices they want, and then the exchange engine is activated.

The matching engine compares the buy and sells orders, and when two orders (buy and sell) are registered for the same amount (for example, $ 10,000), it trades between them. It transfers the seller’s bitcoins to the buyer and the buyer’s dollars to the seller.

But the new generation of decentralized exchanges has generally removed the book of orders from its platform and replaced it with the concept of automated marketing.

Automated marketer, a collection of several smart contracts It is the Chinese blockchain that provides the necessary liquidity for each pair of trades and determines the price of currencies based on the supply and demand mechanism.

The automated marketing algorithm creates space for different trading pairs as a pool of liquidity.

Each liquidity pool is set up by depositing an equivalent amount of trading currency. To exchange, people can attach their wallets to the smart contract of the desired liquidity pool and receive the equivalent amount of the other token by depositing one of the tokens.

In fact, in this method, instead of exchanging their tokens with each other, people exchange tokens with a smart cash pool contract.

The ratio of tokens in the pool indicates the rate of supply and demand. Therefore, the automaker uses this ratio to calculate changes in currency prices over time. The people who provide liquidity to the pairs of values ​​in the pools are called “liquidity providers

.” By locking their assets in the pool, these people can earn a portion of the commissions paid by the traders. They can also release their assets and withdraw from the liquidity pool whenever they want.

In the rest of this article, we will fully explain the concept of automated marketing and how it works.

What is an automated marketer?

As its name implies (marketer + automaker), an automated marketer is a mathematical algorithm that creates a market for direct trades in decentralized exchanges. By market, we mean the conditions that must be met for a trade to occur.

This algorithm automatically determines the price of assets using the supply and demand mechanism. It allows users to trade without registering a buy and sell order and even without the need for the other party (seller or buyer).

To better understand the performance of automated market makers, we remind you once again that the performance of decentralized exchanges does not depend on a particular organization.

 These platforms are, in fact, smart contracts that are registered and executed on the Chinese blockchain.

Therefore, they must have a specific protocol for pricing assets, providing liquidity, and adjusting it. This task is the responsibility of the automated market maker.

If we know how to trade in the first generations of decentralized exchanges (such as BitShears and Binance Dex) person-to-person or peer-to-peer, trading in market-based decentralized exchanges, as a person-to-contract (Peer-to) -contract) is done. Because users can connect their personal wallets to the exchange platform (while retaining full control over their assets), they can buy or sell their assets directly from a smart contract.

An automated market maker is like a robot that has the task of calculating the price of a currency against the currency at the moment and offering it to you. In other words, when you want to buy or sell a digital currency in exchange for another digital currency, it sets the equivalent for you.

The formula of automated market makers of different exchanges is different from each other. 

Some of them, like (Uniswap) and Pancake Swap (Pancakeswap), use simple formulas to do this, while others like (Curve) and (Balancer) have more complex formulas.

The ion-swap exchange formula for determining the price is x * y = k. In this formula, x is the inventory (number of units) of a digital currency in the liquidity pool, and y is the inventory of another digital currency that is to be traded. k In this formula is a fixed number and indicates the amount of liquidity of the entire pool.

In the following, we will explain more about how AMMs work based on this formula.

How Do Automated Marketers Work?

Imagine the pair ETH/UNI You want to buy ion tokens to sell some of your ethers. To do this, you must deposit ether tokens into the pool and receive the equivalent ion tokens. In this case, the volume of ether in the liquidity pool is high, and the ionic volume in this pool is reduced. So it is natural that the price of ions goes up for a while, and instead, the price of ether goes down.

This goes on until the opposite of what you do is done by others, and the price rebalances. Of course, this happens sooner than you think; Because when the price of a digital currency (or a token) goes down in exchange, many people will want to buy it, and the price will return to equilibrium.

So we can conclude as follows:

The automated marketer determines their value (or price) relative to each other based on the weight ratio of the assets in the pool. In more complex protocols, such as the Balancer, whose pools contain a basket of currencies instead of a currency pair, the method of calculating this weight ratio is somewhat more complex. But in protocols such as Ion Swap, Sushi Swap, and Pancake Swap, which use the simplest form of marketing, the weight ratio of currencies is calculated from the relation x * y = k.

To better understand this mechanism, consider the ETH / USDT currency pair. If we consider the number of ETH as X, the number of stable coin USDT as Y, and the volume of liquidity of the pool in question as K, in the formula X * Y = K, the value of K will always be constant. Therefore, the automated marketing protocol determines the price of X and Y in such a way that K remains constant in the above formula.

To better understand this process, consider the following example:

Pool ETH balance: 100 units
USDT pool balance: 200,000 units
Trading fee: 0.3.

Now the volume of pool liquidity (K in the above formula) and the ratio of ETH to USDT are determined as follows:

K = 200,000 * 100 =
20,000,000 ETH / USDT: 200,000 / 100 = 200
0

The ETH / USDT ratio shows the price of ether in terms of tether, and given that the price of the tether is fixed, the ether price here is $ 2,000. The details of the token conversion transaction in this pool will be as follows:

Behzad intends to convert 10ETH into a stable USDT coin.
Conversion fee: 0.03ETH

Therefore, the balance of each token in the pool during the transaction will be as follows:

ETH: 100 + 10 – 0.03 =
109.97 USDT: 20,000,000 / 109.97 = 181,867
 .7

The amount of USDT received by Behzad is determined as follows:

Behzad Received USDT = USDT Primary Balance – USDT Secondary Available
Behzad USDT = 200,000 – 181,867.7 = 18.132.3

Finally, according to the new inventory of ETH and USDT in the pool, the value of K and the new ratio of ETH to USDT are determined as follows:

K = 181.867.7 * 109.97 = 19.999.990.969.20.000.000
ETH / USDT: 181.8677.7 / 109.97 = 1653.79

As you can see, by selling ETH to the ETH / USDT pool, the ETH liquidity in the pool will eventually increase, and the USDT liquidity will decrease. As the liquidity balance of this trading pair is upset, the price of ETH (in terms of USDT) will decrease, and the price of USDT (in terms of ETH) will increase.

In this example, because we have chosen the StableCoin USDT as the currency against the ether, the ETH / USDT ratio represents the price of the ether after the exchange (the price of the ether has decreased from $ 2000 to $ 1653.79).

Note, however, that in this example, for simplicity of calculations, we have assumed very little pool liquidity. Therefore the effect of a 10-ether transaction on the price of this currency is substantial.

Also, if you buy ETH from this pool, the pool balance will be upset in favor of USDT, and this time, the price of ETH will increase. This is almost exactly what an automated marketer does.

This phenomenon (i.e., price changes due to buying and selling), so-called price slippage, is a common phenomenon in decentralized exchanges and depends on two factors: trading volume and the volume of pool liquidity. The more liquid the pool, the less the price will slip, and on the other hand, the more the transaction volume, the more the price will slip.

Of course, in centralized exchanges and office-based models, there is also the phenomenon of price slippage. For example, in a centralized exchange, if the volume of an individual purchase order is high, it will inevitably have to buy all the sales orders from the sales order list until it completes its purchase, and this means that the transaction is in a range of prices instead of a specific price. Be done.

Another concept you need to understand the performance of automated market makers is ” liquidity pool ” and ” liquidity provider. “ 

The question may arise in your mind that when decentralized exchanges do not use the order book and do the transactions themselves, where do they get this amount of liquidity? In other words, how do they have so many high-volume tokens that they provide to users whenever they need them?

The truth is that in automated marketers, there is a section called the liquidity pool that some exchange users, whom we call liquidity providers, charge. Join us in the next part of the article to better understand the role of the liquidity pool and the responsibilities of liquidity providers.

What is a liquidity pool?

That being said, in an automated market, there is no need for two parties to the trade, and only one seller or one buyer is enough to trade; But we still need someone to create this market. For example, when you want your ether in exchange for a token(DAI) Sell, the smart contract that your trading partner must have enough to deposit into your wallet. This is where liquidity comes in. The liquidity of automated market makers is provided by users, so-called ” liquidity providers ” (LPs).

Each user can contribute to the liquidity of the pools as much as he wants. Market-based exchanges allocate all or part of their exchange fees to liquidity providers to encourage more liquidity.

The general process of providing liquidity in automated pools is as follows:

What is an automated marketer? Familiarity with automated marketers
  • According to the interest rates of different pools, people who intend to deposit their assets choose the pool they want to provide liquidity.

 

What is an automated marketer? Familiarity with automated marketers
  • Liquidity suppliers attach their wallets to the smart contract of the pool in question. In this way, the smart contract can access a specified amount of tokens and use them to exchange with other users.

 

What is an automated marketer? Familiarity with automated marketers
  • They then determine the amount of liquidity required and provide the same amount of liquidity from each pair of tokens in the pool. For example, if you want to provide cash for 1 ether in an ETH / DAI pool, you must deposit the equivalent of 1 ether of DAI tokens.
What is an automated marketer? Familiarity with automated marketers
  • After depositing the assets in the pool in question, the smart contract transfers the LP tokens of the same pool to their wallets as much as the individuals’ share of the cash in each pool. For example, if you have cash in your ETH / DAI pool, you will receive an ETH-DAI LP token.
What is an automated marketer? Familiarity with automated marketers
  • The token exchange fee is automatically paid to the respective pools, and users earn the same amount as the pool they’s liquidity from the accumulated fees. Finally, liquidity providers can deposit LP tokens into a smart contract at any time and receive deposit tokens deposited in the pool along with commission profits.

 

 

The amount and manner of distribution of commission profits among liquidity providers vary depending on the economic model designed for each protocol.

Uni Swap, for example, receives 0.3% of the value of each transaction as a commission and transfers it directly to liquidity providers. Sushi Swap Exchange also charges 0.3% of each transaction, But it devotes part of it to its profit-making platform.

On the other hand, other platforms may charge less to attract more users. For example, the Pancake Swap exchange receives 0.2% of the transaction value as a fee from traders and allocates it to liquidity suppliers.

But that is not the whole story of automated marketers and liquidity pools. One of the potential risks for liquidity providers in automated market makers is impermanent loss, which we will explain in the next section.

What is a non-permanent loss?

If we want to describe non-permanent losses in one sentence, we have to say that this happens when the price of tokens deposited in the pool changes over time.

To better explain this concept, we use an example.

Suppose you have deposited 10 ethers and 10,000 dai in a decentralized exchange such as Uni Swap (i.e., at the time of the deposit, the price of each ether was equal to 1,000 dai).

Also, assume that you are the sole provider of pool liquidity. Therefore, this pool’s total amount of liquidity is equal to 100,000 = 10,000 * 10 dai.

Now suppose that the price of ether in the market suddenly rises from $ 1,000 to $ 2,000 (but the price of ether in Uni Swap is still $ 1,000). This is where arbitrators go into ion swaps and buy cheap ethers (to sell them for $ 2,000 in overseas markets). These purchases will continue until the price of ether in Uni Swap reaches $ 2,000 and equals the foreign market price.

We mentioned earlier that the total liquidity of the pool (k) is a fixed amount. So in this example, your pool liquidity should remain at 100,000 dai. In this case, according to the relation x * y = k, your capital will decrease from 10 ethers to 7,071 ethers, and the number of your nannies will increase to 14,142. To make sure the numbers are correct, you can multiply 7,071 by 14142:

7,071 * 14,142 = 99,998,082 ~ 100,000

You can see that the liquidity of your pool with this new ratio is the same as 100,000 dai. You may think that since the money changer has added to your number of midwives, it does not harm you, and the value of your capital is preserved; But it is not:

Dai 28.284 = 14.142 + 14.142 = value of your capital (in case of liquidity)
Dai 30,000 = 20,000 + 10,000 = value of your capital (in case of holding)

As you can see, in such a situation, if you kept your initial capital (i.e., 10 ethers and 10,000 dai) in your wallet instead of depositing it in the liquidity pool, the value of your assets would be higher.

The greater the gap between the initial price of the liquidity you provided and its current price, the larger the non-permanent loss. This is why the use of tokens such as stable coins or wrapped tokens, which have a fixed value, works better in the world of automated marketers.

However, it seems that non-permanent losses are not a good name for this phenomenon. The adjective “non-permanent” is based on the assumption that if assets regain their value when deposited in the liquidity pool, the supplier’s loss will reduce.

However, if you withdraw your assets from the pool when there is a difference in value between the original price and the current price, the loss will be quite permanent.

However, there is another point that you should not forget is that you also receive a profit in exchange for providing liquidity.

In many cases, the profit you receive may overlap or exceed the non-permanent loss. Decentralized exchanges have thought about this before us and have come up with a solution.

If liquidity were to always be at a disadvantage for currencies such as ether, which do not have a fixed price, no one would be willing to provide liquidity for these currencies, and the operation of decentralized exchanges would hamper. For this reason, these exchanges have made more profit for such currencies to attract more liquidity to them.

The purpose of all these explanations was to know that in the world of decentralized exchanges, as in all aspects of digital currencies, there is neither absolute profit nor absolute loss. Everything in these exchanges goes according to precise and predetermined calculations.

Whether you want to use these exchanges to make transactions or you want to participate in the process of providing them with liquidity, you must first devote enough time to study and research and be aware of all their possible consequences.

Concluding remarks

Automated marketing is one of the most important achievements of decentralized finance. Although automated marketers have their own limitations compared to exchange offices, and although they are not as easy to use as traditional exchanges, their innovation in the world of digital currencies is invaluable.

We must not forget that automated marketers are still in the early stages of development. The types of marketers such as Ion Swap, Sushi Swap, and PancakeSwap that we know and use today usually have a nice, user-friendly interface but are still limited in functionality.

Like any other innovation, these exchanges need time to show all their capabilities and reach their maximum potential. With the further advancement of this technology, automated marketers will be designed to be user-friendly and provide lower fees and ultimately more liquidity for Defy users in the not-too-distant future.