SandeshNFTs held by wolves copy
    Updated 2024-10-29
    -- forked from NFTs held by wolves @ https://flipsidecrypto.xyz/studio/queries/d5d4c4c5-e199-4992-bf10-33baf2955458

    /*
    NFT Portfolio Analysis Query
    ---------------------------
    This query analyzes NFT portfolios of Wolves DAO members across multiple blockchain networks
    (Ethereum, Polygon, Arbitrum, and Avalanche) using Reservoir API data.

    Key Features:
    - Multi-chain portfolio tracking
    - Floor price analysis in native tokens and USD
    - Holder concentration metrics
    - Current token price integration
    - Spam filtering and data validation
    */

    -- Identifies current Wolves DAO NFT holders from Polygon network
    WITH wolves_dao_members AS (
    SELECT
    DATE_TRUNC('week', block_timestamp) AS member_join_date,
    nft_to_address AS holder_address,
    tokenId
    FROM polygon.nft.ez_nft_transfers
    WHERE 1=1
    AND block_number >= '44071817' -- Genesis block for Wolves DAO NFT
    AND nft_address = LOWER('0x0433882c60ada1077a9f652ca2d1d36422c62c6c') -- Wolves DAO NFT contract
    -- Get current holder for each token using window function
    QUALIFY ROW_NUMBER() OVER (PARTITION BY tokenId ORDER BY block_number DESC) = 1
    ),

    -- Fetches current prices for relevant blockchain native tokens
    token_prices AS (
    SELECT
    symbol,
    max_by(price, hour) AS current_price -- Latest price for each token
    FROM crosschain.price.ez_prices_hourly
    QueryRunArchived: QueryRun has been archived