boomer772023-07-19 11:23 AM
    Updated 2023-07-19
    with buyz as (select 'buys' as action, *
    from ethereum.core.ez_dex_swaps
    where token_out = lower('0xe98242ef4c30073f7E342eE78fcD33b3bCf887Aa')),

    sellz as (select 'sells' as action, *
    from ethereum.core.ez_dex_swaps
    where token_in = lower('0xe98242ef4c30073f7E342eE78fcD33b3bCf887Aa'))

    select *
    from sellz
    limit 1000

    buyer as (select tx_to as buyer, sum(amount_in) as shitcoin_bought, sum(amount_out) as eth_bought
    from buyz
    group by 1),

    seller as (select origin_from_address as seller, sum(amount_in) as shitcoin_sold, sum(amount_out) as eth_sold
    from sellz
    group by 1)

    select *
    from seller
    limit 100

    select a.buyer, a.shitcoin_bought, a.eth_bought, b.shitcoin_sold, b.eth_sold,
    (b.eth_sold - a.eth_bought) as profit_eth
    from buyer a
    left join seller b on a.buyer = b.seller
    order by profit_eth desc

    --select date_trunc('hour', block_timestamp) as hour_dt,
    --action, concat(symbol_in,'-',symbol_out) as pair,
    --count(distinct tx_hash) as tx_count,
    --sum(amount_out) as t_out
    --from pc
    --group by 1,2,3
    Run a query to Download Data