brian-terraVertex - Monthly Stats copy
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
›
⌄
-- forked from Vertex - Monthly Stats @ https://flipsidecrypto.xyz/edit/queries/f5569d41-4c99-4462-90f8-7567d9400030
-- forked from Vertex - Daily Stats @ https://flipsidecrypto.xyz/edit/queries/c4a68ed6-3525-4c92-983c-b1b3b13619e1
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 sum(total_amount_both) from
(SELECT date_trunc('month', block_timestamp) AS month,
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,
QueryRunArchived: QueryRun has been archived