Query editor
with date_filter as (selectcasewhen {{n_days}} != 0 then date_add('day', -{{n_days}}, now())else cast('{{start_date}}' as timestamp)end as start_date,casewhen {{n_days}} != 0 then date_add('day', 1, now())else cast('{{end_date}}' as timestamp)end as end_date),dex_trades_sample as (selecttx_id,block_time,block_slot,trader_id,project,inner_instruction_index,token_sold_symbol,token_bought_symbol,token_sold_amount,token_bought_amount,token_sold_mint_address,token_bought_mint_address,amount_usd,tx_indexfrom dex_solana.tradesjoin date_filteron block_time between start_date and end_dateand block_date between cast(start_date as date) and cast(end_date as date)wherenot (coalesce(token_sold_amount_raw, 0) = 0and coalesce(token_bought_amount_raw, 0) = 0)),ordered_dex_trades_sample as (select*,row_number() over (partition by tx_idorder by inner_instruction_index asc) as first_vertex,row_number() over (partition by tx_idorder by inner_instruction_index desc) as last_vertexfrom dex_trades_sample),possible_arbs as (selectfv.block_time,fv.tx_id,