Query editor
with fusion_trade as (select block_time, tx_hash, resolver_name as solver, taker as user, sum(volume) as trade_usd,max(CASEWHEN lower(taker_token_symbol) > lower(maker_token_symbol) THEN concat(maker_token_symbol, '-', taker_token_symbol)ELSE concat(taker_token_symbol, '-', maker_token_symbol)END) AS trade_pair -- for filling in the missing liquidity / direct rfq case, max(maker) as maker -- assuming only used when there is no amm so max shall not affectfrom dune.flashbots.result_1inch_fusion_txs_alltimegroup by 1, 2, 3, 4), dedup_fusion_lop_from_base_dex as (select t.*from query_3151907 tleft join dune.flashbots.result_1inch_fusion_txs_alltime tt on t.tx_hash = tt.tx_hashand tt.taker_token_address = t.taker_tokenand tt.maker_token_address = t.maker_tokenand tt.taker_token_amount_raw = t.taker_token_amount_rawand tt.maker_token_amount_raw = t.maker_token_amount_rawand t.project = '1inch Limit Order Protocol'where tt.tx_hash is null)selectf.tx_hash as hash,f.block_time,b."number" as block_number,'1inch Website: Default' as frontend,f.user,'1inch Fusion' as metaaggregator,solver,trade_usd, -- user side from fusion trade totalf.trade_pair,'' as aggregator,coalesce(t.token_pair, f.trade_pair) as token_pair,coalesce(amount_usd, trade_usd) as amount_usd,case when t.project ='uniswap' then concat('Uniswap V', t.version)when t.project LIKE '%1inch%' then(case when lower(t.version) LIKE '%rfq%' then '1inch RFQ'else '1inch Limit Orders' end)when t.project = '0x API' then 'Other RFQ'else CONCAT(UPPER(SUBSTRING(t.project, 1, 1)),SUBSTRING(t.projectFROM2))end as liquidity_src,-- else 'Other DEXes' end as liquidity_src,case when t.project = 'Hashflow' then pmmwhen t.project LIKE '%1inch%' and lower(t.version) LIKE '%rfq%' then coalesce(mm.name || ' PMM', '1inch PMM')-- makerwhen t.project is null then coalesce(mm.name || ' PMM', mm2.name || ' PMM', concat(solver, ' PMM')) else null end as pmm, f.maker -- temp for qafrom fusion_trade fjoin ethereum.blocks b on f.block_time = b."time"left join dedup_fusion_lop_from_base_dex t on f.tx_hash = t.tx_hashleft join query_2812729 mm on mm.address = t.makerleft join query_2812729 mm2 on mm2.address = f.maker