Query editor
/* Success! If you're still running into issues, check out https://dune.com/docs/query/syntax-differences/ or reach out in the #dune-sql Discord channel. */WITH time_series AS(SELECT timefromUNNEST (SEQUENCE(TRY_CAST('2022-07-01 00:00' AS TIMESTAMP),CAST(CURRENT_TIMESTAMP AS TIMESTAMP),INTERVAL '1' Day)) as _u (time))SELECTtime as day,SUM(cbeth) OVER ( ORDER BY time ) AS cumulative_cbeth,cbethFROM(SELECTDATE_TRUNC('day', evt_block_time) AS day,SUM((CASEWHEN contract_address = 0xBe9895146f7AF43049ca1c1AE358B0541Ea49704 THEN CAST(value AS DOUBLE) / 1e18ELSE 0END) * (CASEWHEN "to" in (0x5fae7e604fc3e24fd43a72867cebac94c65b404a,0x73069892f6750ccaaababadc54b6b6b36b3a057d) THEN 1ELSE -1END)) AS cbethFROMerc20_ethereum.evt_TransferWHERE DATE_TRUNC('day', evt_block_time) >= date('2022-07-01') AND("to" in (0x5fae7e604fc3e24fd43a72867cebac94c65b404a,0x73069892f6750ccaaababadc54b6b6b36b3a057d) or"from" in (0x5fae7e604fc3e24fd43a72867cebac94c65b404a,0x73069892f6750ccaaababadc54b6b6b36b3a057d))GROUP BY 1) AS ttright join time_series t on t.time = tt.dayORDER BYtime DESC NULLS FIRST