Must-Read for Liquidity Providers: How Are LP Tokens Calculated?

LP tokens represent your ownership share in an AMM liquidity pool.,The quantity minted for you depends on your contribution proportion

The calculation of the number of LP tokens a user receives after adding liquidity is not singular; it depends on the specific protocol and the condition of the pool at the time of deposit.

Below, I will explain the logic behind the LP token calculation in detail for different scenarios.

用户加池前必看:LP代币数量到底怎么算?

Core Concept

First, understanding the nature of LP tokens is crucial:

  • Proof of Stake: LP tokens represent your share of ownership in the liquidity pool. It’s like a share certificate proving your investment in this “pool company.”

  • Not a Fixed Amount: The number of LP tokens you receive is not simply determined by the amount of assets you deposit, but by the proportion of your deposit relative to the pool’s total assets.

Scenario 1: You Are the First Liquidity Provider (Initializing the Pool)

When you are the first person to create a pool for a trading pair (e.g., TokenA/TokenB), the protocol needs to establish an initial “anchor ratio.” The calculation rule for the number of LP tokens is very simple at this stage:

LP Tokens You Receive = Geometric Mean of the Amounts of the Two Assets You Deposit

The formula is:
LP_Received = √(TokenA_Amount * TokenB_Amount)

  • TokenA_Amount: The amount of the first asset you deposit.

  • TokenB_Amount: The amount of the second asset you deposit.

  • LP_Received: The number of LP tokens you will receive.

An Example:
Suppose you are the first to add liquidity to a TokenA/TokenB pool, depositing TokenA_Amount = 10 and TokenB_Amount = 20,000.
Then, the number of LP tokens you receive = √(10 * 20,000) = √(200,000) ≈ 447.21 LP tokens.

Why is it done this way?
Because 100% of the assets in the pool are yours at this moment. These 447.21 LP tokens represent 100% ownership of the pool. It also sets a price benchmark for subsequent liquidity providers: 1 TokenA = 20,000 / 10 = 2,000 TokenB.

Scenario 2: You Are Not the First Provider (Adding to an Existing Pool)

This is the most common scenario. Here, the calculation of LP tokens is based on your contribution proportion.

Core Formula:
Your LP Tokens = (Amount of TokenA You Provide / Total TokenA in Pool) * Current Total LP Supply

However, to ensure that the added liquidity does not “dilute” the value of existing LPs and conforms to the pool’s current ratio, the protocol typically requires you to deposit the two assets in the same proportion as the current pool.

The calculation steps are as follows:

  1. Get the Current Pool State:

    • Total TokenA in the pool: TokenA_Pool

    • Total TokenB in the pool: TokenB_Pool

    • Current total supply of LP tokens: LP_TotalSupply

  2. Determine the Amount of Assets You Should Deposit:
    Suppose you only want to deposit a certain amount of TokenA. According to the constant product formula x * y = k, the amount of TokenB you need to deposit is:
    TokenB_Deposit = (TokenB_Pool / TokenA_Pool) * TokenA_Deposit
    This ensures the value of the two assets you deposit is equal.

  3. Calculate the LP Tokens You Deserve:
    The protocol mints new LP tokens for you based on the proportion of your deposit relative to the pool’s existing assets. The proportion is the same, so it can be calculated using either asset (the results should theoretically be consistent).
    LP_Received = (TokenA_Deposit / TokenA_Pool) * LP_TotalSupply
    or
    LP_Received = (TokenB_Deposit / TokenB_Pool) * LP_TotalSupply

An Example:

  • Pool State: A TokenA/TokenB pool contains TokenA_Pool = 100 and TokenB_Pool = 200,000. The current total LP supply LP_TotalSupply = 1,000.

  • Current Price1 TokenA = 2,000 TokenB.

  • Your Action: You want to deposit TokenA_Deposit = 5.

First, calculate the required amount of TokenB to deposit:
TokenB_Deposit = (200,000 / 100) * 5 = 10,000 TokenB
So, you need to deposit 5 TokenA and 10,000 TokenB.

Then, calculate the LP tokens you will receive:
LP_Received = (5 / 100) * 1,000 = 50 LP tokens.
or LP_Received = (10,000 / 200,000) * 1,000 = 50 LP tokens.

Interpretation:

  • You contributed 5% of the pool’s assets (5/100 of TokenA, 10,000/200,000 of TokenB).

  • Therefore, you received 5% of the total LP supply (50 / (1000 + 50) ≈ 4.76%. Note the total supply becomes 1050, so your share is 50/1050≈4.76%).

  • This ensures your share is directly proportional to your contribution.

Special Cases and Considerations

  1. Mismatched Ratios: If the ratio of the two assets you deposit does not match the pool’s current ratio, the protocol will typically automatically convert the “excess” portion of one asset into the other to match the ratio, but this incurs slippage and fees. Most front-end interfaces will calculate the precise required amounts for you and prevent mismatched deposits.

  2. Impact of Fees: Trading fees are added to the pool, increasing the total value of the assets inside. This means that even if the price remains unchanged, the amount of assets represented by each LP token increases (i.e., the LP token itself appreciates). When you redeem your liquidity, you can withdraw more assets than you initially deposited. This appreciation is not immediately reflected in the number of LP tokens you hold but is realized when you redeem each LP token for a larger share of the pool.

  3. Nuances Across Protocols: While the core logic is the same, different protocols like Uniswap V2/V3, Balancer, and Curve may have slight variations in their implementation. For instance, Uniswap V3’s concentrated liquidity makes LP tokens non-fungible, leading to more complex calculations.

Summary

 
Scenario Calculation Method Core Idea
First LP LP Tokens = √(TokenA_Amount * TokenB_Amount) Sets the initial price and 100% ownership.
Subsequent LPs LP Tokens = (Your Asset Deposit / Pool's Total Asset) * Current Total LP Supply Allocates pool shares based on contribution proportion.

In simple terms, LP tokens are your “shares” in this shared capital pool. The proportion of your deposited capital relative to the total capital determines how many “shares” you get from the total. When you remove liquidity, you redeem a proportional share of both assets from the pool based on the number of LP tokens you hold relative to the total supply.

本文由PandaAcademy原创,如若转载,请注明出处:https://academy.pandatool.org/en_US/kn/2102

。PandaAcademy是PandaTool旗下的Web3学习中心,专注于向普通用户提供区块链和加密货币知识输出
Like (0)
pandatool's avatarpandatool
Previous 2025年10月23日 19:34
Next 2025年4月19日 16:40

相关推荐