[Serum] Populate seqNum
on Event
and implement loadFillsSince
#195
+23
−1
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.
Thank you for implementing this client library for Serum! I really appreciate the open-source efforts to make the Dex accessible, and I'd like to make my own contribution.
Description
This PR makes two changes:
seqNum
on theEvent
type indecodeEventQueue
loadFillsSince
Why
It appears based on
git blame
thatseqNum
was added afterdecodeEventQueue
, anddecodeEventQueue
was never updated.I think it would be useful to populate the
seqNum
given it is available as a field, and there isn't a way to uniquely determine whether you've processed aFill
without it.I also implemented an additional
loadFillsSince
API function, since there is already functionality todecodeEventsSince
, and I think it would useful to be able toloadFillsSince
a givenseqNum
Testing
I manually against the Serum Validator node:
https://solana-api.projectserum.com
Goal was to test that the
seqNum
is calculated correctly, being careful to make sure it handles theu32overflow
case.Here is a sample test output. Notice that head
seqNum
is26178226
,count
is4
, user-requestedlimit
is5
.Doing the logic and calculating the expected case by hand:
Header seqNum:
26178226
Count:
4
Ending seqNum:
26178226 + 4 - 1 = 26178229
Starting seqNum:
endSeqNum - limit = 26178225
The test output below correctly indicates the modified
decodeEventQueue
returns5 fill events
with theseqNum
starting from26178225
: