SandeshWolvesDAO Eth NFTs
    Updated 2024-10-25
    /*
    NFT Holdings Analysis Query
    --------------------------
    This query analyzes NFT holdings across Ethereum of Wolves Dao members. It specifically:
    - Identifies holders of a Wolves dao token on Polygon
    - Tracks current NFT ownership on Ethereum
    - Calculates collection-level statistics including total NFTs held and unique holders

    */

    -- Latest ownership status for all NFTs on Ethereum
    -- Uses window function to get current holder for each NFT
    WITH ethereum_latest_transfers AS (
    SELECT
    block_timestamp,
    tx_hash,
    nft_to_address AS current_holder,
    nft_address,
    project_name,
    tokenId
    FROM ethereum.nft.ez_nft_transfers
    QUALIFY (ROW_NUMBER() OVER (PARTITION BY nft_address, tokenId ORDER BY block_number DESC) = 1)
    ),

    -- Identifies holders of Wolves DAO on Polygon
    -- Filters for transfers after a specific block
    polygon_holders AS (
    SELECT
    DATE_TRUNC('week', block_timestamp) AS member_since,
    nft_to_address AS member_address,
    tokenId
    FROM polygon.nft.ez_nft_transfers
    WHERE 1=1
    AND block_number >= '44071817' -- Starting block for analysis
    AND nft_address = LOWER('0x0433882c60ada1077a9f652ca2d1d36422c62c6c') -- Target NFT contract
    QUALIFY ROW_NUMBER() OVER (PARTITION BY tokenId ORDER BY block_number DESC) = 1 -- Get current holder for each token
    QueryRunArchived: QueryRun has been archived