Query editor
-- D1: Dune 8163671 completed and extended to the full window (Nov 2021 -> now), by controller version.-- reg = NameRegistered cost; v4/v5 split baseCost vs premium; v1-v3 emit only `cost` (base+premium, not separable on-chain from the event).-- USD at event-day average WETH price from prices.usd (same series exported to prices-eth-usd-daily.csv).with eth_price as (select date_trunc('day',minute) day, avg(price) eth_usd from prices.usdwhere blockchain='ethereum' and contract_address=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2and minute>=timestamp '2021-11-01' group by 1),reg as (select evt_block_time t, 'v1' v, cast(cost as double) base_wei, 0e0 prem_wei from ethereumnameservice_ethereum.ethregistrarcontroller_1_evt_nameregisteredunion all select evt_block_time, 'v2', cast(cost as double), 0e0 from ethereumnameservice_ethereum.ethregistrarcontroller_2_evt_nameregisteredunion all select evt_block_time, 'v3', cast(cost as double), 0e0 from ethereumnameservice_ethereum.ethregistrarcontroller_3_evt_nameregisteredunion all select evt_block_time, 'v4', cast(basecost as double), cast(premium as double) from ethereumnameservice_ethereum.ethregistrarcontroller_4_evt_nameregisteredunion all select evt_block_time, 'v5', cast(basecost as double), cast(premium as double) from ethereumnameservice_ethereum.ethregistrarcontroller_5_evt_nameregistered),renew as (select evt_block_time t, 'v1' v, cast(cost as double) wei from ethereumnameservice_ethereum.ethregistrarcontroller_1_evt_namerenewedunion all select evt_block_time, 'v2', cast(cost as double) from ethereumnameservice_ethereum.ethregistrarcontroller_2_evt_namerenewedunion all select evt_block_time, 'v3', cast(cost as double) from ethereumnameservice_ethereum.ethregistrarcontroller_3_evt_namerenewedunion all select evt_block_time, 'v4', cast(cost as double) from ethereumnameservice_ethereum.ethregistrarcontroller_4_evt_namerenewedunion all select evt_block_time, 'v5', cast(cost as double) from ethereumnameservice_ethereum.ethregistrarcontroller_5_evt_namerenewed),r as (select date_trunc('month', t) month, v,sum(base_wei/1e18) reg_base_eth, sum(prem_wei/1e18) premium_eth, count(*) n_reg,sum(base_wei/1e18*p.eth_usd) reg_base_usd, sum(prem_wei/1e18*p.eth_usd) premium_usdfrom reg join eth_price p on date_trunc('day', t) = p.daywhere t >= timestamp '2021-11-01' group by 1,2),n as (select date_trunc('month', t) month, v, sum(wei/1e18) renew_eth, count(*) n_renew, sum(wei/1e18*p.eth_usd) renew_usdfrom renew join eth_price p on date_trunc('day', t) = p.daywhere t >= timestamp '2021-11-01' group by 1,2)select coalesce(r.month, n.month) month, coalesce(r.v, n.v) controller,coalesce(reg_base_eth,0) reg_base_eth, coalesce(premium_eth,0) premium_eth, coalesce(renew_eth,0) renew_eth,coalesce(reg_base_eth,0)+coalesce(premium_eth,0)+coalesce(renew_eth,0) total_eth,coalesce(reg_base_usd,0) reg_base_usd, coalesce(premium_usd,0) premium_usd, coalesce(renew_usd,0) renew_usd,coalesce(reg_base_usd,0)+coalesce(premium_usd,0)+coalesce(renew_usd,0) total_usd,coalesce(n_reg,0) n_reg, coalesce(n_renew,0) n_renewfrom r full outer join n on r.month=n.month and r.v=n.vorder by 1,2