adriaparcerisasOptimism DEX swaps 2
    Updated 2022-08-03
    with
    uniswap as (
    select
    trunc(block_timestamp,'day') as date,
    project_name,
    contract_address,
    count(DISTINCT tx_hash) as swaps
    from optimism.core.fact_event_logs x
    join optimism.core.dim_labels on origin_to_address = address
    where label_type = 'dex' and project_name='uniswap' and block_timestamp>CURRENT_DATE-INTERVAL'1 month'
    GROUP by 1,2,3
    order by 1 asc
    ),
    velodrome as (
    select
    trunc(block_timestamp,'day') as date,
    'Velodrome Finance' as project_name,
    contract_address,
    count(DISTINCT tx_hash) as swaps
    from optimism.core.fact_event_logs
    where origin_to_address='0xa132dab612db5cb9fc9ac426a0cc215a3423f9c9' and block_timestamp>CURRENT_DATE-INTERVAL'1 month'
    GROUP by 1,2,3
    order by 1 asc
    ),
    final as (
    select * from velodrome
    union select * from uniswap
    )
    SELECT
    date,
    project_name,
    symbol as token,
    swaps
    from final x
    join optimism.core.dim_contracts y on contract_address=address
    order by 1 asc
    Run a query to Download Data