fix: mark twaps as completed - #4
Merged
Merged
Conversation
yvesfracari
reviewed
Sep 7, 2026
yvesfracari
left a comment
There was a problem hiding this comment.
Most of the code looks good to me, just double confirm that logic is reorg friendly.
Comment on lines
+107
to
+112
| const isComplete = | ||
| generator.status === "Active" && | ||
| generator.allCandidatesKnown && | ||
| aggregate != null && | ||
| aggregate.partCount > 0 && | ||
| aggregate.openPartCount === 0 && |
There was a problem hiding this comment.
If I understood correctly, a child can be changed back to open on reorgs. In that case, I don't see any handler that will change the parent back to incomplete.
Danziger
reviewed
Sep 8, 2026
| ((aggregate?.openPartCount ?? 0) > 0 || | ||
| candidateGeneratorIds.has(generator.eventId)); | ||
|
|
||
| await context.db |
There was a problem hiding this comment.
It would be better to collect the individual updates and send them together using db.batch: https://orm.drizzle.team/docs/batch-api, rather than awaiting inside the loop.
Collaborator
Author
There was a problem hiding this comment.
There is no batch on this object https://ponder.sh/docs/indexing/write#store-api
Danziger
approved these changes
Sep 8, 2026
Danziger
left a comment
There was a problem hiding this comment.
One comment, but approving already.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The indexer updates each TWAP part when its order status changes. However, it did not update the parent after the final part became terminal.
For example, parent 0x20d0260a39328b530d4644dc07718409ad294f6afdb8970d63b63275cedab1a5 remained
Activeafter both parts becamefulfilled.The indexer only detected parent completion during initial discovery. Therefore, TWAP orders that settled later remained
Active.Changes
Completedwhen:How to Test
0x20d0260a39328b530d4644dc07718409ad294f6afdb8970d63b63275cedab1a5.Completed.Active.Completed.Checklist