brian-terraVertex - Daily Stats
Updated 2024-03-11
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
›
⌄
WITH qMain as (
SELECT DISTINCT
block_timestamp,
tx_hash,
contract_address,
symbol,
trader,
amount_usd,
fee_amount,
'perp' AS label
FROM arbitrum.vertex.ez_perp_trades
UNION ALL
SELECT DISTINCT
block_timestamp,
tx_hash,
contract_address,
symbol,
trader,
amount_usd,
fee_amount,
'spot' AS label
FROM arbitrum.vertex.ez_spot_trades
)
SELECT date_trunc('day', block_timestamp) AS day,
COUNT(DISTINCT CASE WHEN label = 'spot' THEN trader END) AS distinct_spot_traders,
COUNT(DISTINCT CASE WHEN label = 'perp' THEN trader END) AS distinct_perp_traders,
COUNT(DISTINCT trader) AS distinct_total_traders,
COUNT(DISTINCT CASE WHEN label = 'spot' THEN tx_hash END) AS distinct_spot_txns,
COUNT(DISTINCT CASE WHEN label = 'perp' THEN tx_hash END) AS distinct_perp_txns,
COUNT(DISTINCT tx_hash) AS distinct_total_txns,
SUM(CASE WHEN label = 'spot' THEN amount_usd ELSE 0 END) AS total_amount_spot,
SUM(CASE WHEN label = 'perp' THEN amount_usd ELSE 0 END) AS total_amount_perp,
SUM(amount_usd) AS total_amount_both
QueryRunArchived: QueryRun has been archived