nitsUntitled Query
Updated 2022-05-19
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
›
⌄
with _from as (select date(block_timestamp) as day_,symbol, sum(amount_usd)*(-1) as total_amt from ethereum.udm_events
where from_label = 'maker'
group by day_, symbol ),
_to as (select date(block_timestamp) as day_,symbol, sum(amount_usd) as total_amt from ethereum.udm_events
where to_label = 'maker'
group by day_, symbol ),
collaterals as (select day_, symbol, sum(total_amt) as net_amt from (
select * from _FROM
UNION ALL
SELECT * FROM _TO)
group by day_, symbol ),
from_ as
(select tx_id,min(block_timestamp) as bl, max(amount_usd) as amt from ethereum.udm_events
where contract_address = '0x6b175474e89094c44da98b954eedeac495271d0f' and from_address = '0x0000000000000000000000000000000000000000'
group by tx_id )
,
to_ as
(select tx_id,min(block_timestamp) as bl, max(amount_usd)*(-1) as amt from ethereum.udm_events
where contract_address = '0x6b175474e89094c44da98b954eedeac495271d0f' and to_address = '0x0000000000000000000000000000000000000000'
group by tx_id )
select * from
(select day, net_vol, symbol, net_amt, case when net_amt = '0' then '0' else net_amt/net_vol*100 end as percent_impact from
(
select date(bl) as day, sum(amt) as net_vol from
(select * from from_
UNION ALL
select * from to_)
group by day )
inner join collaterals
on day = day_ )
where net_amt is not NULL
Run a query to Download Data