with deposits as (select
date_trunc('day', block_timestamp) as day,
sum(LP_TOKEN_AMOUNT_USD) as total_deposited
from optimism.velodrome.ez_lp_actions
where lp_action = 'deposit'
group by day
),
withdraws as (select
date_trunc('day', block_timestamp) as day,
sum(LP_TOKEN_AMOUNT_USD) as total_withdrawn
from optimism.velodrome.ez_lp_actions
where lp_action = 'withdraw'
group by day
)
select
date(d.day) as date,
d.total_deposited,
w.total_withdrawn,
d.total_deposited - w.total_withdrawn as net_deposited
from deposits d, withdraws w
where d.day = w.day