Query editor
with cls as (select addr, cls from (values(0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, 'eth'),(0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48, 'stable'), (0xdac17f958d2ee523a2206206994597c13d831ec7, 'stable'),(0x6b175474e89094c44da98b954eedeac495271d0f, 'stable'), (0xdc035d45d973e3ec169d2276ddab16f1e407384f, 'stable'),(0x6c3ea9036406852006290770bedfcaba0e23a0e8, 'stable'), (0x4c9edd5852cd905f086c759e8383e09bee1e68e9, 'stable'),(0x9d39a5de30e57443bff2a8307a4256c8797a3497, 'stable'), (0xe343167631d89b6ffc58b88d6b7fb0228795491d, 'stable'),(0x8292bb45bf1ee4d140127049757c2e0ff06317ed, 'stable'), (0xc5f0f7b66764f6ec8c8dff7ba683102295e16409, 'stable'),(0x8d0d000ee44948fc98c9b98a4fa4921476f08b0d, 'stable'), (0x853d955acef822db058eb8505911ed77f175b99e, 'stable'),(0xcacd6fd266af91b8aed52accc382b4e165586e29, 'stable'), (0xf939e0a03fb07f59a73314e73794be0e57ac1b4e, 'stable'),(0x40d16fc0246ad3160ccc09b8d0d3a2cd28ae6c2f, 'stable'), (0x0000000000085d4780b73119b644ae5ecd22b376, 'stable'),(0x8e870d67f660d95d5be530380d0ec0bd388289e1, 'stable'), (0x5f98805a4e8be255a32880fdec7f6728c6568ba0, 'stable'),(0x73a15fed60bf67631dc6cd7bc5b6e8da8190acf5, 'stable'), (0xc139190f447e929f090edeb554d95abb8b18ac1c, 'stable'),(0x15700b564ca08d9439c58ca5053166e8317aa138, 'stable'), (0x0c10bf8fcb7bf5412187a595ab97a3609160b5c6, 'stable'),(0x1abaea1f7c830bd89acc67ec4af516284b1bc33c, 'stable'),(0x2260fac5e5542a773aa44fbcfedf7c193bc2c599, 'btc'), (0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf, 'btc'),(0x18084fba666a33d37592fa2633fd49a74dd93a88, 'btc'), (0x8236a87084f8b84306f72007f36f2618a5634494, 'btc'),(0x7a56e1c57c7475ccf742a1832b028f0456652f97, 'btc'), (0x657e8c867d8b37dcc18fa4caead9c45eb088c642, 'btc'),(0xc96de26018a54d51c097160568752c4e3bd6c364, 'btc'),(0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0, 'lst'), (0xae7ab96520de3a18e5e111b5eaab095312d7fe84, 'lst'),(0xae78736cd615f374d3085123a210448e74fc6393, 'lst'), (0xbe9895146f7af43049ca1c1ae358b0541ea49704, 'lst'),(0xcd5fe23c85820f7b72d0926fc9b05b43e359b7ee, 'lst'), (0x35fa164735182de50811e8e2e824cfb9b6118ac2, 'lst'),(0xbf5495efe5db9ce00f80364c8b423567e58d2110, 'lst'), (0xa1290d69c65a6fe4df752f95823fae25cb99e5a7, 'lst'),(0xfae103dc9cf190ed75350761e95403b7b8afa6c0, 'lst'), (0xa35b1b31ce002fbf2058d22f30f95d405200a15b, 'lst'),(0x5e8422345238f34275888049021821e8e08caa1f, 'lst'), (0xac3e018457b222d93114458476f3e3416abbe38f, 'lst'),(0xd5f7838f5c461feff7fe49ea5ebaf7728bb0adfa, 'lst'), (0xd9a442856c234a39a81a089c06451ebaa4306a72, 'lst'),(0xf951e335afb289353dc249e82926178eac7ded78, 'lst'), (0xf1c9acdc66974dfb6decb12aa385b9cd01190e38, 'lst')) as t(addr, cls)),tk as (select contract_address, symbol, decimalsfrom tokens.erc20where blockchain = 'ethereum'),pxd as (select contract_address, day, pricefrom prices.usd_dailywhere blockchain = 'ethereum' and day >= current_date - interval '{{window_days}}' day - interval '1' day),orders as (select o.evt_tx_hash as tx_hash,o.evt_block_time as bt,date_trunc('day', o.evt_block_time) as day,case when o.fromToken = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee then 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 else o.fromToken end as from_t,case when o.toToken = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee then 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 else o.toToken end as to_t,o.fromAmount, o.returnAmountfrom (-- two decoded namespaces = two DexRouter generations (see q281 header); disjoint ⇒ UNION ALL exactselect evt_tx_hash, evt_block_time, fromToken, toToken, fromAmount, returnAmountfrom okx_dex_v4_ethereum.dexrouter_evt_orderrecordwhere evt_block_time >= now() - interval '{{window_days}}' dayunion allselect evt_tx_hash, evt_block_time, fromToken, toToken, fromAmount, returnAmountfrom okx_ethereum.dexrouter_evt_orderrecordwhere evt_block_time >= now() - interval '{{window_days}}' day) o),sided as (select o.*,coalesce(ta.symbol, '0x' || substr(to_hex(o.from_t), 1, 8)) as s_from,