project-serum / serum-js

JavaScript client library for interacting with the Project Serum DEX.
82 stars 33 forks source link

Fill event price logic #22

Closed thaaddeus closed 4 years ago

thaaddeus commented 4 years ago

In market.ts there is a quite a bit of logic that retrieves the price from an event https://github.com/project-serum/serum-js/blob/c4ec583a678bd387bdb5c1887ebd8d5a5c454982/src/market.ts#L521 is it basically equivalent to priceLotsToNumber(event.orderId.ushrn(64)) or we should not rely on order id encoding to retrieve the order price? I'm asking as already using that logic to retreive price for request queue items and not 100% sure if that is correct or not.

...also is it necessary to check event.nativeQuantityPaid.gtn(0) at https://github.com/project-serum/serum-js/blob/c4ec583a678bd387bdb5c1887ebd8d5a5c454982/src/market.ts#L509 can there be a fill that has nativeQuantityPaid set to 0? Thanks

thaaddeus commented 4 years ago

I think I got it now regarding price, as price encoded in order id can be different from price that order has been filled.