Afonso_Diaz2023-06-08 10:46 PM
Updated 2023-06-08
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 t as (
select
project_name as cex,
address
from near.core.dim_address_labels
where label_type = 'cex'
group by 1, 2
),
t2 as (
select
try_parse_json(replace (logs[0], 'EVENT_JSON:', '')) as data,
tx_hash,
block_timestamp,
data:data[0]:old_owner_id as signer,
data:data[0]:new_owner_id as receiver,
data:data[0]:amount/1e6 as amount_usd
from near.core.fact_receipts
where receiver_id = 'usdt.tether-token.near'
and data:event = 'ft_transfer'
),
t3 as (
select
tx_hash,
block_timestamp,
iff(receiver = address, 'Inflow', 'Outflow') as direction,
cex,
iff(direction = 'Inflow', signer, receiver) as user,
amount_usd
from t2
join t on address in (signer, receiver)
)
select
direction,
Run a query to Download Data