[Ethereum] How to calculate the number of tokens owned by the liquidity pool via bonding curve on Uniswap

bonding-curvestokensuniswap

I know a little bit about the Uniswap, providing liquidity, bonding curves…

But I'm still struggling to perform the actual math – what is the actual formula?

Real-life example (easier to operate on real numbers)

enter image description here

Situation

Round numbers:

  • 300 ETH
  • 300k GET

Say I'm a whale and I add 60 ETH and 60k GET to the bonding curve.

The bonding curve now:

  • 360 ETH
  • 360k GET

I have 20% of the liquidity pool.

Calculation

What will happen in cases 1 and 2?

  1. Someone sends 10 ETH into the bonding curve?

  2. Someone sends 10k GET into the bonding curve?

My understanding is that I will still own 20% of the liquidity pool but what about the actual numbers of ETH and GET?

Best Answer

As a liquidity provider, you cannot send money on either side of the pool, they need to be added in the same proportions.

However, someone is free to buy ETH/GET or buy GET/ETH from the pool. In this case the number of tokens left in the pool changes and the price moves using the following formula:

ETH/GET price before = 360/360k = 1000

For the case (1): bought 1000 GET with 10 ETH

ETH/GET new price = 350k/370 = 945

For the sake of simplification, I left of liquidity provider fees from the calculations.

Related Topic