elsinaDistribution of profits from cryptopunks collection traders
    Updated 2022-08-31
    with transfer as (
    select
    seller_address as addr,
    min(block_timestamp::date) as min,
    max(block_timestamp::date) as max,
    sum(iff(price_usd is null, 0, price_usd)) as vol
    from ethereum.core.ez_nft_sales
    where project_name in ('cryptopunks', 'Wrapped CryptoPunks V1', 'wrapped cryptopunks')
    group by 1
    union all
    select
    buyer_address as addr,
    min(block_timestamp::date) as min,
    max(block_timestamp::date) as max,
    -sum(iff(price_usd is null, 0, price_usd)) as vol
    from ethereum.core.ez_nft_sales
    where project_name in ('cryptopunks', 'Wrapped CryptoPunks V1', 'wrapped cryptopunks')
    group by 1
    ),
    profit as (
    select
    addr,
    sum(vol) as profit_or_loss,
    datediff('day', min(min), max(max)) as n_days
    from transfer
    where addr != '0x0000000000000000000000000000000000000000'
    group by 1
    )
    select
    case
    when profit_or_loss < 0 then 'a. Loss'
    when profit_or_loss <= 10 then 'b. 0 - 10'
    when profit_or_loss <= 100 then 'c. 10 - 100'
    when profit_or_loss <= 1000 then 'd. 100 - 1K'
    when profit_or_loss <= 10000 then 'e. 1K - 10K'
    when profit_or_loss <= 100000 then 'f. 10K - 100K'
    Run a query to Download Data