binhachon141. Staking Yield, Mvmt. II: Anchor
    Updated 2022-01-29
    with Anchor_deposit_collaterals as (
    select
    block_timestamp,
    msg_value:sender::string as sender,
    msg_value:contract::string as denom,
    msg_value:execute_msg:send:amount::float/1e6 as amount
    from
    terra.msgs
    where msg_value:execute_msg:send:contract::string in ('terra1ptjp2vfjrwh0j0faj9r6katm640kgjxnwwq9kn', 'terra10cxuzggyvvv44magvrh3thpdnk9cmlgk93gmx2') --bETH bLUNA
    and msg_value:execute_msg:send:amount is not null
    and tx_status = 'SUCCEEDED'
    ),
    Anchor_withdraw_collaterals as (
    select
    block_timestamp,
    msg_value:sender::string as sender,
    case
    when msg_value:contract::string = 'terra1ptjp2vfjrwh0j0faj9r6katm640kgjxnwwq9kn' then 'terra1kc87mu460fwkqte29rquh4hc20m54fxwtsx7gp'
    when msg_value:contract::string = 'terra10cxuzggyvvv44magvrh3thpdnk9cmlgk93gmx2' then 'terra1dzhzukyezv0etz22ud940z7adyv7xgcjkahuun'
    end as denom,
    msg_value:execute_msg:withdraw_collateral:amount::float/1e6 as amount
    from
    terra.msgs
    where msg_value:execute_msg:withdraw_collateral is not null
    and msg_value:contract::string in ('terra1ptjp2vfjrwh0j0faj9r6katm640kgjxnwwq9kn', 'terra10cxuzggyvvv44magvrh3thpdnk9cmlgk93gmx2') --bETH bLUNA
    and tx_status = 'SUCCEEDED'
    ),
    collateral_token_contract as (
    select 'terra1kc87mu460fwkqte29rquh4hc20m54fxwtsx7gp' as contract_address
    union
    select 'terra1dzhzukyezv0etz22ud940z7adyv7xgcjkahuun' as contract_address
    ),
    single_liquidation as (
    select
    tx_id,
    block_timestamp,
    Run a query to Download Data