Nige7777Anchor repayments 19.1
    Updated 2021-07-14

    with cte_b as (
    select
    SUM(msg_value:execute_msg:borrow_stable:borrow_amount / pow(10,6)) as Amount_Borrowed
    from terra.msgs where 1=1 --and tx_id in ( '7920C252C381D6D3952421133A7090D9C1D2079663B1E2E9A253711FA7FFAE06','1EB5176A40308B36C26564FA12B897AAE869B4E58D9ACFC3012EFB10FFE60A74')
    and msg_value:contract::string = 'terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s'
    and msg_value:execute_msg:borrow_stable is not null
    and tx_status = 'SUCCEEDED'

    ),
    cte_r as (
    select
    SUM(msg_value:coins[0]:amount / pow(10,6)) as Amount_Repaid

    from terra.msgs where 1=1 --and tx_id in ( '7920C252C381D6D3952421133A7090D9C1D2079663B1E2E9A253711FA7FFAE06','1EB5176A40308B36C26564FA12B897AAE869B4E58D9ACFC3012EFB10FFE60A74')
    and msg_value:contract::string = 'terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s'
    and msg_value:execute_msg:repay_stable is not null
    and tx_status = 'SUCCEEDED'

    )
    select
    Amount_Borrowed,
    Amount_Repaid
    from cte_b b
    cross join cte_r r

    Run a query to Download Data