AMLBotDEX activity pie
Updated 2024-06-13Copy Reference Fork
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 DEX activity @ https://flipsidecrypto.xyz/edit/queries/08e92905-8b01-4f85-9525-cbef0359b303
with raw_tx as(
select
block_timestamp::date day,
tx_hash,
token_in,
amount_in_usd,
token_out,
amount_out_usd
from {{blockchain}}.defi.ez_dex_swaps
where block_timestamp::date >= current_date - {{days_back}}
and (
token_in = lower('{{token_address}}')
or token_out = lower('{{token_address}}'))
),
sell as (
select
day,
'Sell' type,
sum(case
when token_in = lower('{{token_address}}') then amount_in_usd
end) volume
from raw_tx
group by day
),
buy as(
select
day,
'Buy' type,
sum(case
when token_out = lower('{{token_address}}') then amount_out_usd
end) volume
from raw_tx
group by day
)
QueryRunArchived: QueryRun has been archived