par_rnINK 03
    Updated 2025-01-15
    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)


    select
    COUNT (DISTINCT ORIGIN_FROM_ADDRESS) AS users,
    COUNT (DISTINCT TX_HASH) AS transactions ,
    -- case when symbol = 'WETH' then 'ETH'
    -- when symbol = 'Kraken' then 'KRAKEN'
    -- else 'USDC' end as symbol,

    sum(case when symbol = 'WETH' then raw_amount_precise/pow(10,18)
    when symbol = 'Kraken' then raw_amount_precise/pow(10,18)
    else raw_amount_precise/pow(10,6) end) as amount,

    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 (
    Last run: 3 months ago
    USERS
    TRANSACTIONS
    AMOUNT
    AMOUNT_USD
    1
    835923890409903466887.53611604569.9067521
    1
    48B
    13s