MLDZMNdzz8
    Updated 2023-02-08
    with tb1 as (select
    hour::date as day,
    symbol,
    decimals,
    avg (price) as price_usd
    from ethereum.core.fact_hourly_token_prices
    group by 1,2,3),

    tb2 as (select
    *,
    event_inputs:value as amount,
    SYMBOL as Tokens
    from arbitrum.core.fact_event_logs s left join arbitrum.core.dim_contracts a on s.contract_address=a.address
    where origin_to_address in ('0x3d6ba331e3d9702c5e8a8d254e5d8a285f223aba','0xb87a436b93ffe9d75c5cfa7bacfff96430b09868')
    and tx_status= 'SUCCESS'
    and event_name = 'Transfer'
    and amount is not null
    ),

    tb3 as (
    select s.*,
    (amount*price_usd / pow (10,s.decimals)) as amount_usd
    from tb2 s
    left join tb1 b on s.block_timestamp::date = b.day and s.Tokens = b.symbol
    where amount_usd is not null ),

    tb4 as (select
    HOUR::date as day,
    avg(PRICE) as price_token
    from ethereum.core.fact_hourly_token_prices where SYMBOL='WETH'
    group by 1),
    tb5 as (select
    HOUR::date as day,
    avg(PRICE) as price_token
    from ethereum.core.fact_hourly_token_prices where SYMBOL='MATIC'
    Run a query to Download Data