Quotes Channel

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:

  1. 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.

  2. 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

  3. * -> 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 Code
NOTE: since this is an API,  WS logic can be written in any language. This example
is in typescript, but the overall sequence will be the same for any language.
*/

import { RawData, WebSocket } from 'ws'

// Example if Containerized API runtime is local
const url = `ws://localhost:${process.env.HTTP_PORT}`
const wsConnection = new WebSocket(url)
const MOCK_API_KEY = '3423ee2bfd89491f82b351404'


const authMessage: AuthMessage = {
  type: 'AUTH',
  apiKey: MOCK_API_KEY,
  body: null
}

// send AuthMessage
wsConnection.send(JSON.stringify(authMsg))

/*
This filter message will listen to all PUBLIC quote and will additionally
receive PRIVATE quotes from the RFQ network.
*/

const webSocketFilter: FilterMessage = {
  type: 'FILTER',
  channel: 'QUOTES',
  body: {
    chainId: '42161',
    taker: '0x170f9e3eb81ed29491a2efdcfa2edd34fdd24a71' // mock address
  }
}

// handle message ingestion from ws
const wsCallback = (data: RawData) => {
  const message: InfoMessage | PostQuoteMessage | FillQuoteMessage | DeleteQuoteMessage = JSON.parse(data.toString())
    switch (message.type) {
        case 'INFO': {
            // auth result message will arrive here
            break
        }
        case 'POST_QUOTE': {
            // new quotes will arrive here
    	    break
        }
        case 'FILL_QUOTE': {
            // filled quotes will arrive here
    	    break
        }
        case 'DELETE_QUOTE': {
            // cancelled quotes will arrive here
    	    break
        }
        case 'ERROR': {
            // any error message will arrive here
    	    break
        }
        // throw error if case not covered
        default: {
      	    throw `Unexpected message type ${message.type}`
        }
    }
}

// subscribe to WS messages
wsConnection.on('message', wsCallback)

// send FilterMessage to start getting quotes stream
wsConnection.send(JSON.stringify(webSocketFilter))


// unsubscribe to WS messages
// NOTE: unsubscribing does NOT close the ws connection
const unsubscribeMsg: WSUnsubscribeMessage = {
    type: 'UNSUBSCRIBE',
    channel: 'QUOTES',
    body: null,
}

wsConnection.send(JSON.stringify(unsubscribeMsg))

Last updated

Terms and Disclaimers

Privacy Policy