1

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?
2

2 Answers 2

2

You can take a look at this resource on why fees that were collected as percentage of the liquidity can be defined as 1 - sqrt(k1)/sqrt(k2) here:

Uniswap v2 whitepaper: how is formula for "total fees computed since last time fees were collected" derived?

1

I wrote a book on this exact topic going carefully through this example if interested :-)

https://www.amazon.co.uk/Automated-Market-Makers-Decentralized-Cryptocurrency/dp/1484286154/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.