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

Potential Tick Duplication In extract_pool_events_and_positions module #15

Open
steegecs opened this issue Apr 25, 2023 · 5 comments
Open

Comments

@steegecs
Copy link

In viewing the extract_pool_events_and_positions function in the filtering.rs file used by the extract_pool_events_and_positions module, it looks like you might end up creating the same tick more than once. This is because of the or logic for creating both ticks. From my understanding, it is possible that only one of the ticks already exists, so you should run separate conditions for each tick to trigger the new tick creation.

The scenario I am thinking of is there is a new pool, and the first two deposits are as follows:

  • User 1 deposits $100 on tick 10 to 15
  • User 2 deposits $100 on tick 10 to 20

When the user makes two deposits, tick 10 already exists, but tick 20 does not. So you would only acknowledge that a new tick was created for tick 20.

Screenshot 2023-04-25 at 12 12 40 PM

@steegecs
Copy link
Author

Maybe something like this?

Screenshot 2023-04-25 at 12 28 25 PM

@maoueh
Copy link
Contributor

maoueh commented May 11, 2023

@Eduard-Voiculescu
Copy link
Collaborator

Hey @steegecs, so we actually removed the create_upper_tick and create_lower_tick because we had some issues on detecting when a tick was actually created.

We found that the contract emits a initialize storage change on the contract for a given pool: https://github.com/Uniswap/v3-core/blob/main/contracts/libraries/Tick.sol#L36

But interestingly, a pool has their ticks which will move a little bit depending on the added and removed liquidity in it. So this makes it that we would sometimes miss some ticks as their had already been initialized.

So the if create_lower_tick or create_upper_tick would be false, we would miss some ticks. Hence why whenever we get a mint we just check the prices_from_tick_index.

@abourget
Copy link
Contributor

Was this resolved? Can we close this?

@Eduard-Voiculescu
Copy link
Collaborator

@steegecs Do you need any more clarification?

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

4 participants