Query editor
-- Panel 1: Copy-trader detection-- Who enters the tokens you enter, within 60 seconds of you, again and again.-- Rule: follower's first buy of a token lands within 60s after this wallet's first buy of it, on 3+ distinct tokens, last 30 days.with p as (select from_hex(replace(lower(trim('{{wallet}}')), '0x', '')) as w),quote_tokens as (select t from (values(0x82af49447d8a07e3bd95bd0d56f35241523fbab1), -- WETH arbitrum(0x4200000000000000000000000000000000000006), -- WETH base(0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c), -- WBNB(0x55d398326f99059ff775485246999027b3197955), -- USDT bnb(0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9), -- USDT arbitrum(0xaf88d065e77c8cc2239327c5edb3a432268e5831), -- USDC arbitrum(0xff970a61a04b1ca14834a43f5de4533ebddb5cc8), -- USDC.e arbitrum(0x833589fcd6edb6e08f4c7c32d4f71b54bda02913), -- USDC base(0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d), -- USDC bnb(0xe9e7cea3dedca5984780bafc599bd69add087d56), -- BUSD bnb(0x8d0d000ee44948fc98c9b98a4fa4921476f08b0d), -- USD1 bnb(0xda10009cbd5d07dd0cecc66161fc93d7c9000da1), -- DAI arbitrum(0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f), -- WBTC arbitrum(0x7130d2a12b9bcbfae4f2634d864a1ee1ce3ead9c) -- BTCB bnb) as x(t)),-- this wallet's first buy (entry) of each token in the windowmy_entries as (select blockchain, token_bought_address as token, min(block_time) as entry_timefrom dex.tradeswhere taker = (select w from p)and blockchain in ('arbitrum','base','bnb')and block_month >= date_trunc('month', current_date - interval '30' day)and block_date >= current_date - interval '30' dayand token_bought_address not in (select t from quote_tokens)group by 1, 2),-- every other wallet's first buy (entry) of those same tokens in the windowother_entries as (select t.blockchain, t.taker, t.token_bought_address as token,min(t.block_time) as entry_time,min_by(t.amount_usd, t.block_time) as entry_usdfrom dex.trades tjoin my_entries mon m.blockchain = t.blockchainand m.token = t.token_bought_addresswhere t.blockchain in ('arbitrum','base','bnb')and t.block_month >= date_trunc('month', current_date - interval '30' day)and t.block_date >= current_date - interval '30' dayand t.taker != (select w from p)group by 1, 2, 3),pairs as (select o.taker as follower, o.blockchain, o.token, o.entry_usd,date_diff('second', m.entry_time, o.entry_time) as delay_secfrom other_entries ojoin my_entries mon m.blockchain = o.blockchain and m.token = o.tokenwhere o.entry_time between m.entry_time and m.entry_time + interval '60' second)selectfollower,