Query editor
-- 0xb4e16d0168e52d35cacd2c6185b44281ec28c9dcwithfrequency as (selectdate_trunc('week', evt_block_time) as time, count(*) as num_swapsfrom uniswap_v2_ethereum.Pair_evt_Swapwhere contract_address = 0xb4e16d0168e52d35cacd2c6185b44281ec28c9dcgroup by 1),volume as (withbase as (selectdate_trunc('minute', s.evt_block_time) as time, case when cast(amount0Out as double) = 0 then p.token1 else p.token0 end as token_bought_address, case when cast(amount0Out as double) = 0 then cast(amount1Out as double) else cast(amount0Out as double) end as token_bought_amount_rawfrom uniswap_v2_ethereum.Pair_evt_Swap sleft join uniswap_v2_ethereum.Factory_evt_PairCreated p on p.pair = s.contract_addresswhere s.contract_address = 0xb4e16d0168e52d35cacd2c6185b44281ec28c9dc)selectdate_trunc('week', b.time) as time, sum(token_bought_amount_raw / pow(10, COALESCE(t.decimals,18)) * p.price) as total_usd_amountfrom base bleft join tokens.erc20 t on t.contract_address = b.token_bought_addressleft join prices.usd p on p.minute = b.time and p.blockchain = 'ethereum' and p.contract_address = b.token_bought_addressgroup by 1), dex_trades as (selectdate_trunc('week', block_date) week, sum(amount_usd) total_usd_amount_dxfrom dex.tradeswhere blockchain = 'ethereum'and project_contract_address = 0xb4e16d0168e52d35cacd2c6185b44281ec28c9dcgroup by 1)selectv.time, f.num_swaps, v.total_usd_amount, dx.total_usd_amount_dxfrom volume vleft join frequency f on f.time = v.timeleft join dex_trades dx on dx.week = v.time