mariyaNet deposit of Luna on Mars protocol
    Updated 2022-04-09
    with dep as(
    SELECT --*
    date_trunc('day', block_timestamp) AS dt1,
    sum(EVENT_ATTRIBUTES:"0_amount")/1e6 as daily_deposit
    FROM terra.msg_events
    where EVENT_ATTRIBUTES:"0_action"='deposit'
    and EVENT_ATTRIBUTES:asset='uluna'
    and EVENT_ATTRIBUTES:"0_contract_address"='terra19dtgj9j5j7kyf3pmejqv8vzfpxtejaypgzkz5u'
    and tx_status = 'SUCCEEDED'
    group by 1),

    witd as(
    SELECT
    date_trunc('day', block_timestamp) AS dt2,
    sum(EVENT_ATTRIBUTES:"0_amount")/1e6 as daily_withdraw
    FROM terra.msg_events
    where EVENT_ATTRIBUTES:"0_action"='withdraw'
    and EVENT_ATTRIBUTES:asset='uluna'
    and EVENT_ATTRIBUTES:"0_contract_address"='terra19dtgj9j5j7kyf3pmejqv8vzfpxtejaypgzkz5u'
    and tx_status = 'SUCCEEDED'
    group by 1)

    select dep.dt1 as dt,
    daily_deposit,
    daily_withdraw,
    (daily_deposit-daily_withdraw) as net_deposit
    from dep
    inner join witd on dep.dt1=witd.dt2

    Run a query to Download Data