strawbettyNet LUNA deposited and borrowed in Mars protocol during time
    Updated 2022-07-07
    with deposit_luna as (
    select
    block_timestamp::date as date,
    case
    when msg_value:execute_msg:deposit_native:denom = 'uluna' then 'LUNA'
    end as asset,
    sum(msg_value:coins[0]:amount/1e6) as total_deposit_amount,
    count(distinct msg_value:sender) as unique_depositors_count,
    count(tx_id) as total_deposit_txs_count
    from terra.msgs
    where msg_value:contract = 'terra19dtgj9j5j7kyf3pmejqv8vzfpxtejaypgzkz5u'
    and msg_value:execute_msg:deposit_native:denom = 'uluna'
    and TX_STATUS = 'SUCCEEDED'
    group by 1,2
    ), borrow_luna as (
    select
    block_timestamp::date as date,
    case
    when msg_value:execute_msg:borrow:asset:native:denom = 'uluna' then 'LUNA'
    end as asset,
    sum(msg_value:execute_msg:borrow:amount/1e6) as total_borrow_amount,
    count(distinct msg_value:sender) as unique_borrowers_count,
    count(tx_id) as total_borrow_txs_count
    from terra.msgs
    where msg_value:contract = 'terra19dtgj9j5j7kyf3pmejqv8vzfpxtejaypgzkz5u'
    and msg_value:execute_msg:borrow:asset:native:denom = 'uluna'
    and TX_STATUS = 'SUCCEEDED'
    group by 1,2
    )

    SELECT
    d.date,
    d.asset,
    total_deposit_amount,
    total_borrow_amount,
    total_deposit_amount-total_borrow_amount as net_LUNA,
    Run a query to Download Data