With delegations_monkeydao as (
select
tx_id,
block_timestamp,
instruction:parsed:info:stakeAuthority::string as delegator
from solana.events
where block_timestamp >= '2022-02-01'
and block_timestamp < '2022-02-17'
and event_type = 'delegate'
and instruction:parsed:info:voteAccount ='DfpdmTsSCBPxCDwZwgBMfjjV8mF8xHkGRcXP8dJBVmrq' -- monkey dao validator
and succeeded = 'TRUE'
)
Select
date_trunc('day',block_timestamp) as date,
sum(instruction:parsed:info:lamports) / pow(10,9) as sol_amount_delegated,
sum(sol_amount_delegated) over (order by date) as cumulative_delegations
from solana.events
where block_timestamp >= '2022-02-01'
and event_type = 'createAccount'
and tx_id IN (select tx_id from delegations_monkeydao)
group by date
order by date desc