ArioMK-Swap Volume by Tokens
Updated 2023-09-15
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 price as (
select
date_trunc(day, HOUR) as day,
SYMBOL,
avg(PRICE) as avg_price
from base.price.ez_hourly_token_prices
where SYMBOL in ('DAI', 'USDbC', 'cbETH')
group by 1,2
union all
select
date_trunc(day, HOUR) as day,
SYMBOL,
avg(PRICE) as avg_price
from ethereum.price.ez_hourly_token_prices
where SYMBOL in ('WETH', 'MAV')
group by 1,2
)
select
date_trunc(day, BLOCK_TIMESTAMP) as date
,concat(SYMBOL_IN, '→', SYMBOL_OUT) as "Swap Pair"
,count(distinct TX_HASH) as "Swap Count"
,sum(
case
when AMOUNT_IN_USD is not null then AMOUNT_IN_USD
when AMOUNT_IN_USD is null
and AMOUNT_OUT_USD is not null then AMOUNT_OUT_USD
else (AMOUNT_IN * avg_price)
end
) as "Swap Volume"
from base.defi.ez_dex_swaps
join price b on symbol_in = symbol and date_trunc(day, block_timestamp) = b.day
where
platform = 'maverick'
and block_timestamp::date >= '2023-08-09'
Run a query to Download Data