Query editor
with p1inch as (select price as inch_usd from prices.usd where blockchain='ethereum'and contract_address=0x111111111117dc0aa78b770fa6a738034120c302 and minute >= now()-interval '1' day order 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 ethereum.logs where topic0=0x54bc5c027d15d7aa8ae083f994ab4411d2f223291672ecd3a344f3d92dcaf8b2and contract_address=0x111111338c5091e8440b67b168bae16a668ac0de and block_time >= now()-interval '10' day),valued as (select f.block_time, f.maker,case when si.symbol='1INCH' then cast(f.amount_in as double)/1e18*coalesce((select inch_usd from p1inch),0.08)when so.symbol='1INCH' then cast(f.amount_out as double)/1e18*coalesce((select inch_usd from p1inch),0.08) end as usdfrom fills fleft join tokens.erc20 si on si.blockchain='ethereum' and si.contract_address=f.token_inleft join tokens.erc20 so on so.blockchain='ethereum' and so.contract_address=f.token_outwhere '1INCH' in (si.symbol, so.symbol)and (upper(si.symbol) in ('PAXG','XAUT','NVDAON','TSLAON','AAPLON','SPYON','METAON','AMZNON','CRCLON','GOOGLON','QQQON','NVDAX','TSLAX','AAPLX','SPYX','METAX','AMZNX','SYRUPUSDC','SYRUPUSDT','USDY')or upper(so.symbol) in ('PAXG','XAUT','NVDAON','TSLAON','AAPLON','SPYON','METAON','AMZNON','CRCLON','GOOGLON','QQQON','NVDAX','TSLAX','AAPLX','SPYX','METAX','AMZNX','SYRUPUSDC','SYRUPUSDT','USDY')))select date_trunc('day',block_time) as day, round(sum(usd)) as total_volume_usd,round(sum(case when maker=0xfDad50617fcDa25Ca2904A645BCA6607f212A7C5 then usd end)) as my_volume_usd,round(100.0*sum(case when maker=0xfDad50617fcDa25Ca2904A645BCA6607f212A7C5 then usd end)/nullif(sum(usd),0),3) as my_share_pctfrom valued group by 1 order by 1 desc