hessCumulative CryptoPunks sales
    Updated 2022-08-30
    with eth_price as (select date(block_timestamp) as p_date, (sum(AMOUNT_OUT)/sum(AMOUNT_IN)) as avg_price
    from ethereum.core.ez_dex_swaps
    where TOKEN_IN = lower('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2')
    and TOKEN_OUT = lower('0xdAC17F958D2ee523a2206206994597C13D831ec7')
    group by 1)
    ,
    punk as ( select date(block_timestamp) as date, tx_hash, platform_name, seller_address, buyer_address, tokenid, price , price*avg_price as price_usd
    from ethereum.core.ez_nft_sales a left outer join eth_price b on a.block_timestamp::date = p_date
    where nft_address = lower('0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB')
    and buyer_address != '0x0000000000000000000000000000000000000000' and seller_address != '0x0000000000000000000000000000000000000000'
    and event_type ilike 'sale' and currency_symbol = 'ETH' and tx_hash != '0x92488a00dfa0746c300c66a716e6cc11ba9c0f9d40d8c58e792cc7fcebf432d0'
    )

    select trunc(date,'week') as weekly, count(DISTINCT(tx_hash)) as total_sales, count(DISTINCT(buyer_address)) as buyer , count(DISTINCT(seller_address)) as total_seller,
    count(DISTINCT(tokenid)) as total_number_nft, sum(price) as total_amount, sum(price_usd) as volume,
    median(price) as avg_price,
    sum(total_sales) over (order by weekly asc) as cum_sales,
    sum(buyer) over (order by weekly asc) as cum_buyer,
    sum(total_seller) over (order by weekly asc) as cum_seller,
    sum(total_amount) over (order by weekly asc) as cum_amount,
    sum(volume) over (order by weekly asc) as cum_volume
    from punk
    where date >= '{{Date}}'
    group by 1

    Run a query to Download Data