Query editor
-- USDC-WETH v3: 0x88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640WITHpair_tokens AS (SELECT token0, token1FROM uniswap_v3_ethereum.Factory_evt_PoolCreatedWHERE pool = {{D3_Pool Contract}}),all_router_swaps AS (SELECTcall_tx_hash, pathFROM uniswap_v3_ethereum.SwapRouter02_call_swapExactTokensForTokensWHERE call_successUNION ALLSELECTcall_tx_hash, pathFROM uniswap_v3_ethereum.SwapRouter02_call_swapTokensForExactTokensWHERE call_success),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 sLEFT JOIN pair_tokens p ON true -- cross joinWHERE cardinality(s.path) > 2 -- the path column is the sequence of tokens swapped. >2 is indirect swapsAND ( contains_sequence(s.path, array[p.token0, p.token1])OR contains_sequence(s.path, array[p.token1, p.token0]) ))-- ,-- swapped_amount AS (-- SELECT-- ABS(cs.output_amount0) / POWER(10, COALESCE(p0.decimals, 18)) * p0.price AS usd_amount-- , call_tx_hash-- , call_trace_address-- FROM uniswap_v3_ethereum.Pair_call_swap cs -- function table has trace address, event table doesn't-- LEFT JOIN uniswap_v3_ethereum.Factory_evt_PoolCreated pc-- ON pc.pool = cs.contract_address-- LEFT JOIN prices.usd p0 ON p0.contract_address = pc.token0-- AND date_trunc('minute', p0.minute) = date_trunc('minute', cs.call_block_time)-- AND p0.blockchain = 'ethereum'-- WHERE call_tx_hash IN (SELECT tx_hash FROM paths_nondirect)-- AND call_trace_address IN (SELECT call_trace_address FROM paths_nondirect)-- ),final AS (SELECTCONCAT(coalesce(t0.symbol, cast(pn.first_token as varchar)), '-', coalesce(t1.symbol, cast(pn.last_token as varchar)) ) AS path_symbols, COUNT(*) AS times_routed