Tutorials:Automated Market Making: Difference between revisions

From Seasonal Tokens
Jump to navigation Jump to search
BeginnersGuide>Marin
 
m (Move page script moved page Tutorials:78ee to Tutorials:Automated Market Making)
 
(One intermediate revision by one other user not shown)
(No difference)

Latest revision as of 01:41, 4 November 2025

Quest: Automated Market Making

Liquidity Pools are used to implement decentralized, automated, and trust-less markets.

  • These work differently from traditional order-book-based exchanges, where buyers and sellers place orders, and the exchange matches them.
  • In a decentralized exchange, a person trades with the liquidity pool, not directly with another person.

Key Concepts

  • Buying or selling a token in a decentralized exchange affects the price of the token.
  • The price is calculated after the impact of your trade is taken into account.
  • To calculate the price Uniswap uses the Constant Product Formula.

Formula for Token Price

Let’s assume a liquidity pool contains:

  • T amount of tokens
  • E amount of Ether

The price of a token in units of Ether is given by:

P = E / T  
  • Buyers:
 - Take tokens and deposit Ether, increasing the price.  
  • Sellers:
 - Deposit tokens and take Ether, decreasing the price.  

Price Determination

Prices are determined by maintaining the condition:

 T * E = k  

Where k is a constant.

Why this condition?

  1. The formula is simple and requires no active management.
  2. It ensures the liquidity pool can never be completely drained of either asset.
  3. Prices are sensitive to trade size: Larger trades have a more significant impact on the price.
This encourages smaller, frequent trades and discourages large market-moving trades.

Key Insights:

  • When you buy:
 - You don’t get the listed price but a higher price calculated after your Ether is deposited, and tokens are taken.  
 - The more you want to buy, the more expensive it gets.  
  • When you sell:
 - You don’t get the listed price but a lower price calculated after your tokens are deposited, and Ether is taken.  
 - The more you sell, the cheaper it gets.


Example:

An example will be better for understanding how this works.

Automated Market Making Example