Query editor
withinflows as (select"from" as wallet, to as protocol_contract, date_trunc('day', tt.evt_block_time) as block_time, cast(value as double) / pow(10, COALESCE(tk.decimals, 18)) as token_value, tt.contract_address as contract_address, tk.symbol as symbol, get_href(get_chain_explorer_tx_hash('ethereum', cast(tt.evt_tx_hash as varchar)), cast(tt.evt_tx_hash as varchar)) as tx_hash, tt.evt_tx_hash, casewhen to = 0xEd7d74AA7eB1f12F83dA36DFaC1de2257b4e7523 then 'DAI'When to = 0x137000352B4ed784e8fa8815d225c713AB2e7Dc9 then 'USDC'when to = 0x28BC58e600eF718B9E97d294098abecb8c96b687 then 'USDT'end as amm_name, tr.function_name, tr.trace_address, tr.function_name as swap_typefrom erc20_ethereum.evt_Transfer as ttleft join tokens.erc20 as tk on tk.contract_address = tt.contract_addressleft join (select tx_hash, function_name, trace_addressfrom ethereum.traces_decodedwhere block_time >= cast('{{1. Start date}}' as timestamp)and block_time <= cast('{{2. End date}}' as timestamp)and function_name in ('openSwapPayFixed', 'openSwapReceiveFixed','openSwapPayFixed28daysUsdt','openSwapPayFixed60daysUsdt,','openSwapPayFixed90daysUsdt','openSwapReceiveFixed28daysUsdt','openSwapReceiveFixed60daysUsdt','openSwapReceiveFixed90daysUsdt','openSwapPayFixed28daysUsdc','openSwapPayFixed60daysUsdc','openSwapPayFixed90daysUsdc','openSwapReceiveFixed28daysUsdc','openSwapReceiveFixed60daysUsdc','openSwapReceiveFixed90daysUsdc','openSwapPayFixed28daysDai','openSwapPayFixed60daysDai','openSwapPayFixed90daysDai','openSwapReceiveFixed28daysDai','openSwapReceiveFixed60daysDai','openSwapReceiveFixed90daysDai')) as tr on tt.evt_tx_hash = tr.tx_hashwhere tt.evt_block_time >= cast('{{1. Start date}}' as timestamp)and tt.evt_block_time <= cast('{{2. End date}}' as timestamp)and to in (0xEd7d74AA7eB1f12F83dA36DFaC1de2257b4e7523, -- Milton DAI0x137000352B4ed784e8fa8815d225c713AB2e7Dc9, -- Milton USDC0x28BC58e600eF718B9E97d294098abecb8c96b687) -- Milton USDTand symbol is not NULLand tr.function_name in ('openSwapPayFixed', 'openSwapReceiveFixed','openSwapPayFixed28daysUsdt','openSwapPayFixed60daysUsdt,','openSwapPayFixed90daysUsdt'