Query editor
with--this is all to get the contract_address and blockchain of the inputted paramsselected_tokens as (SELECTdistinct symbol, contract_address, blockchain, decimalsFROM (SELECTsymbol, blockchain, max_by(contract_address, transfers) as contract_address, max_by(decimals, transfers) as decimalsFROM (SELECTupper(tk.symbol) as symbol, tk.contract_address, tk.blockchain, tk.decimals, COALESCE(count(*),0) as transfersFROM tokens.erc20 tkLEFT JOIN evms.erc20_transfers tr ON tk.blockchain = tr.blockchainAND tk.contract_address = tr.contract_addressAND tr.evt_block_time > now() - interval '5' day --should be good enough time filterAND tr.blockchain = '{{3. Blockchain}}'WHERE contains(split(replace('{{1. Token Symbols}}',' ',''),','), upper(tk.symbol))and tk.blockchain = '{{3. Blockchain}}'group by 1,2,3,4) group by 1,2UNION ALLSELECTtk.symbol, '{{3. Blockchain}}' as blockchain, from_hex(trim(c.address)) as contract_address, COALESCE(tk.decimals, 18) as decimalsFROM unnest(split('{{2. Token Contracts}}',',')) as c(address)LEFT JOIN tokens.erc20 tk ON tk.contract_address = try(from_hex(trim(c.address))) AND tk.blockchain = '{{3. Blockchain}}'WHERE try(from_hex(trim(c.address))) is not nulland lower(c.address) != 'none'and try(from_hex(trim(c.address))) not in (SELECT distinct contract_address FROM tokens.erc20))), dex_trades as (SELECTd.token_bought_address as token_address,case when token_bought_amount != cast(token_bought_amount as double) then d.amount_usd/d.token_bought_amountelse d.amount_usd/(cast(d.token_bought_amount as double))end as price,'buy' as action,d.token_bought_amount as amount,d.tx_from as trader,d.block_time,d.blockchainFROM dex.trades dWHERE d.amount_usd > 0AND cast(d.token_bought_amount as double) > 0AND blockchain = '{{3. Blockchain}}'AND block_time > now() - interval '{{4. Days}}' day