maybeyonasanchor_stats
    Updated 2023-03-25
    with borrows as (
    select
    block_id as block,
    block_timestamp as time,
    tx_id,
    msg_value:sender::string as sender,
    msg_value:execute_msg:borrow_stable:borrow_amount / POW(10,6) as amount,
    'borrow' as event,
    -msg_value:execute_msg:borrow_stable:borrow_amount / POW(10,6) as vector
    from terra.msgs
    where
    msg_value:contract = 'terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s'
    and msg_value:execute_msg:borrow_stable is not null
    and tx_status='SUCCEEDED'
    ),
    repays as(
    select
    block_id as block,
    block_timestamp as time,
    tx_id,
    msg_value:sender::string as sender,
    msg_value:coins[0]:amount / POW(10,6) as amount,
    'repay' as event,
    msg_value:coins[0]:amount / POW(10,6) as vector
    from terra.msgs
    where
    msg_value:contract = 'terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s'
    and msg_value:execute_msg like '%repay%'
    and tx_status='SUCCEEDED'
    ),
    events as(
    select * from borrows
    union all
    select * from repays
    ),
    updates as(
    Run a query to Download Data