0-MIDPer day average buy and sell
    Updated 2023-04-15
    with act1 as (
    with tab1 as (
    select BLOCK_TIMESTAMP::date as date
    ,ORIGIN_FROM_ADDRESS
    ,SYMBOL
    ,AMOUNT
    ,AMOUNT_USD
    ,ORIGIN_TO_ADDRESS
    ,FROM_ADDRESS
    ,TO_ADDRESS
    from arbitrum.core.ez_token_transfers
    where CONTRACT_ADDRESS=lower('0x912ce59144191c1204e64559fe8253a0e49e6548')
    and date>='2023-03-23'
    and SYMBOL='ARB'),
    tab2 as (
    select ADDRESS
    ,PROJECT_NAME
    ,LABEL_TYPE
    from crosschain.core.address_labels
    where LABEL_TYPE='dex')
    select
    date
    ,SYMBOL
    ,sum(case when ORIGIN_FROM_ADDRESS=FROM_ADDRESS then AMOUNT_USD end) as sell_volume
    ,sum(case when ORIGIN_FROM_ADDRESS=TO_ADDRESS then AMOUNT_USD end) as Buy_volume
    ,count(distinct case when ORIGIN_FROM_ADDRESS=FROM_ADDRESS then ORIGIN_FROM_ADDRESS end) as sellers
    ,count(distinct case when ORIGIN_FROM_ADDRESS=TO_ADDRESS then ORIGIN_FROM_ADDRESS end) as buyers
    from tab1
    left join tab2
    on tab1.ORIGIN_TO_ADDRESS=tab2.ADDRESS
    group by 1,2),
    act2 as (
    with tab3 as (
    select BLOCK_TIMESTAMP::date as date
    ,ORIGIN_FROM_ADDRESS
    ,SYMBOL
    Run a query to Download Data