Tony_Intel2023-05-24 01:39 PM
Updated 2023-05-24
999
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 arbitrum as (
select *, 'Arbitrum' as blockchain
from (
select
case when len(input_data) = 970 then 'Borrow'
when len(input_data) = 1034 then 'Withdraw' end as action,
case when len(input_data) = 970 then 'Borrower'
when len(input_data) = 1034 then 'Withdrawer' end as user_activity,
symbol,
date_trunc('day', y.block_timestamp) as date,
sum(raw_amount/pow(10, decimals)) as amount,
count(distinct y.to_address) as user_count,
count(distinct y.tx_hash) as tx_count
from arbitrum.core.fact_token_transfers y
join arbitrum.core.fact_transactions x
on x.tx_hash = y.tx_hash
join arbitrum.core.dim_contracts t
on y.contract_address = t.address
where y.origin_function_signature = '0x49160658' and y.ORIGIN_TO_ADDRESS = '0xbe54bafc56b468d4d20d609f0cf17ffc56b99913'
group by 1, 2, 3, 4
union all
select
case when origin_function_signature = '0x3bc1f1ed' then 'Deposit'
when origin_function_signature = '0x0020311b' then 'Repay' end as action,
case when origin_function_signature = '0x3bc1f1ed' then 'Depositor'
when origin_function_signature = '0x0020311b' then 'Repayer' end as user_activity,
symbol,
date_trunc('day', x.block_timestamp) as date,
sum(raw_amount/pow(10, decimals)) as amount,
count(distinct x.from_address) as user_count,
count(distinct tx_hash) as tx_count
from arbitrum.core.fact_token_transfers x
join arbitrum.core.dim_contracts t
on x.contract_address = t.address
Run a query to Download Data