Query editor
WITH addresses AS (SELECT * FROM query_2428525 -- DAO addresses),addresses_polygon AS (SELECT address FROM addresses WHERE blockchain = 'polygon'),sent_polygon AS (SELECTdate_trunc('month', block_time) as month,"from" AS address,-CAST(sum(value) AS INT256) AS totalFROMpolygon.traces trJOIN addresses_polygon ON tr."from" = addresses_polygon.addressWHEREsuccessAND (call_type NOT IN ('delegatecall', 'callcode', 'staticcall') OR call_type IS null)AND block_time >= CAST('2021-05-02' AS TIMESTAMP)GROUP BY 1, 2),received_polygon AS (SELECTdate_trunc('month', block_time) as month,to AS address,CAST(sum(value) AS INT256) AS totalFROMpolygon.traces trJOIN addresses_polygon ON tr."to" = addresses_polygon.addressWHEREsuccessAND (call_type NOT IN ('delegatecall', 'callcode', 'staticcall') OR call_type IS null)AND block_time >= CAST('2021-05-02' AS TIMESTAMP)GROUP BY 1, 2),gas_costs_polygon AS (SELECTdate_trunc('month', block_time) as month,"from" AS address,-(CAST(sum(gas_used * gas_price) as INT256)) as totalFROMpolygon.transactions txJOIN addresses_polygon ON tx."from" = addresses_polygon.addressWHEREsuccessAND block_time >= CAST('2021-05-02' AS TIMESTAMP)GROUP BY 1, 2),-- ensure there is a month entry for every address, to avoid gaps in the graphsactive_months AS (SELECT DISTINCT monthFROM (SELECT month FROM sent_polygonUNION SELECT month FROM received_polygonUNION SELECT month FROM gas_costs_polygon)),active_addresses_polygon AS (SELECT DISTINCT address