Query editor
-- Clanker trading volume by day and chain---- dune.com/queries/9059332: the public query behind the trading volume on-- the "Clanker" dashboard (dune.com/stambouli_o1/clanker), in the stambouli_o1-- Dune team's "Clanker" folder. This file is its source of truth.-- clanker-analytics runs it every day and stores its rows-- (server/jobs/trading-volume.ts), so the dashboard total and clanker.world's-- all-pool volume are the same figure.---- Every DEX trade of a Clanker token, by UTC day and chain, from the first-- launch to yesterday: every pool dex.trades covers, Clanker's own and the-- ones others created for the same tokens. Each trade counts once, whether the-- Clanker token was bought or sold. The token list is-- dune.stambouli_o1.clanker_pools (every Clanker launch, uploaded from-- clanker-analytics).---- Incremental: each run keeps the days it already has and recomputes only the-- last 3 (trades can reach Dune late) and the days since, so a daily refresh-- scans a few days, not the whole history.with prev_result as (select * from table(previous.query.result(schema => descriptor(day date,blockchain varchar,trades bigint,volume_usd double,clanker_pool_usd double,other_pools_usd double,total_volume_usd double,total_clanker_pool_usd double,total_other_pools_usd double,cumulative_volume_usd double)))),-- Without a previous result (the first run after any edit), the saved history-- (dune.stambouli_o1.clanker_trading_volume_history, uploaded from-- clanker-analytics) stands in, so that run recounts a few days, not all-- history, which would pass Dune's 30-minute limit.prev as (select day, blockchain, trades, volume_usd, clanker_pool_usdfrom prev_resultunion allselect cast(day as date), blockchain, cast(trades as bigint), volume_usd, clanker_pool_usdfrom dune.stambouli_o1.clanker_trading_volume_historywhere not exists (select 1 from prev_result)),checkpoint as (select coalesce(max(day) - interval '3' day, date '2024-09-01') as cutofffrom prev),pools as (select distinct blockchain, token, poolfrom dune.stambouli_o1.clanker_pools),