Query editor
with transactions as (selectdate_trunc('day', block_time) as time,(cast(bytearray_to_uint256(bytearray_substring(data, 1 + 32 * 3, 32)) / 1e18 as double)+cast(bytearray_to_uint256(bytearray_substring(data, 1 + 32 * 4, 32)) / 1e18 as double)+cast(bytearray_to_uint256(bytearray_substring(data, 1 + 32 * 5, 32)) / 1e18 as double)+cast(bytearray_to_uint256(bytearray_substring(data, 1 + 32 * 6, 32)) / 1e18 as double)+cast(bytearray_to_uint256(bytearray_substring(data, 1 + 32 * 7, 32)) / 1e18 as double))as volume,casewhen bytearray_substring(data, 1 + 32 * 2, 32) = 0x0000000000000000000000000000000000000000000000000000000000000001 then 'buy'when bytearray_substring(data, 1 + 32 * 2, 32) = 0x0000000000000000000000000000000000000000000000000000000000000000 then 'sell'end as typefrom base.logswhere topic0 = 0x069a3131d4d72dbdcb40a0d8ff0aa58f71096c2726da05e3ed2608ddf1e93228and contract_address = 0x428aeF7fB31E4E86162D62d4530a4dd7232D953D),aggregated as (selecttime,sum(case when type = 'buy' then volume else 0 end) as buy_volume,sum(case when type = 'sell' then -volume else 0 end) as sell_volumefrom transactionsgroup by time)select * from aggregated