theericstonebtc exchange flow tracking
Updated 2023-09-27
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
›
⌄
-- exchange deposits
with deposits as (
select
time_slice(block_timestamp, 30, 'MINUTE') as halfhour,
date_trunc('hour',block_timestamp) as hour,
count(distinct(tx_id)) as n_deposits,
sum(value) as amount_to_exch,
max(value) as max_dep,
median(value) as median_dep,
avg(value) as mean_dep,
mean_dep - median_dep as mean_med_delta
FROM
bitcoin.core.fact_outputs
where
block_timestamp < current_date - {{minago}} and
block_timestamp > current_date - {{maxago}} and
pubkey_script_address in (
select address from bitcoin.core.dim_labels
where label_type = 'cex')
group by 1,2
order by 1 desc
),
prices as (
select *,
price - first_value(price) OVER (ORDER by HOUR) as price_zeroed,
price - LAG(price, 1, 0) OVER (ORDER BY HOUR) AS price_diff
from crosschain.price.ez_hourly_token_prices
where blockchain = 'ethereum'
and lower(token_address) = lower('0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599')
and hour < current_date - {{minago}}
and hour > current_date - {{maxago}}
)
select
deposits.*,
Run a query to Download Data