Rocky_sFlow on Exchange
Updated 2023-10-24
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 wallet AS (
SELECT label AS exchange, address
FROM ethereum.core.dim_labels
WHERE label_type = 'cex'),
BAT_deposit AS (
SELECT
date_trunc('day', BLOCK_TIMESTAMP) AS time,
exchange AS exchange,
sum(et.amount) AS total_dep
FROM ethereum.core.ez_token_transfers AS et
JOIN wallet on et.TO_ADDRESS = wallet.address
WHERE BLOCK_TIMESTAMP >= DATEADD(day, -7, CURRENT_TIMESTAMP())
AND contract_address = '0x0d8775f648430679a709e98d2b0cb6250d2887ef'
AND FROM_ADDRESS NOT IN (SELECT address FROM wallet)
GROUP BY 1,2
ORDER BY time),
BAT_withdrawl AS (
SELECT
date_trunc('day', ed.BLOCK_TIMESTAMP) AS time,
exchange AS exchange,
sum(ed.amount)*-1 AS total_withd
FROM ethereum.core.ez_token_transfers AS ed
JOIN wallet AS db on ed.FROM_ADDRESS = db.address
WHERE ed.BLOCK_TIMESTAMP >= DATEADD(day, -7, CURRENT_TIMESTAMP())
AND ed.contract_address = '0x0d8775f648430679a709e98d2b0cb6250d2887ef'
AND ed.TO_ADDRESS NOT IN (SELECT address FROM wallet)
GROUP BY 1,2
ORDER BY time)
SELECT
pd.time AS time,
sum(pd.total_dep) AS BAT_deposit,
sum(pw.total_withd) AS BAT_withdrawl
FROM BAT_deposit AS pd
Run a query to Download Data