with Lt1 as
(select DATE(block_timestamp) as date, sum(msg_value:"coins"[0]:"amount" / 1e6) as sum_total_deposits
FROM
terra.msgs
where tx_id in (
select TX_ID
FROM
terra.msg_events
WHERE event_attributes:"0_contract_address" = 'terra1j66jatn3k50hjtg2xemnjm8s7y8dws9xqa5y8w'
AND event_attributes:"0_action" = 'provide_liquidity'
and block_timestamp > '2021-12-26'
)
and block_timestamp > '2021-12-26'
GROUP BY 1
order by 1),
Lt2 as (
select DATE(block_timestamp) as date,
sum(msg_value:"execute_msg":"send":"amount" / 1e6) as sum_total_withdraw
FROM
terra.msgs
where tx_id in (
select TX_ID
FROM
terra.msg_events
WHERE event_attributes:"0_contract_address" = 'terra1nuy34nwnsh53ygpc4xprlj263cztw7vc99leh2'
AND event_attributes:"1_action" = 'withdraw_liquidity'
and block_timestamp > '2021-12-26'
)
and block_timestamp > '2021-12-26'
GROUP BY 1
order by 1
)
select
Lt1.date,
Lt1.sum_total_deposits,
Lt2.sum_total_withdraw