maybeyonascowswap_sushi_daily
    Updated 2022-04-19
    with
    cowswaps as (
    select distinct tx_hash from ethereum_core.fact_event_logs
    where contract_address = lower('0x9008d19f58aabd9ed0d60971565aa8510560ab41')
    and event_name = 'Trade'
    ),
    sushi_pools as (
    select distinct pool_address from ethereum_core.dim_dex_liquidity_pools
    where platform = 'sushiswap'
    ),
    sushi_swaps as (
    select
    date(block_timestamp) as date,
    count(distinct tx_hash) as sushi_txs
    from ethereum_core.fact_event_logs
    where event_name = 'Swap'
    and tx_hash in (select * from cowswaps)
    and contract_address in (select * from sushi_pools)
    group by 1
    ),
    total_cowswaps as (
    select
    date(block_timestamp) as date,
    count(distinct tx_hash) as coswap_txs
    from ethereum_core.fact_event_logs
    where contract_address = lower('0x9008d19f58aabd9ed0d60971565aa8510560ab41')
    and event_name = 'Trade'
    group by 1
    ),
    non_sushi as (
    select
    c.date,
    coswap_txs - sushi_txs as non_sushi_txs
    from total_cowswaps c join sushi_swaps s on c.date = s.date
    )

    Run a query to Download Data