Subscribes to Decentralized exchange market Liquidity updates, optionally filtered by exchange or pair.
Protocols Supported
This subscription only supports Uniswap v2, Uniswap v3, Sushiswap and Uniswap clones.
Blockchains Supported
This subscription only supports data on
ethereum-mainnet
.
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" } ]
}
Param | Type | Description |
---|---|---|
pair | string | The asset pair by which to filter. DEX pairs are most accurate using pair contract address rather than symbols (OPTIONAL) |
exchange | string | The 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"
}
Field | Type | Description |
---|---|---|
exchange | string | The exchange contract address. |
timestamp | number | The time at which the trade took place. |
pair | string | The 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));
});