The Quote channel is where ALL quotes (limit orders) and state changes to the orderbook can be found. Additionally, quotes from an RFQ request can also be retrieved here.
Filter Message (Quotes)
All channels require a filter message prior to streaming. Filter messages will define what data is streamed along with activating the stream itself. There are several parameters that can be used to refine the stream.
chainId (Required) : Designate whether the stream is for a production chain or testnet chain
poolAddress (Optional): filter by specific option market
side (Optional): filter by either bid only or ask only
size (Optional): filter by minimum size
The size parameter must be represented in a string that is in 10^18 format. For example, if the filter for size is mean to be 2, then value here must be '2000000000000000000'.
provider (Optional): filter by quote providers
taker (Optional):filter by taker address is IMPORTANT for RFQ network users. There are 3 ways to configure this:
omit: if this filter param is omitted, then only public quotes will stream. If there is no intention of using the RFQ network, omit this filter.
address: if the intention is to use the RFQ network to request quotes, populate this field with the wallet address of the requester to see all relevant PostQuote messages from quote providers
* -> if the intention is to use the RFQ network to provide/request quotes, populate this field with a star to see all relevant FillQuote messages.
/*TypeScript Sample CodeNOTE: since this is an API, WS logic can be written in any language. This exampleis in typescript, but the overall sequence will be the same for any language.*/import { RawData, WebSocket } from'ws'// Example if Containerized API runtime is localconsturl=`ws://localhost:${process.env.HTTP_PORT}`constwsConnection=newWebSocket(url)constMOCK_API_KEY='3423ee2bfd89491f82b351404'constauthMessage:AuthMessage= { type:'AUTH', apiKey:MOCK_API_KEY, body:null}// send AuthMessagewsConnection.send(JSON.stringify(authMsg))/*This filter message will listen to all PUBLIC quote and will additionallyreceive PRIVATE quotes from the RFQ network.*/constwebSocketFilter:FilterMessage= { type:'FILTER', channel:'QUOTES', body: { chainId:'42161', taker:'0x170f9e3eb81ed29491a2efdcfa2edd34fdd24a71'// mock address }}// handle message ingestion from wsconstwsCallback= (data:RawData) => {constmessage:InfoMessage|PostQuoteMessage|FillQuoteMessage|DeleteQuoteMessage=JSON.parse(data.toString())switch (message.type) {case'INFO': {// auth result message will arrive herebreak }case'POST_QUOTE': {// new quotes will arrive herebreak }case'FILL_QUOTE': {// filled quotes will arrive herebreak }case'DELETE_QUOTE': {// cancelled quotes will arrive herebreak }case'ERROR': {// any error message will arrive herebreak }// throw error if case not covereddefault: {throw`Unexpected message type ${message.type}` } }}// subscribe to WS messageswsConnection.on('message', wsCallback)// send FilterMessage to start getting quotes streamwsConnection.send(JSON.stringify(webSocketFilter))// unsubscribe to WS messages// NOTE: unsubscribing does NOT close the ws connectionconstunsubscribeMsg:WSUnsubscribeMessage= { type:'UNSUBSCRIBE', channel:'QUOTES', body:null,}wsConnection.send(JSON.stringify(unsubscribeMsg))