Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does this formula really work? #1

Open
pememoni opened this issue May 22, 2022 · 4 comments
Open

Does this formula really work? #1

pememoni opened this issue May 22, 2022 · 4 comments

Comments

@pememoni
Copy link

I think you have assumed that K is constant; while in practice, Uniswap applies a 0.30% fee to trades, which is added to reserves. As a result, each trade actually increases k. So if we want to use this formula a) we should know the K exactly before the execution of our transaction which is not possible as we don't have control on the previous transaction even if we bribe the miner to execute it in a higher-order b) we should compute the new K after our front-running tx and affect it for the original transaction. Am I right?

@yoongyy
Copy link

yoongyy commented Jun 7, 2022

What is K actually?

@knkrth
Copy link

knkrth commented Nov 11, 2022

Does fee represent network fee or Transaction fee from the mempool?

@goheesheng
Copy link

How much profit did you guys get?

@jeanbmar
Copy link

jeanbmar commented Aug 12, 2024

@pememoni Absolutely correct, this repo wrongly assumes the same k for the frontrun tx and the sandwiched tx. Indeed, k remains constant within a single swap only, because of the liquidity provider fees.

To verify this claim, take the following lp parameters:

rIn = 27925138973299724
rOut = 8992401273670500100800
feeFactor = 9975
feePrecision = 10000
targetAmountIn = 2000000000000000
targetMinAmountOut = 366371816369992062049

Calling worstReserves using these params will return an optimal frontrun amountIn of 8069026577219367.
However, 8079399535895272 is a more optimal frontrun amountIn that satisfies the targetMinAmountOut requirement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants