drone-mostafacax out
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
Transfer_T AS ( SELECT
tx_hash,
block_timestamp,
try_parse_json(replace(logs[0]::string, 'EVENT_JSON:', '')) AS EVENTs,
EVENTs['event']::string AS Method,
receiver_id AS Token
FROM near.core.fact_receipts
WHERE receiver_id in ('usdt.tether-token.near','dac17f958d2ee523a2206206994597c13d831ec7.factory.bridge.near')
AND object_keys(status_value)[0]::string != 'Failure'
AND Method = 'ft_transfer'
AND block_timestamp >= CURRENT_DATE - 30 ),
final as (SELECT
tx_hash,
block_timestamp,
EVENTs,
Method,
value['old_owner_id']::string AS Sender,
value['new_owner_id']::string AS Receiver,
try_cast(value['amount']::string AS bigint) / 1e6 AS Amount,
Token
FROM Transfer_T, LATERAL FLATTEN(EVENTs['data'])
)
SELECT
PROJECT_NAME,Token,
count (DISTINCT t1.TX_HASH) as txn,
count (DISTINCT t1.Receiver) as Receiver,
sum (Amount) as Volume
FROM final t1
LEFT JOIN near.core.dim_address_labels on ADDRESS = Sender
WHERE LABEL_TYPE = 'cex'
GROUP BY 1,2
Run a query to Download Data