market:dex:liquidity [ENT]

Subscribes to Decentralized exchange market Liquidity updates, optionally filtered by exchange or pair.

Make sure you're connected.

Request

All pairs:

{
  "jsonrpc" : "2.0",
  "id"      : 1,
  "method"  : "subscribe",
  "params"  : [ "market:dex:liquidity" ]
}

Specific pair or exchange:

{
  "jsonrpc" : "2.0",
  "id"      : 1,
  "method"  : "subscribe",
  "params"  : [ "market:dex:liquidity", { "exchange": "0x5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f" } ]
}
ParamTypeDescription
pairstringThe asset pair by which to filter. DEX pairs are most accurate using pair contract address rather than symbols (OPTIONAL)
exchangestringThe exchange for which to retrieve asset pairs. (OPTIONAL)

Response

"result": {
  "exchangeId":"0x1f98431c8ad98523631ae4a59f267346ea31f984",
  "pairAddress":"0x3b685307c8611afb2a9e83ebc8743dc20480716e",
  "address":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
  "timestamp":1640901195000,
  "timestampNanoseconds":0,
  "transactionHash":"0xa316d8090895649055843c2b27d165746b9368accf4854dc4b469e10487bcdd0",
  "transactionIndex":272,
  "logIndex":467,
  "amount":"3116.233560330526497885",
  "liquidityPrice":"1112.2814865261057512611"
}
FieldTypeDescription
exchangestringThe exchange contract address.
timestampnumberThe time at which the trade took place.
pairstringThe pair contract address.

Example

const WebSocket = require('ws');
const ws = new WebSocket('wss://ws.web3api.io/', {headers: {x-api-key:'<api_key>'}});

ws.on('open', () => {
  ws.send(JSON.stringify({
      jsonrpc: '2.0',
      method: 'subscribe',
      params: ['market:dex:liquidity'],
      id: 1,
    }));
});

ws.on('message', data => {
  console.log(JSON.stringify(JSON.parse(data), null, 2));
});