primo_dataeth_swap_usdc_weth_vs_wbtc_weth
    Updated 2022-07-09
    select date(l.block_timestamp) as date
    , count(distinct case when l.contract_address = lower('0x397FF1542f962076d0BFE58eA045FfA2d347ACa0') then l.tx_hash else null end) as swap_count_usdc_weth
    , count(distinct case when l.contract_address = lower('0xceff51756c56ceffca006cd410b03ffc46dd3a58') then l.tx_hash else null end) as swap_count_wbtc_weth

    , sum(case when l.contract_address = lower('0x397FF1542f962076d0BFE58eA045FfA2d347ACa0')
    then ((l.event_inputs:amount1Out::integer) + (l.event_inputs:amount1In::INTEGER))/ pow(10,t1.decimals)
    else null end) as weth_volume_usdc_weth
    , sum(case when l.contract_address = lower('0xceff51756c56ceffca006cd410b03ffc46dd3a58')
    then ((l.event_inputs:amount1Out::integer) + (l.event_inputs:amount1In::INTEGER))/ pow(10,t1.decimals)
    else null end) as weth_volume_wbtc_weth
    from ethereum.core.fact_event_logs as l
    left join ethereum.core.dim_dex_liquidity_pools as p
    on l.contract_address = p.pool_address
    left join ethereum.core.dim_contracts as t0
    on p.token0 = t0.address
    left join ethereum.core.dim_contracts as t1
    on p.token1 = t1.address
    where l.block_timestamp >= current_date - 6
    and l.contract_address in (lower('0x397FF1542f962076d0BFE58eA045FfA2d347ACa0'), lower('0xceff51756c56ceffca006cd410b03ffc46dd3a58'))
    and l.event_name = 'Swap'
    group by 1
    order by 1;




    Run a query to Download Data