Query editor
-- with a1 as (SELECT-- DATE_TRUNC('day',block_time) AS day,-- sum(value/1e18) as value-- FROM avalanche_c.traces-- WHERE to = 0xa481b139a1a654ca19d2074f174f17d7534e8cec-- -- or to = 0x563395a2a04a7ae0421d34d62ae67623caf67d03-- and call_type = 'call'-- AND tx_success-- AND success-- and block_time > timestamp '2023-09-20'-- and block_time < timestamp '2023-10-08'-- GROUP BY 1),-- a3 as(SELECT-- DATE_TRUNC('day',block_time) AS day,-- -sum(value/1e18) as value-- FROM avalanche_c.traces-- WHERE "from" = 0xa481b139a1a654ca19d2074f174f17d7534e8cec-- -- or "from" = 0x563395a2a04a7ae0421d34d62ae67623caf67d03-- and call_type = 'call'-- AND tx_success-- AND success-- and block_time > timestamp '2023-09-20'-- and block_time < timestamp '2023-10-08'-- GROUP BY 1),-- a2 as (select-- date_trunc('day',minute) as month,-- avg(price) as price-- from prices.usd-- where symbol = 'AVAX'-- and minute > timestamp '2023-06-01'-- and blockchain is null-- group by 1)-- select-- a1.day,-- a1.value * a2.price as inflow,-- a3.value * a2.price as outflow,-- -- (a1.value+a3.value) * a2.price as usd_tvl,-- case when sum((a1.value+a3.value) * a2.price)over(order by a1.day) < 0 then 0-- else sum((a1.value+a3.value) * a2.price)over(order by a1.day)-- end as cumulative-- from a1-- left join a2 on a1.day = a2.month-- left join a3 on a1.day = a3.day)with a1 as (SELECTDATE_TRUNC('day',block_time) AS day,sum(value/1e18) as valueFROM avalanche_c.tracesWHERE to = 0x563395a2a04a7ae0421d34d62ae67623caf67d03and call_type = 'call'AND tx_successAND successGROUP BY 1),a3 as(SELECTDATE_TRUNC('day',block_time) AS day,-sum(value/1e18) as valueFROM avalanche_c.tracesWHERE "from" = 0x563395a2a04a7ae0421d34d62ae67623caf67d03and call_type = 'call'