Tony_Intel2023-05-20 06:30 PM
Updated 2023-05-21
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
›
⌄
select
case when len(input_data) = 970 then 'Borrow'
when len(input_data) = 1034 then 'Withdraw' end as action,
symbol,
date_trunc('day', y.block_timestamp) as date,
sum(raw_amount/pow(10, decimals)) as amount
from avalanche.core.fact_token_transfers y
join avalanche.core.fact_transactions x
on x.tx_hash = y.tx_hash
join avalanche.core.dim_contracts t
on y.contract_address = t.address
where y.origin_function_signature = '0x49160658' and y.ORIGIN_TO_ADDRESS = '0x0cd070285380cabfc3be55176928dc8a55e6d2a7'
group by 1, 2, 3
union all
select
case when origin_function_signature = '0x3bc1f1ed' then 'Deposit'
when origin_function_signature = '0x0020311b' then 'Repay' end as action,
symbol,
date_trunc('day', x.block_timestamp) as date,
sum(raw_amount/pow(10, decimals)) as amount
from avalanche.core.fact_token_transfers x
join avalanche.core.dim_contracts t
on x.contract_address = t.address
where origin_to_address = lower('0x1f9bD6986D0cDCde9fbBe87D142f3Dc4DdcA1Fd9') and origin_function_signature in ('0x3bc1f1ed', '0x0020311b')
group by 1, 2, 3
union all
select
'Deposit' as action,
symbol,
date_trunc('day', x.block_timestamp) as date,
sum(raw_amount/pow(10, decimals)) as amount
from avalanche.core.fact_token_transfers x
Run a query to Download Data