KuramaSommelier - ETH-BTC-Trend Uniswap Holdings
Updated 2022-11-06Copy Reference Fork
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
›
⌄
with table_0 as (select distinct tx_hash from ethereum.core.fact_token_transfers
where from_address = '0x953c953755ddbb61a6c116f2219508f838b3219b' or to_address = '0x953c953755ddbb61a6c116f2219508f838b3219b'),
table_1 as (
select date_trunc('hour',block_timestamp) as date, tx_hash, case when contract_address = '0x6b7f87279982d919bbf85182ddeab179b366d8f2' then 'Eth-Btc Trend' else 'USDC' end as currency,
case when contract_address = '0x6b7f87279982d919bbf85182ddeab179b366d8f2' then raw_amount/pow(10,18) else raw_amount/pow(10, b.decimals) end as amount_currency,
case when to_address = origin_from_address then 'Amount Out'
else 'Amount In' end as in_out,
case when in_out = 'Amount Out' then amount_currency*(-1) else amount_currency end as amount_currency_sign
from ethereum.core.fact_token_transfers a
left join (select distinct symbol, token_address, decimals from ethereum.core.fact_hourly_token_prices
) b
on a.contract_address = b.token_address
where tx_hash in (select * from table_0)
and (from_address = origin_from_address or to_address = origin_from_address or (from_address = origin_to_address and to_address = '0x953c953755ddbb61a6c116f2219508f838b3219b') )
)
select currency, sum(amount_currency_sign) from table_1
group by 1
Run a query to Download Data