binhachon1. Weigh Anchor (Users) - top 100 number of tx
    Updated 2022-01-09
    with Anchor_borrow as (
    select
    block_timestamp,
    msg_value:sender::string as borrower,
    msg_value:execute_msg:borrow_stable:borrow_amount::float/1e6 as borrow_amount
    from
    terra.msgs
    where msg_value:execute_msg:borrow_stable is not null
    and msg_value:contract::string = 'terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s'
    and tx_status = 'SUCCEEDED'
    ),
    Anchor_repay as (
    select
    block_timestamp,
    msg_value:sender::string as borrower,
    msg_value:coins[0]:amount::float/1e6 as repay_amount
    from
    terra.msgs
    where msg_value:execute_msg:repay_stable is not null
    and msg_value:contract::string = 'terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s'
    and msg_value:coins[0]:denom::string = 'uusd'
    and tx_status = 'SUCCEEDED'
    ),
    single_liquidation as (
    select
    tx_id,
    block_timestamp,
    event_attributes:"0_borrower"::string as borrower,
    event_attributes:liquidator::string as liquidator,
    event_attributes:"1_repay_amount"::float/1e6 as repay_amount
    from
    terra.msg_events
    where event_type = 'from_contract'
    and tx_status = 'SUCCEEDED'
    and event_attributes:"0_action"::string = 'liquidate_collateral'
    and event_attributes:collateral_token::string is not null
    Run a query to Download Data