AMLBotCEX flow
Updated 2023-09-20
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 cex_address as
(
select address, label from {{blockchain}}.core.dim_labels
where label_type='cex'
),
cex_outflow as(
select date_trunc('day', block_timestamp) day,
label,
count(distinct tx_hash) as outflow_tx,
count(distinct from_address) as outflow_unique_users,
sum(raw_amount/power(10, decimals)) as outflow_volume_usd
from {{blockchain}}.core.fact_token_transfers transfers
left join {{blockchain}}.core.dim_contracts contracts
on transfers.contract_address = contracts.address
join cex_address
on transfers.from_address = cex_address.address
where contract_address = lower('{{token_address}}')
and block_timestamp::date >= current_date - {{days_back}}
group by day, label
order by day, label
),
-- sending the asset to cex
cex_inflow as(
select date_trunc('day', block_timestamp) day,
label,
count(distinct tx_hash) as inflow_tx,
count(distinct to_address) as inflow_unique_users,
sum(raw_amount/power(10, decimals)) as inflow_volume_usd
from {{blockchain}}.core.fact_token_transfers transfers
left join {{blockchain}}.core.dim_contracts contracts
on transfers.contract_address = contracts.address
join cex_address
on transfers.to_address = cex_address.address
where contract_address = lower('{{token_address}}')
and block_timestamp::date >= current_date - {{days_back}}
group by day, label
Run a query to Download Data