DEX metrics
This article describes mandatory metrics for crypto DEX spot symbols and the rules on how to send them to Kafka topic. Topic will be created on the TradingView side. All questions about Kafka access organization will be discussed during the integration process.
Message flow
We expect messages for spot symbols that are provided in /symbol_info.
When new symbol is listed and available in /symbol_info response, we expect to start receiving messages for it.
If symbol is no longer present in /symbol_info response, we expect a message
with corresponding key and null value. No messages for delisted symbols are
expected afterwards.
Messages have to be formed according to the following rules:
- when transaction occurs messages with updated metrics for all resolutions have to be sent
- after the transaction in time intervals corresponding to the resolution (i.e.
1 hour after the transaction for
1hmetrics) follow-up messages have to be sent with adjusted metrics - when there is no transaction for more than 24 hours then periodic messages have to be sent in 24 hours intervals from the time of the last transaction with all transactional metrics set to zero and updated quasi-static metrics
Delay up to 30 seconds is acceptable for purposes of sending several messages in a batch.
Data
Format of the message is as follows:
key: symbol_info.ticker
value: metrics as JSON
Expected metrics are specified in the following tables.
Metrics with resolutions
| Metric | Type | Description |
|---|---|---|
buy_volume_<res> | Number | Byes volume in USD during period |
buyers_<res> | Number | Number of unique byers during period |
buys_<res> | Number | Number of buy transactions during the period |
sell_volume_<res> | Number | Sells volume USD during period |
sellers_<res> | Number | Number of unique sellers during period |
sells_<res> | Number | Number of sell transaction during the period |
trades_volume_<res> | Number | Transaction volume USD during period |
txs_count_<res> | Number | Number of transaction during the period |
txs_count_uniq_<res> | Number | Number of unique addresses (makers), which acted in transaction during the period |
where <res> corresponds to the following expected resolutions:
15m1h4h12h24h
Quasi-static metrics
On pair (pool)
| Metric | Type | Description |
|---|---|---|
created_time | Number | Unix timestamp of pool creation |
total_liquidity | Number | Total liquidity of pool in USD |
On token
These metrics are provided for each token in a pool with prefixes token0 and
token1.
| Metric | Type | Description |
|---|---|---|
token0_liquiditytoken1_liquidity | Number | Current liquidity in USD for each token in pool |
token0_supplytoken1_supply | Number | Current supply for each token in pool |
The following assumptions are made on all of the received messages:
trades_volume_<res>=buy_volume_<res>+sell_volume_<res>txs_count_<res>=buys_<res>+sells_<res>txs_count_uniq_<res><=buyers_<res>+sellers_<res>total_liquidity=token0_liquidity+token1_liquidity- transaction value for greater resolutions can't be more than value of a lesser resolution
Example
Key: bsc:0x47a90A2d92A8367A91EfA1906bFc8c1E05bf10c4-USD
Value:
{
"buy_volume_5m": 3876,
"buy_volume_1h": 3876,
"buy_volume_4h": 12766,
"buy_volume_12h": 23291,
"buy_volume_24h": 41221,
"buyers_5m": 1,
"buyers_1h": 1,
"buyers_4h": 2,
"buyers_12h": 4,
"buyers_24h": 8,
"buys_5m": 1,
"buys_1h": 1,
"buys_4h": 2,
"buys_12h": 4,
"buys_24h": 8,
"sell_volume_5m": 0,
"sell_volume_1h": 2344,
"sell_volume_4h": 2344,
"sell_volume_12h": 2344,
"sell_volume_24h": 2344,
"sellers_5m": 0,
"sellers_1h": 1,
"sellers_4h": 1,
"sellers_12h": 1,
"sellers_24h": 1,
"sells_5m": 0,
"sells_1h": 1,
"sells_4h": 1,
"sells_12h": 1,
"sells_24h": 1,
"trades_volume_5m": 3876,
"trades_volume_1h": 6220,
"trades_volume_4h": 15110,
"trades_volume_12h": 25635,
"trades_volume_24h": 43565,
"txs_count_5m": 1,
"txs_count_1h": 2,
"txs_count_4h": 3,
"txs_count_12h": 5,
"txs_count_24h": 9,
"txs_count_uniq_5m": 1,
"txs_count_uniq_1h": 2,
"txs_count_uniq_4h": 3,
"txs_count_uniq_12h": 5,
"txs_count_uniq_24h": 9,
"created_time": 1702313167,
"total_liquidity": 4756583.9,
"token0_liquidity": 2378291.95,
"token0_supply": 1990010200000,
"token1_liquidity": 2378291.95,
"token1_supply": 1990010200000
}