Moe0**aiirr
    Updated 2023-01-25
    with tb1 as (
    select
    date_trunc(week,BLOCK_TIMESTAMP) as date ,
    tx_hash,
    case when EVENT_INPUTS:chainId = '1' then 'Mainnet Ethereum'
    when EVENT_INPUTS:chainId = '10' then 'ETH to Optimism by Hop'
    when EVENT_INPUTS:chainId = '137' then 'ETH to Polygon by Hop'
    when EVENT_INPUTS:chainId = '100' then 'Gnosis Chain'
    when EVENT_INPUTS:chainId = '42161' then 'ETH to Arbitrum by Hop'
    end as chainId
    from ethereum.core.fact_event_logs
    where contract_address = lower('0xb8901acb165ed027e32754e0ffe830802919727f')
    and event_name = 'TransferSentToL2'
    ),

    bridge as (select tx_hash
    from ethereum.core.fact_event_logs
    where event_name = 'TransferSentToL2'
    )



    select
    date_trunc(week,BLOCK_TIMESTAMP) as date ,
    'ETH -> Hop ->' as chainId,
    count (distinct ETH_FROM_ADDRESS) as users,
    count(distinct tx_hash) as num_txns,
    sum(AMOUNT_USD) as bridged_value,
    avg(AMOUNT_USD) as avg_bridged_value,
    median(AMOUNT_USD) as median_bridged_value,
    max(AMOUNT_USD) as max_bridged_value,

    sum(bridged_value)over(order by date) as cum_value,
    Run a query to Download Data