Query editor
with result as (selecttx_hash,block_time,block_number,user,tx_to, -- used later to find the makercoalesce(case when tx_to = 0x5050e08626c499411b5d0e0b5af0e83d3fd82edf then 'SCP' else resolver_name end, 'UNREGISTERED') as solver,CASEWHEN src_token_symbol < dst_token_symbol THEN src_token_symbol || '-' || dst_token_symbolELSE dst_token_symbol || '-' || src_token_symbolEND as trade_pair,amount_usd as trade_usd,src_token_address as taker_token_address,dst_token_address as maker_token_address,src_token_amount as taker_token_amount_raw,dst_token_amount as maker_token_amount_raw,src_token_symbol as taker_token_symbol,dst_token_symbol as maker_token_symbolfrom oneinch.swaps sleft join oneinch.fusion_accounts f on f.address = s.tx_fromwhereflags['fusion']and f.blockchain = 'ethereum'and s.blockchain = 'ethereum'and s.block_time >= now() - interval '7' day-- src taker -- dst maker), token_transfers as (select tx_hash, --maker_token_amount_raw,maker_token_address, max(t."from") as maker -- mm or amm-- may not handle the 2 mm filling rfq orders with same amount case, one maker will be recorded-- may not handle the intermediate contract proxy case, only checking the one sending to settlement directlyfrom erc20_ethereum.evt_Transfer tjoin result on t.evt_tx_hash = result.tx_hash-- and t.value = maker_token_amount_rawand t.contract_address = maker_token_addresswhere (case when tx_to=0x5050e08626c499411b5d0e0b5af0e83d3fd82edfthen t."to" != result."user"else t."from" != tx_to end) -- make sure the token from is not the settler contract, but the maker-- special casing SCP's trades: they use 5050 as both router and maker, and another proxy to transfer between-- usually solver has a router, and a different maker address-- e.g. https://etherscan.io/tx/0xcf92c08adf776f7886013931e04f03686c91582120a78521005f97f9be7a786c-- t."to" = tx_to -- 1inch settlement contract-- and t."from" != result."user"-- and evt_block_time > date('2022-12-25')and evt_block_time >= now() - interval '7' daygroup by 1,2--,3) select r.*, t.makerfrom result rleft join token_transfers t on r.tx_hash = t.tx_hash-- and r.maker_token_amount_raw = t.maker_token_amount_rawand r.maker_token_address = t.maker_token_address