Query editor
-- Query to fetch all-time volume, 24hr volume, number of holders, and new wallets in last 24 hoursWITH trading_volume AS (-- Calculate all-time and 24hr trading volume from dex.tradesSELECTSUM(amount_usd) AS all_time_volume_usd,SUM(CASEWHEN block_time >= NOW() - INTERVAL '24' HOURTHEN amount_usdELSE 0END) AS volume_24hr_usdFROM dex.tradesWHERE token_bought_address = 0xcdbddbdefb0ee3ef03a89afcd714aa4ef310d567OR token_sold_address = 0xcdbddbdefb0ee3ef03a89afcd714aa4ef310d567),holders AS (-- Estimate number of holders from erc20.transfers (unique wallets that received the token)SELECTCOUNT(DISTINCT "to") AS num_holdersFROM erc20_ethereum.evt_transferWHERE contract_address = 0xcdbddbdefb0ee3ef03a89afcd714aa4ef310d567),new_wallets AS (-- Count wallets receiving the token for the first time in the last 24 hoursSELECTCOUNT(DISTINCT "to") AS new_wallets_24hrFROM (SELECT"to",MIN(evt_block_time) AS first_transfer_timeFROM erc20_ethereum.evt_transferWHERE contract_address = 0xcdbddbdefb0ee3ef03a89afcd714aa4ef310d567GROUP BY "to"HAVING MIN(evt_block_time) >= NOW() - INTERVAL '24' HOUR) first_transfers)-- Combine all metrics into a single rowSELECTtv.all_time_volume_usd,tv.volume_24hr_usd,h.num_holders,nw.new_wallets_24hrFROM trading_volume tvCROSS JOIN holders hCROSS JOIN new_wallets nw;