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

calling setPosition can cause the price to move outside of the current tick #96

Closed
NoahZinsmeister opened this issue Oct 23, 2020 · 0 comments

Comments

@NoahZinsmeister
Copy link
Contributor

NoahZinsmeister commented Oct 23, 2020

specifically, setPosition can involve up to 3 calls to updateReservesAndVirtualSupply, which is responsible for updating reserves. it can be the case that it is impossible to add or remove reserves at the exact ratio of the current price, meaning that the price (reserve1Virtual/reserve0Virtual) changes. If liquidity is being added, the price can increase, if liquidity is being removed, the price can decrease. this is shown by assert statements in the code. so:

  1. ideally, we would be able to formally prove that these asserts can never be reached, and remove them from the deployed bytecode

  2. if the price ever moves outside of the current tick, this poses a problem, as we only want to run the tick transition logic for swaps. right now, this case is prevented by require statements in the code, though of course this is less than ideal

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

1 participant