Query editor
-- This query has been migrated to run on DuneSQL.-- If you need to change back because you’re seeing issues, use the Query History view to restore the previous version.-- If you notice a regression, please email [email protected].WITHnew_transfers AS (SELECTto AS wallet,MIN(evt_block_time) AS timeFROMerc20_{{chain}}.evt_TransferWHEREcontract_address = {{token_address}}GROUP BY1HAVINGMIN(evt_block_time) > NOW() - INTERVAL '{{day}}' day),amount_accumulated AS (SELECTcast(SUM(value) as int256) AS amount_raw,DATE_TRUNC('day', evt_block_time) AS timeFROMerc20_{{chain}}.evt_TransferWHEREto IN (SELECTwalletFROMnew_transfers)AND contract_address = {{token_address}}GROUP BY2UNIONSELECT- SUM(cast(value as int256)) AS amount_raw,DATE_TRUNC('day', evt_block_time) AS timeFROMerc20_{{chain}}.evt_TransferWHERE"from" IN (SELECTwalletFROMnew_transfers)AND contract_address = {{token_address}}GROUP BY2),accumulation AS (SELECTSUM(amount_raw) OVER (ORDER BYtime) AS accumulation,timeFROMamount_accumulated