Query editor
-- Params:-- {{granularity}} -- day | week | month | year-- {{lookback_days}} -- e.g., 180-- {{currency}} -- ETH | USDWITHbounds AS (SELECTCAST(DATE_TRUNC('{{granularity}}', NOW() - INTERVAL '{{lookback_days}}' DAY) AS DATE) AS start_day,CAST(DATE_TRUNC('{{granularity}}', NOW()) AS DATE) AS end_day),buckets AS (SELECT DATE_TRUNC('{{granularity}}', d) AS bucketFROM bounds,UNNEST(SEQUENCE(start_day, end_day, INTERVAL '1' DAY)) AS t(d)GROUP BY 1),floors AS (SELECTDATE_TRUNC('{{granularity}}', t.block_time) AS bucket,t.nft_contract_address,MIN(t.amount_original) AS floor_eth,MIN(t.amount_usd) AS floor_usdFROM nft.trades tWHERE t.blockchain = 'ethereum'AND t.block_time >= (SELECT start_day FROM bounds)AND t.nft_contract_address IN (0xa3aee8bce55beea1951ef834b99f3ac60d1abeeb, -- VeeFriends S10x9378368ba6b85c1fba5b131b530f5f5bedf21a18 -- VeeFriends S2)AND t.amount_original > 0AND t.amount_usd > 0GROUP BY 1,2),aligned AS (SELECTb.bucket,f.nft_contract_address,f.floor_eth,f.floor_usdFROM buckets bLEFT JOIN floors f ON f.bucket = b.bucket)SELECTa.bucket,a.nft_contract_address,-- Fixed-scale outputs for clean tooltips/legendsCAST(ROUND(a.floor_eth, 3) AS DECIMAL(38,3)) AS floor_eth,CAST(ROUND(a.floor_usd, 2) AS DECIMAL(38,2)) AS floor_usd,-- Currency-param value (single numeric column for charting)CASEWHEN '{{currency}}' = 'USD'THEN CAST(ROUND(a.floor_usd, 2) AS DECIMAL(38,3))ELSE CAST(ROUND(a.floor_eth, 3) AS DECIMAL(38,3))END AS floor_value,-- S2/S1 ratios (fixed to 3 decimals)CASE