Sbhn_NPmagic-yellow
Updated 2025-01-14
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 price as (
select
hour::date as datee,
token_address,
avg(price) usdprice
from crosschain.price.ez_prices_hourly
where token_address in (
'0xf1815bd50389c46847f0bda824ec8da914045d14',
'0x4200000000000000000000000000000000000006',
'0xca5f2ccbd9c40b32657df57c716de44237f80f05')
and symbol in ('WETH','USDC.E','KRAKEN')
group by 1,2),
tab_last as (
select origin_from_address,
sum(case when symbol = 'WETH' then (raw_amount_precise/pow(10,18))*usdprice
when symbol = 'Kraken' then (raw_amount_precise/pow(10,18))*usdprice
else (raw_amount_precise/pow(10,6))*usdprice end) as amount_usd
from ink.core.ez_token_transfers a
join ink.core.fact_event_logs b using(tx_hash)
left join price on block_timestamp::date=datee and token_address=a.contract_address
where topic_0 = '0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822'
and concat('0x', right(topics[1],40)) = '0x9b17690de96fcfa80a3acaefe11d936629cd7a77'
and b.contract_address in ('0x73a09cd53871b2ac4f5e08b89eb2e25e1959d92a','0x7e16bb931c222e47597fa745abcc03098e1ebcf6')
and a.contract_address in (
'0xf1815bd50389c46847f0bda824ec8da914045d14',
'0x4200000000000000000000000000000000000006',
'0xca5f2ccbd9c40b32657df57c716de44237f80f05')
group by 1
)
select case when amount_usd<10 then '<10$'
when amount_usd>=10 and amount_usd<100 then '10$ - 100$'
when amount_usd>=100 and amount_usd<1000 then '100$ - 1000$'
QueryRunArchived: QueryRun has been archived