I have a couple of questions of fees in UniSwap v2 (update: please note I read the whitepaper as well as the source code)
- When someone swaps, the output token they should get is calculated according to 99.7% of the input token they provided. However, when doing the math for providers as they add and remove liquidity, it doesn's seem like they get the right proportion of the fee. E.g. if three providers add 100,000 and 1,000 of tokens and then two users swap one 1000 of the second token and the other 75056 of the first, it seems that 225 and 3 tokens were collected as fee, but if one of the providers removes their liquidity, they get just 18 and 0.751 tokens above what they put in.
- it is said that the fees that were collected as percentage of the liquidity can be defined as 1 - sqrt(k1)/sqrt(k2). Can someone explain the logic?