Query editor
-- tracks orderflow of popular dapp frontends and wallets, runs DAILY-- adapted from angelfish: https://dune.com/angelfish/orderflow-metricswith get_transfers as (select tx_hash,"from","to",contract_address,amountfrom (-- gets all erc20 transfers (from events)select evt_tx_hash as tx_hash,"from","to",erc20transfers.contract_address,value as amount,case when '{{source}}' = 'All transfers' then '{{source}}' else 'ERC20 transfers' end as sourcefrom erc20_ethereum.evt_Transfer erc20transferswhere 0x0000000000000000000000000000000000000000 not in ("from", "to") -- remove mint and burnsand (case when '{{source}}' != 'All transfers' then contract_address in ({{tokens}}) end)and evt_block_time > date_trunc('day', now() - interval '{{scope_in_days}}' day)union all-- gets all transfers that transferred ether (from traces)select tx_hash,"from","to",0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 as contract_address,value as amount,case when '{{source}}' = 'All transfers' then '{{source}}' else 'ETH transfers' end as sourcefrom ethereum.traces traceswhere value > uint256 '0' -- this is the ether filterand block_time > date_trunc('day', now() - interval '{{scope_in_days}}' day)) as twhere source = '{{source}}')-- get all successful transactions that have sent to a router address,txs_to_router as (select transactions.block_time,transactions.hash as tx_hash,transactions."from",transactions."to",case when transactions."from" in (select user from query_2698146) and transactions."to" = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D then 'Maestro'else routers.project end as project,case when transactions."from" in (select user from query_2698146) and transactions."to" = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D then 'Telegram Bot'when lower(routers."type") = 'telegram trading bot' then 'Telegram Bot'when lower(routers."type") = 'solver' or routers.project in ('Uniswap X', 'Cowswap') then 'Intent Based'when lower(routers."type") = 'meta-aggregator' or routers.project = 'DODO API' then 'Aggregator'when lower(routers."type") = 'amm' or routers."type" = 'router' then 'DEX'when lower(routers."type") = 'wallet' or routers.project = 'OKX' then 'Wallet'when routers."type" = '?' then 'Unknown'else routers."type" end as sourcefrom ethereum.transactions transactionsjoin query_2614931 as routerson transactions."to" = routers.address and routers.blockchain = 'ethereum'where transactions.block_time > date_trunc('day', now() - interval '{{scope_in_days}}' day)and transactions.block_time < date_trunc('day', now())and transactions.success = true)-- get all transactions where eoa sends or receives from router