Query editor
with decoded as (selectblock_time, tx_hash, "from", input, output, SUBSTR(TO_HEX(input), 1, 8) as selector, casewhen SUBSTR(TO_HEX(input), 1, 8) = 'D808D889' then 81when SUBSTR(TO_HEX(input), 1, 8) = '0DC4BDAE' then 433when SUBSTR(TO_HEX(input), 1, 8) = 'B9B5149B' then 49end as tuple_startfrom polygon.traceswhere block_time > now() - interval '10' dayand success = falseand to = 0x07964f135f276412b3182a3b2407b8dd45000000and SUBSTR(TO_HEX(input), 1, 8) in ('D808D889', '0DC4BDAE', 'B9B5149B')and LOWER(CAST(output as VARCHAR)) like '%' || LOWER(TO_HEX(TO_UTF8({{error_message}}))) || '%'),decoded_tokens as (selectblock_time, tx_hash, varbinary_substring(input, tuple_start, 20) as token0_address, varbinary_substring(input, tuple_start + 32, 20) as token1_addressfrom decoded)selectdate_trunc('day', dt.block_time) as "day", CONCAT(casewhen dt.token0_address = 0x0000000000000000000000000000000000000000 then 'POL'else COALESCE(e0.symbol, LOWER(CONCAT('0x', TO_HEX(dt.token0_address))))end, '-', casewhen dt.token1_address = 0x0000000000000000000000000000000000000000 then 'POL'else COALESCE(e1.symbol, LOWER(CONCAT('0x', TO_HEX(dt.token1_address))))end) as "token0-token1",CONCAT('0x', TO_HEX(dt.token0_address), '-', '0x', TO_HEX(dt.token1_address)),count(distinct dt.tx_hash) as countsfrom decoded_tokens dtleft join tokens.erc20 e0on e0.blockchain = 'polygon'and e0.contract_address = dt.token0_addressleft join tokens.erc20 e1on e1.blockchain = 'polygon'and e1.contract_address = dt.token1_addressgroup by1, 2, 3order by1 desc, 4 desc;