uniswap – How Uniswap Distributes Fees Equally Considering Proportion and Duration Pooled

decentralized-exchangedefiexchangesliquidity-provideruniswap

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:

s_minted=sqrt(x_deposited*y_deposited) #1

Where s represents the liquidity pool tokens. And for later LPs is:

s_minted=(x_deposited/x_latest)*s_latest #2

So as an example say the initial LP deposits 1x and 100y, which corresponds to 10 s minted to his name as per #1. Now say a trader buys 20y with 0.25*(1+0.0003)x where 0.0003 is the 0.3% swap fee. The new x:y reserves are 1+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 from 1*100=100 to 1.250075*80=100.006. Now say another LP comes along and adds liquidity at l times the current reserves, where l > 0, say l=2.0 which corresponds to 2.50015:160 being added to the pool, resulting in the pools new reserves of 1.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 his 20 liquidity pool tokens before any further trades&fees are made he would get his share of the reserves:

reserve_share=(s_owned/s_total) * reserve_total #3

which for reserve x works out to (20/30)*3.750225 = 2.50015 and for reserve y 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.

Related Topic