A similar question has already been asked, however a satisfactory answer has not yet been provided. The Uniswap V2 Pools docs states:
If the provider is minting a new pool, the number of liquidity tokens they will receive will equal sqrt(x * y)
But it doesn't state how many liquidity pool tokens later liquidity providers(LPs) receive, in my mind it wouldn't make sense for later LPs to receive pool tokens in accordance with that formula as it doesn't factor in the point in time an LP joined the pool and so they shouldn't enjoy a stake in fees generated prior to their joining.
Could someone please explain or direct me to a resource that explains how fees on Uniswap are distributed in an equitable manner?
Best Answer
So after a bit of research I found the answer. Based on Section 3.4 of the Uniswap V2 Whitepaper the initial liquidity pool tokens minted for the initial liquidity provider(LP) is:
Where
s
represents the liquidity pool tokens. And for later LPs is:So as an example say the initial LP deposits
1x
and100y
, which corresponds to 10s
minted to his name as per #1. Now say a trader buys20y
with0.25*(1+0.0003)x
where0.0003
is the0.3%
swap fee. The newx:y
reserves are1+0.25+0.000075:100-20 = 1.250075:80
. The additional reserve from the swap fee being added to the pool results in an increase to the constant product from1*100=100
to1.250075*80=100.006
. Now say another LP comes along and adds liquidity atl
times the current reserves, wherel > 0
, sayl=2.0
which corresponds to2.50015:160
being added to the pool, resulting in the pools new reserves of1.250075+2.50015:80+160 = 3.750225:240
, as per #2 the new LP receives(2.50015/1.250075) * 10 = 20s
. Now if this LP were to immediately pull out/withdraw his reserves by burning his20
liquidity pool tokens before any further trades&fees are made he would get his share of the reserves:which for reserve
x
works out to(20/30)*3.750225 = 2.50015
and for reservey
works out to(20/30)*240 = 160
, which is exactly equal to the amount he initially added to the pool, meaning he did not derive any value from the fees generated prior to his liquidity provision. But if he were to keep his LP position future trading fees will now be weighted based on current reserves and so on and so forth for other LPs who can add or withdraw liquidity to pools at any time.