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:
Populates the seqNum on the Event type in decodeEventQueue
Implements a new function loadFillsSince
Why
It appears based on git blame that seqNum was added after decodeEventQueue, and decodeEventQueue 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 a Fill without it.
I also implemented an additional loadFillsSince API function, since there is already functionality to decodeEventsSince, and I think it would useful to be able to loadFillsSince a given seqNum
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
: