John_GaltFury Forge - Date and Price
    Updated 2022-07-07
    with deposit1 as (select
    tx_id
    from terra.msg_events
    where date(block_timestamp) > '2022-04-01'
    and event_attributes:contract_address= 'terra1vsdd5zp8jwq9k6zdj805w2szaaq4eakldwydlq'
    and event_attributes:action = 'deposit'
    and event_index = 6
    ),

    deposit2 as (select
    block_timestamp as date,
    fl.value:amount / pow(10, 6) as deposit_amount,
    tx_id
    from terra.msg_events,
    lateral flatten(input => event_attributes:amount) fl
    where date(block_timestamp) > '2022-04-01'
    and event_attributes:recipient = 'terra1vsdd5zp8jwq9k6zdj805w2szaaq4eakldwydlq'
    and event_index = 5
    ),

    deposit_final as (select
    date_trunc('hour', deposit2.date) as Day_Hour, sum(deposit2.deposit_amount) as deposit_amount
    from deposit2
    inner join deposit1 on deposit1.tx_id = deposit2.tx_id
    group by day_hour
    ),

    withdraw1 as (select
    tx_id
    from terra.msg_events
    where date(block_timestamp) > '2022-04-01'
    and event_attributes:contract_address = 'terra1vsdd5zp8jwq9k6zdj805w2szaaq4eakldwydlq'
    and event_attributes:action = 'withdraw'
    and event_index = 6
    ),