adam10ANC Deposits v Collateral
    Updated 2021-09-16
    WITH collateral as (
    SELECT date_trunc('day', block_timestamp) as date,
    -- msg_value:coins[0]:denom::string as currency,
    sum(msg_value:execute_msg:send:amount / POW(10, 6)) as deposit_bluna
    -- msg_value:execute_msg:send:amount / POW(10, 6) as deposit_bluna,
    -- msg_value
    FROM terra.msgs
    WHERE date > to_timestamp('2021-06-01 00:00:00') and msg_type = 'wasm/MsgExecuteContract' and msg_value:contract = 'terra1kc87mu460fwkqte29rquh4hc20m54fxwtsx7gp'
    and msg_value:execute_msg:send:msg:deposit_collateral = '{}' -- and msg_value:coins[0]:amount IS NOT NULL --and msg_value:coins[1] IS NULL
    GROUP BY 1
    -- LIMIT 500
    -- and msg_value:MsgExecuteContract:denom = 'uusd' --and msg_value:MsgExecuteContract:execute_msg:deposit_stable IS NOT NULL
    )

    , withdraw_collateral as (
    SELECT date_trunc('day', block_timestamp) as date,
    sum(msg_value:execute_msg:withdraw_collateral:amount / POW(10, 6)) as withdraw_bluna
    FROM terra.msgs
    WHERE date > to_timestamp('2021-06-01 00:00:00') and msg_type = 'wasm/MsgExecuteContract' and msg_value:contract = 'terra1ptjp2vfjrwh0j0faj9r6katm640kgjxnwwq9kn'
    and msg_value:execute_msg:withdraw_collateral:amount IS NOT NULL
    -- LIMIT 500
    GROUP BY 1
    )

    , deposits as (
    SELECT date_trunc('day', block_timestamp) as date,
    -- msg_value:coins[0]:denom::string as currency,
    sum(msg_value:coins[0]:amount / POW(10, 6)) as deposit
    -- msg_value
    FROM terra.msgs
    WHERE date > to_timestamp('2021-06-01 00:00:00') and msg_type = 'wasm/MsgExecuteContract' and msg_value:contract = 'terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s'
    and msg_value:execute_msg:deposit_stable = '{}' and msg_value:coins[0]:amount IS NOT NULL --and msg_value:coins[1] IS NULL
    GROUP BY 1
    -- LIMIT 500
    -- and msg_value:MsgExecuteContract:denom = 'uusd' --and msg_value:MsgExecuteContract:execute_msg:deposit_stable IS NOT NULL
    )
    Run a query to Download Data