binhachonGain or Lose? - stETH buyer
    Updated 2022-04-02
    with pool_address as (
    select
    distinct pool_address
    from ethereum.dex_swaps
    where token_address = '0xae7ab96520de3a18e5e111b5eaab095312d7fe84'
    ),
    stETH_swap as (
    select
    block_timestamp,
    tx_id,
    amount_in,
    amount_out,
    direction
    from ethereum.dex_swaps
    where token_address = '0xae7ab96520de3a18e5e111b5eaab095312d7fe84'
    ),
    WETH_swap as (
    select
    tx_id,
    amount_in,
    amount_out
    from ethereum.dex_swaps
    where pool_address in (select * from pool_address)
    and token_address = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
    ),
    stETH_WETH_swap as ( --swap from WETH to stETH => stETH out
    select
    block_timestamp,
    stETH_swap.tx_id,
    sum(stETH_swap.amount_out) as s_amount_out,
    sum(WETH_swap.amount_in) as s_amount_in,
    s_amount_out - s_amount_in as gain_amount,
    100 * gain_amount / s_amount_in as gain_perc
    from stETH_swap
    inner join WETH_swap on (stETH_swap.tx_id = WETH_swap.tx_id)
    where direction = 'OUT'
    Run a query to Download Data