Query editor
-- New Holders Acquisition - Cross-Collection-- Tracks wallets that acquired tokens within timeframe AND still hold those specific tokens-- Parameters: {{Timeframe}} (days: 30, 90, 180, 365, 730, 9999), {{Granularity}} (day/week/month)-- {{StartDate}} (text) - Optional start date for gap-fill (empty = full fetch)-- Output: period, collection_key, new_wallets, tokens_acquired, tokens_retained, retention_rate-- Define core collections with chain contextWITH collections AS (SELECT contract_address, blockchain, collection_key, collection_name FROM (VALUES(0xA3AEE8BCE55BEEA1951EF834B99F3AC60D1ABEEB, 'ethereum', 's1', 'Series 1'),(0x9378368ba6b85c1fba5b131b530f5f5bedf21a18, 'ethereum', 's2', 'Series 2'),(0x65FFF8F5F6A9922B6DC13FE06345A0FE46DD413D, 'ethereum', 'iconics', 'Iconics'),(0x6bb33db533dcc47d26570408559228d180bcd67c, 'base', 'bookgames', 'Book Games')) AS t(contract_address, blockchain, collection_key, collection_name)),-- All marketplace purchases in timeframepurchases AS (SELECTt.buyer AS wallet,t.nft_contract_address,t.token_id,t.block_time,c.collection_key,c.collection_name,c.blockchain,CASEWHEN t.currency_symbol IN ('ETH', 'WETH')THEN CAST(t.amount_raw AS DOUBLE) / 1e18ELSE NULLEND AS amount_eth,t.amount_usdFROM nft.trades tINNER JOIN collections cON t.nft_contract_address = c.contract_addressAND t.blockchain = c.blockchainWHERE t.block_time >= NOW() - INTERVAL '{{Timeframe}}' DAY),-- First purchase time per wallet per collection (all-time, not just timeframe)first_acquisition AS (SELECTt.buyer AS wallet,c.collection_key,MIN(t.block_time) AS first_purchase_timeFROM nft.trades tINNER JOIN collections cON t.nft_contract_address = c.contract_addressAND t.blockchain = c.blockchainGROUP BY t.buyer, c.collection_key),-- Wallets whose first purchase was within timeframe (true new holders)new_wallets AS (SELECT wallet, collection_key, first_purchase_timeFROM first_acquisitionWHERE first_purchase_time >= NOW() - INTERVAL '{{Timeframe}}' DAY),-- Current owner of each token (most recent transfer recipient)