misaghlbGain or Lose - distribution wallets LIDO Swaps stETH => ETH - in 2022
    Updated 2022-06-11
    with wallets as (
    SELECT ORIGIN_FROM_ADDRESS as wallet,
    sum(AMOUNT_OUT) - sum(AMOUNT_IN) as total_profit_loss
    FROM ethereum.core.ez_dex_swaps
    where date(BLOCK_TIMESTAMP) >= '2022-01-01'
    and SYMBOL_IN = 'stETH'
    and SYMBOL_OUT = 'WETH'
    GROUP BY wallet
    ORDER BY total_profit_loss DESC
    ),
    total_profit_losss_dist as (
    SELECT
    case
    when total_profit_loss <=-5 then 'Loss above 5 ETH'
    when total_profit_loss >-5 and total_profit_loss <= -3 then 'Loss 3 - 5 ETH'
    when total_profit_loss >-3 and total_profit_loss <= -1 then 'Loss 1 - 3 ETH'
    when total_profit_loss >-1 and total_profit_loss <= -0.5 then 'Loss 0.5 - 1 ETH'
    when total_profit_loss >-0.5 and total_profit_loss <= -0.1 then 'Loss 0.1 - 0.5 ETH'
    when total_profit_loss >-0.1 and total_profit_loss<0 then 'Loss below 0.1 ETH'
    when total_profit_loss=0 then 'No Profit/Loss'
    when total_profit_loss>0 then 'Profit'
    end as bal_dist
    from wallets
    )
    SELECT bal_dist, count(bal_dist) as counts from total_profit_losss_dist
    group by bal_dist

    Run a query to Download Data