Sectortest1
    Updated 2022-10-09
    --Log
    -- 1. Need incorporate simplified holder list from NFT_Transfers. Current list does not account for transfers and shows multiple holders for a token with current date.
    -- 1a. I am matching buys and sells by nft_contract and tokenid. What about ERC1155 tokens where the token id is the same for each? How is it counting those?
    -- 2. need to create individual wallet PnL tracker to perform QA. Create subsections to perform QA from begining to end to isolate issues.
    -- 3. Need to evaluate solution for duplicate wallets. If a wallet holds 2 are their trades being counted twice? If we eliminate duplicate wallets will this impact someone who bought, sold then bought again?
    -- Done: Add to holders table since distinct will not work. ROW_NUMBER() OVER (PARTITION BY wallet ORDER BY buy/sell_date DESC) AS rank, then in the next table: where rank=1
    -- Still Need to verify this works.
    -- select
    -- ROW_NUMBER() OVER (PARTITION BY nft_to_address, tokenid ORDER BY block_timestamp DESC) AS rank,
    -- block_timestamp as date,
    -- nft_to_address as buyer,
    -- nft_from_address as seller,
    -- tokenid
    -- from ethereum.core.ez_nft_transfers
    -- where nft_address = lower('0x08d7c0242953446436f34b4c78fe9da38c73668d')

    With mint_or_buy as (
    select
    date_trunc('day', block_timestamp) as mint_or_buy_date,
    nft_to_address as wallet,
    tokenid
    from ethereum.core.ez_nft_mints
    where nft_address = lower('0x08d7c0242953446436f34b4c78fe9da38c73668d')
    union

    --Find all wallets that purchased and join it with the minted list. These are all wallets that at one point acquired one
    select
    date_trunc('day', block_timestamp) as mint_or_buy_date,
    buyer_address as wallet,
    tokenid
    from ethereum.core.ez_nft_sales a
    where nft_address = lower('0x08d7c0242953446436f34b4c78fe9da38c73668d')
    ),

    --Find all wallets that have ever sold
    Run a query to Download Data