How Automated Market Makers (AMMs) Work in Defi: Uniswap as a Case Study
What Is an Automated Market Maker?
Automated Market Maker is a mechanism that executes the trading of digital assets without any permission, and trade runs automatically with the use of liquidity pools that replaces buyers and sellers.
A decentralized exchange (DEX) protocol relies on a mathematical formula to set the asset price. This formula replaces older books in traditional exchanges where pricing algorithms determine the cost of the assets.
This Automated Market Maker (AMM) is a part of the Decentralized Finance (DeFi) Ecosystem and plays a significant role in improvising the DeFi Space.
A Deep Dive into Uniswap
The Uniswap protocol uses an automated market maker (AMM)-style architecture to enable decentralized swaps of crypto-assets. One of the foundational elements of Ethereum’s DeFi ecosystem is the protocol.
Users who deposit money into a pool to become a liquidity provider on Uniswap are given a token that represents their investment. A commission of 0.3% is due for each exchange carried out through the protocol.
Each liquidity provider receives a percentage of these commissions based on the number of crypto assets they have contributed to the pool.
As a result, users can swap Ethereum (ETH) and the most compatible ERC20 tokens directly through Uniswap. Users can also use their assets to add to the system’s liquidity. In exchange, they get the commissions produced by each swap as payment.
How Does Uniswap Work?
Uniswap is an Ethereum protocol that supports the exchange of tokens. Tokens are always kept in the user’s hands, and because it operates on a blockchain, trust in third parties is not required.
The protocol does away with the order book to keep liquidity reserves of various tokens in its smart contracts. Transactions are thus carried out directly against these reserves.
Using the continuous product market maker mechanism, the price is established automatically. The system’s constant (x * y = k) maintains the relative equilibrium of total reserves.
The system’s reserves are distributed across a network of liquidity providers who issue tokens. Each LP receives a proportionate share of the commissions from each transaction.
For instance, after adding 1,000 DAI and 10 ETH, the liquidity pool now stands at 10,000 DAI and 100 ETH. Because the quantity supplied equals 10% of the total liquidity, the contract generates and transfers to the market maker “liquidity tokens” (LP tokens) that grant them access to 10% of the overall liquidity pool.
These tokens serve as an accounting tool to keep track of the debt owed to liquidity providers. The new liquidity tokens are created or destroyed to maintain the same relative fraction of everyone’s liquidity pool if others add or remove coins.
How Does an Automatic Market Maker (AMM) work?
Utilizing liquidity pools, an AMM operates. Users deposit their assets in pools, which are funds, and they always deposit their assets in pairs to establish a market.
For instance, if the user wants to establish an exchange market between ETH and DAI, they must contribute an identical amount of each currency to the pool. Users that contribute 10 ETH to this pool will also need to contribute 1,000 DAI because each ETH is worth 100 DAI.
The fundamental equation to take into account is x * y = k, where x and y represent the quantities of the currencies in the liquidity pool, and k represents the product. These two amounts are multiplied by Uniswap (1000 x 10 = 10,000). Any operation after this must maintain the product’s value in relation to the two currencies.
Benefits of Automated Market Maker
Automated Market Makers has been changing the space of cryptocurrency trading. The benefits that cryptocurrency exchanges experience by utilizing the automated market-making mechanism.
- Many new trading models are created by using this automation mechanism.
- Due to this, the market develops high liquidity.
- Latency on trades can be measured in milliseconds instead of seconds.
- Reduces the ability of front running, wash trading, price manipulation, and more.
- Price Slippage is counted as less than a penny between the trade executions.
- It takes only a fraction of a second to create and set costs for orders.
- This system made everyone happy, reducing price fluctuations and gaining new acceptable profit margins.
Cons of AMM
1. Slippage Problem
One of the main problems of AMM is what is known as slippage. Slippage is the difference between a trade’s expected price and the transaction’s execution price.
2. The problem of impermanent loss
Another problem with AMM is what is known as impermanent loss (IL). The IL is a consequence of how an AMM works from the constant product mechanism.
Bottomline
Automated market makers have increased the liquidity of decentralized exchanges and a new profitable money-making option for liquidity providers. Being the core of DeFi, AMMs has become one of the most important innovations of the decentralized world.