this example subscribes to SOL perp market on-chain events for bids, asks and fill.
following info is logged at each update of each orderbook as well as fill event:
latest trade
bid-ask values
midprice
spread in bps
market depth at +/-2%
note: in case no fill event received before an orderbook update, the latest trade will be empty. maybe there is a way to get the last traded price, in that case we can add that in future.
additions:
a wssSubscriber class, which can be/is reused to subscribe to given uri. callbacks can be registered by its clients to handle the incoming wss messages.
a bookSide class, which uses wssSubscriber to subscribe to bids and asks and offers its clients interfaces to get best prices and volume. additionaly it can notify the clients on each update via a callback.
an orderbook class which contains two bookSide instances representing bids and asks and offers its clients an interface to get the level1 info.
a trades class, which uses wssSubscriber to subscribe to market event queue and offers its clients interfaces to get last traded price. additionaly it can notify the clients on each update via a callback.
a level1 and order structs
minor improvements:
const correctness at solana api
added todo to use scoped enums at existing mango code, didnt change it here as this might requires changes in other examples as well.
this example subscribes to SOL perp market on-chain events for bids, asks and fill. following info is logged at each update of each orderbook as well as fill event:
note: in case no fill event received before an orderbook update, the latest trade will be empty. maybe there is a way to get the last traded price, in that case we can add that in future.
additions:
minor improvements: