CryptoLionanchor tvl
    Updated 2021-08-04
    with deposit_bluna as (
    SELECT
    tx_id,
    msg_value:execute_msg:send:amount/POW(10,6) as amount,
    msg_value:execute_msg:send:contract as contract
    FROM terra.msgs
    WHERE msg_value:execute_msg:send:msg LIKE '%deposit_collateral%'
    AND tx_status='SUCCEEDED'
    ),

    withdraw_bluna as (
    SELECT
    tx_id,
    -- msg_value:execute_msg:unlock_collateral:collaterals[0][0]
    msg_value:execute_msg:unlock_collateral:collaterals[0][1] / POW(10,6) as amount,
    msg_value:execute_msg:unlock_collateral:collaterals[0][0] as contract
    FROM terra.msgs
    WHERE msg_value:execute_msg LIKE '%unlock_collateral%'
    AND tx_status='SUCCEEDED'
    ),
    deposit_ust as (
    SELECT
    tx_id,
    msg_value:coins[0]:amount::float / POW(10,6) as amount,
    msg_value:contract as contract
    FROM terra.msgs
    WHERE
    tx_status='SUCCEEDED'
    AND msg_value:execute_msg::string='{"deposit_stable":{}}'
    ),
    withdraw_ust as (
    SELECT
    tx_id,
    msg_value:execute_msg:send:amount / POW(10,6) as amount,
    msg_value:contract as contract
    FROM terra.msgs