-
Notifications
You must be signed in to change notification settings - Fork 10
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
Handle reverts of trades #26
Comments
So trade reversions are tricky to handle. The main factor is that mappings don't have access to In order to get around this, we will take advantage that all trade events are emitted immediately before a solution submission event. This means that we just need to keep track of the number of trades in a solution and we can deterministically reconstruct a trade ID given a solution and the trade index. Additionally, I noticed that prices and solution data was being computed by an The plan for fully implementing this is:
|
Thanks for coming up with a game plan ♟️
Do we know if there are any issues with renaming IDs after initial creation? I could imaging that GraphQL subscriptions might behave weirdly if we change IDs under the hood. How about getting the solution ID from the batch object? Lines 198 to 205 in 00dccfa
This way, whenever we get a TradeReversion event we could:
Generally I agree that price computation should happen onSolutionSubmission but that seems like a separate task. |
The issue is that the first trade does not know what solution ID to use, as the
Good question. One thing to note is that all of these events get processed in a single block, not sure if this makes a difference or not for subscriptions. Maybe we can create a
This also works. I just naively imagined that each
The reason its related is that |
We do create the solution ID as the dex-subgraph/src/mappings/batch.ts Lines 5 to 18 in 00dccfa
Do you think that would have to change?
Does it have to be? At the moment it's just a list so I would expect I can query all trade Ids from the entity (no need to store a count on it). Another thing I saw about the price estimation and why it might make sense to process in the trade processing is that it keeps track of cummulative volume per token (to give a sense how robust the price is). |
Reverts affect to many entities. Depending when we implement this issue, we might have more affected entities, but at least:
The text was updated successfully, but these errors were encountered: