alirsOPB-OPT09
    Updated 2022-10-14
    with zipswap as (
    select
    DISTINCT tx_hash
    from optimism.core.fact_event_logs
    where
    origin_to_address= lower('0xE6Df0BB08e5A97b40B21950a0A51b94c4DbA0Ff6') --ZipSwap
    and event_name = 'Swap'
    and tx_status = 'SUCCESS'
    )
    select date_trunc('day',block_timestamp::date) as date,
    -- SYMBOL
    count(DISTINCT tx_hash) as swap_count
    ,sum(EVENT_INPUTS:value/pow(10,DECIMALS)) as Swap_amount
    ,sum(Swap_amount) over(order by date) as cum_Swap_amount
    from optimism.core.fact_event_logs
    join optimism.core.dim_contracts on address = CONTRACT_ADDRESS
    where
    EVENT_NAME='Transfer'
    and tx_status = 'SUCCESS'
    and EVENT_INDEX=0
    and tx_hash in (select tx_hash from zipswap)
    and date>='2022-01-01'
    group by 1
    order by 1

    Run a query to Download Data