Query editor
withstatic as (select'{{timebox for distribution by direction}}' as timebox, date_trunc('{{timebox for distribution by direction}}', timestamp '{{displayed period from for distribution by direction}}') as displayed_from, depth['{{timebox for distribution by direction}}'] as depth_back_seconds, to_unixtime(next['{{timebox for distribution by direction}}']) - to_unixtime(now()) as seconds_left_in_timeboxfrom query_3298581), stat as (selectdate_trunc((select timebox from static), block_time) as time, count(*) as swaps, count(*) filter(where direct) as swaps_direct, count(*) filter(where not direct) as swaps_external, count(*) filter(where last_period) as swaps_last_period, sum(count(*)) over(order by date_trunc((select timebox from static), block_time)) as swaps_cumulative, count(distinct tx_hash) as txs, sum(amount_usd) as volume, sum(amount_usd) filter(where direct) as volume_direct, sum(amount_usd) filter(where not direct) as volume_external, sum(amount_usd) filter(where last_period) as volume_last_period, sum(sum(amount_usd)) over(order by date_trunc((select timebox from static), block_time)) as volume_cumulative, count(distinct user) as wallets, count_if(wallet_rn = 1) as wallets_new, count(distinct user) filter(where last_period) as wallets_last_period, sum(count_if(wallet_rn = 1)) over(order by date_trunc((select timebox from static), block_time)) as wallets_cumulativefrom (selectblockchain, block_time, tx_hash, user, call_trace_address, flags['direct'] as direct, block_time > date_add('second', -(select depth_back_seconds from static), now()) as last_period, amount_usd, row_number() over(partition by user order by block_time) as wallet_rnfrom oneinch.swapswhereif('{{blockchain}}' = '= all =', true, blockchain = '{{blockchain}}')and (protocol = 'AR' or flags['second_side'])and tx_success and call_success)group by 1)selecttime, swaps, swaps_direct, swaps_external, swaps_cumulative, if(time = date_trunc((select timebox from static), now()), sum(swaps_last_period) over() * (select seconds_left_in_timebox from static) / (select depth_back_seconds from static)) as swaps_predicted, txs, volume, volume_direct, volume_external