Query editor
withpair_tokens as (selecttoken0, token1from uniswap_v2_ethereum.Factory_evt_PairCreatedwhere pair = {{Pair Address}}), all_router_swaps as (select call_tx_hash, path from uniswap_v2_ethereum.Router02_call_swapETHForExactTokenswhere call_success union allselect call_tx_hash, path from uniswap_v2_ethereum.Router02_call_swapExactETHForTokenswhere call_success union allselect call_tx_hash, path from uniswap_v2_ethereum.Router02_call_swapExactETHForTokensSupportingFeeOnTransferTokenswhere call_success union allselect call_tx_hash, path from uniswap_v2_ethereum.Router02_call_swapExactTokensForETHwhere call_success union allselect call_tx_hash, path from uniswap_v2_ethereum.Router02_call_swapExactTokensForETHSupportingFeeOnTransferTokenswhere call_success union allselect call_tx_hash, path from uniswap_v2_ethereum.Router02_call_swapExactTokensForTokenswhere call_success union allselect call_tx_hash, path from uniswap_v2_ethereum.Router02_call_swapExactTokensForTokensSupportingFeeOnTransferTokenswhere call_success union allselect call_tx_hash, path from uniswap_v2_ethereum.Router02_call_swapTokensForExactETHwhere call_success union allselect call_tx_hash, path from uniswap_v2_ethereum.Router02_call_swapTokensForExactTokens)--get all router02 swaps that used usdc/weth in the path, paths_nondirect as (selectp.*, s.path[1] as first_token, s.path[cardinality(path)] as last_token, s.call_tx_hash as tx_hash, s.path as full_pathfrom all_router_swaps s, pair_tokens p -- cross join here-- non direct swapswherecardinality(s.path) > 2 --where contains(path, 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2) --basic contains--for "and...or" you need parenthesisand (contains_sequence(s.path, array[p.token0, p.token1])OR contains_sequence(path, array[p.token1, p.token0]))), final as (selectconcat(coalesce(tk0.symbol, first_token), '/', coalesce(tk1.symbol, last_token)) as path_symbols, count(*) as times_routed, arbitrary(tx_hash) as example_hashfrom paths_nondirect pnleft join tokens.erc20 tk0 on tk0.contract_address = pn.first_token and tk0.blockchain = 'ethereum'left join tokens.erc20 tk1 on tk1.contract_address = pn.last_token and tk1.blockchain = 'ethereum'group by 1