freemartianUntitled Query
    Updated 2022-06-15


    with steth_out as (
    select to_address, amount_out, block_timestamp::date as TIME, tx_id
    from flipside_prod_db.ethereum.dex_swaps
    where token_address = '0xae7ab96520de3a18e5e111b5eaab095312d7fe84'
    and pool_address = '0xdc24316b9ae028f1497c275eb9192a3ea0f67022'
    and block_timestamp::date > CURRENT_DATE -90
    ),

    eth_in as (
    select to_address, amount_in, block_timestamp::date as TIME, tx_id
    from flipside_prod_db.ethereum.dex_swaps
    where token_address = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
    and pool_address = '0xdc24316b9ae028f1497c275eb9192a3ea0f67022'
    and block_timestamp::date > CURRENT_DATE -90
    ),


    source as (
    select e.to_address as swapper, s.amount_out, e.amount_in,
    count(distinct s.tx_id) as swap_count
    from eth_in e
    inner join steth_out s on e.TIME = s.TIME
    where swapper in (
    select distinct event_inputs:sender
    from ethereum_core.fact_event_logs
    where contract_address = '0xae7ab96520de3a18e5e111b5eaab095312d7fe84'
    and tx_status = 'SUCCESS'
    )
    )

    select swapper, sum(s.amount_out)
    from source
    group by swapper

    Run a query to Download Data