Query editor
withallDate as (selectDATE_TRUNC('day', time) AS date_timefromarbitrum.blockswhere number >= 150048804GROUP by1),DFInDexTransaction as (selecta.block_time,BYTEARRAY_TO_UINT256 (data) / 1e18 as valuefromarbitrum.logs awherea.contract_address = 0xaE6aab43C4f3E0cea4Ab83752C278f8dEbabA689and topic0=0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efand from_hex(CONCAT('0x', SUBSTRING(TRY_CAST(topic2 AS VARCHAR), 27, 40))) in(0x3d285a3713B6F186F488765BeF01F376188384f2)),DFOutDexTransaction as (selecta.block_time,BYTEARRAY_TO_UINT256 (data) / 1e18 as valuefromarbitrum.logs awherea.contract_address = 0xaE6aab43C4f3E0cea4Ab83752C278f8dEbabA689and topic0=0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efand from_hex(CONCAT('0x', SUBSTRING(TRY_CAST(topic1 AS VARCHAR), 27, 40))) in(0x3d285a3713B6F186F488765BeF01F376188384f2)),df_daily_in_value as (select a.date_time, sum(if(b.value is null, 0, b.value)) as value from allDate a LEFT JOIN DFInDexTransaction b ON date_time = DATE_TRUNC('day', b.block_time) group by 1),df_daily_out_value as (select a.date_time, sum(if(b.value is null, 0, b.value)) as value from allDate a LEFT JOIN DFOutDexTransaction b ON date_time = DATE_TRUNC('day', b.block_time) group by 1),tmp as (selecta.date_time,a.value+b.value as volume,sum(a.value) OVER (ORDER BY a.date_time) as grossIn,sum(b.value) OVER (ORDER BY b.date_time) as grossOutfrom df_daily_in_value a LEFT JOIN df_daily_out_value b on a.date_time=b.date_timewhere TRY_CAST(a.date_time AS DATE) > TRY_CAST((CURRENT_TIMESTAMP - INTERVAL '14' day) AS DATE)),dailyGrossIn as (selectDISTINCTa.date_time,b.value,sum(b.value) over(ORDER by a.date_time) as grossfrom allDate a left join DFInDexTransaction b on a.date_time=DATE_TRUNC('day', b.block_time)