Query editor
with registry as (selectwallet,required_for_symbolsfrom query_6953003),target_symbols as (select *from (values('ethereum', 'LINK', 'LINK_USDT'),('arbitrum', 'ARB', 'ARB_USDT'),('optimism', 'OP', 'OP_USDT')) as t(blockchain, token_symbol, symbol)),recent_trades as (selectlower(to_hex(t.tx_from)) as wallet,lower(t.blockchain) as blockchain,t.block_time,ts.symbol,casewhen upper(t.token_bought_symbol) = ts.token_symbol then 'buy'when upper(t.token_sold_symbol) = ts.token_symbol then 'sell'end as side,cast(t.amount_usd as double) as amount_usdfrom dex.trades tjoin target_symbols tson lower(t.blockchain) = ts.blockchainand (upper(t.token_bought_symbol) = ts.token_symbolor upper(t.token_sold_symbol) = ts.token_symbol)join registry ron lower(to_hex(t.tx_from)) = r.walletand ts.symbol = r.required_for_symbolswhere t.block_time >= now() - interval '12' hourand t.amount_usd is not nulland cast(t.amount_usd as double) >= 100and t.tx_from is not null),aggregated as (selectwallet,symbol,max(block_time) as ts,count(*) as trades_recent,sum(case when side = 'buy' then amount_usd else 0 end) as buy_usd_recent,sum(case when side = 'sell' then amount_usd else 0 end) as sell_usd_recentfrom recent_tradesgroup by 1, 2),signals as (selectwallet,symbol,