Query editor
-- select * from query_2448618 a-- join (select * from dex.trades where blockchain = 'arbitrum') d-- on a.evt_tx_hash = d.tx_hash-- join erc20_arbitrum.evt_Transfer et-- on a.evt_tx_hash = et.evt_tx_hash-- where-- select * from dex.trades-- where blockchain = 'arbitrum' and tx_hash = 0x3f7ad7c94e40ecf07d7cd40bda86df0c30731ed4a1a84a4f5f1a25ba6f9d1c4bwith source_dex_trades as (select *from dex.tradeswhere blockchain = 'arbitrum'-- and block_time > now() - interval '3' day-- and tx_hash = 0x3f7ad7c94e40ecf07d7cd40bda86df0c30731ed4a1a84a4f5f1a25ba6f9d1c4b), tx_cnt as (select tx_hash, count(*) as cntfrom source_dex_tradesgroup by 1), rn as (select*,ROW_NUMBER() over (partition by tx_hash order by evt_index) as rn_asc,ROW_NUMBER() over (partition by tx_hash order by evt_index desc) as rn_descfrom source_dex_trades d-- where blockchain = 'arbitrum'where d.tx_hash in (select tc.tx_hash from tx_cnt tc where cnt > 1)-- where blockchain = 'arbitrum' and d.tx_hash in (select evt_tx_hash from query_2448618)), loop as (select l.tx_hash, l.cntfrom (selectr1.tx_hash,count(*) as cnt-- r1.token_sold_symbol as token_sold_symbol_1,-- r1.token_bought_symbol as token_bought_symbol_1,-- r1.token_sold_amount as token_sold_amount_1,-- r1.token_bought_amount as token_bought_amount_1,-- r2.token_sold_symbol as token_sold_symbol_2,-- r2.token_bought_symbol as token_bought_symbol_2,-- r2.token_sold_amount as token_sold_amount_2,-- r2.token_bought_amount as token_bought_amount_2,-- r1.rn_asc as rn_asc,-- r2.rn_desc as rn_descfrom rn r1join rn r2 on r1.tx_hash = r2.tx_hash and r1.rn_asc + 1 = r2.rn_ascwhere r1.token_bought_address = r2.token_sold_address and r1.token_bought_amount = r2.token_sold_amountgroup by 1) ljoin tx_cnt tc on l.tx_hash = tc.tx_hashwhere l.cnt + 1 = tc.cnt)-- , loop_cnt as (-- select-- tx_hash,-- count(*) as cnt