Query editor
with p1inch as (select price as inch_usd from prices.usdwhere blockchain='ethereum'and contract_address = 0x111111111117dc0aa78b770fa6a738034120c302and minute >= now() - interval '1' dayorder by minute desc limit 1),fills as (select block_time,bytearray_substring(data, 45, 20) as maker,bytearray_substring(data, 109, 20) as token_in,bytearray_substring(data, 141, 20) as token_out,bytearray_to_uint256(bytearray_substring(data, 161, 32)) as amount_in,bytearray_to_uint256(bytearray_substring(data, 193, 32)) as amount_outfrom robinhood.logswhere topic0 = 0x54bc5c027d15d7aa8ae083f994ab4411d2f223291672ecd3a344f3d92dcaf8b2and contract_address = 0x111111338c5091e8440b67b168bae16a668ac0deand block_time >= now() - interval '90' day),valued as (select f.block_time, f.maker,casewhen si.symbol='1INCH' then cast(f.amount_in as double)/power(10,coalesce(si.decimals,18)) * coalesce((select inch_usd from p1inch),0.08)when so.symbol='1INCH' then cast(f.amount_out as double)/power(10,coalesce(so.decimals,18)) * coalesce((select inch_usd from p1inch),0.08)end as usdfrom fills fleft join tokens.erc20 si on si.blockchain='robinhood' and si.contract_address=f.token_inleft join tokens.erc20 so on so.blockchain='robinhood' and so.contract_address=f.token_outwhere '1INCH' in (si.symbol, so.symbol)and (si.symbol in ('VIRTUAL')or so.symbol in ('VIRTUAL')))selectdate_trunc('day', block_time) as day,sum(usd) as total_volume_usd,sum(case when maker = 0x38a2ad303a7A400F7FF521caef0700bd9E57EC34 then usd end) as my_volume_usd,100.0 * sum(case when maker = 0x38a2ad303a7A400F7FF521caef0700bd9E57EC34 then usd end)/ nullif(sum(usd),0) as my_share_pctfrom valuedgroup by 1order by 1 desc