Query editor
-- tracks orderflow of popular dapp frontends and wallets, runs DAILY-- adapted from angelfish: https://dune.com/angelfish/orderflow-metrics-- first leg of the swap (user sends/receives token0)with get_transfers_0 as (select tx_hash,block_number,"from","to",contract_address,amountfrom (-- gets all erc20 transfers (from events)select evt_tx_hash as tx_hash,evt_block_number as block_number,"from","to",contract_address,value as amount,true as includefrom erc20_ethereum.evt_Transferwhere ({{token0}} = 0x0000000000000000000000000000000000000000 or contract_address = {{token0}})and evt_block_time > date_trunc('day', now() - interval '{{scope_in_days}}' day)and 0x0000000000000000000000000000000000000000 not in ("from", "to") -- remove mint and burnsunion all-- gets all transfers that transferred ether (from traces)select tx_hash,block_number,"from","to",0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 as contract_address,value as amount,case when ({{token0}} = 0x0000000000000000000000000000000000000000 or {{token0}} = 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2)then true else false end as includefrom ethereum.traceswhere value > uint256 '0' -- this is the ether filterand block_time > date_trunc('day', now() - interval '{{scope_in_days}}' day)) as twhere include = true) --select * from get_transfers_0 where block_number = 18924505 and tx_hash = 0x4aeb66322b091885863304aaf1fba76ce6897ba6b79b913e029f82cdde9f37eb-- second leg of the swap (user sends/receives token1),get_transfers_1 as (select tx_hash,block_number,"from","to",contract_address,amountfrom (-- gets all erc20 transfers (from events)select evt_tx_hash as tx_hash,evt_block_number as block_number,"from","to",contract_address,value as amount,case when {{token1}} != 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2then true else false end as includefrom erc20_ethereum.evt_Transfer