shreyash-5873Mirror aUST Collateral Withdraws v4
    Updated 2022-02-09
    --Withdraw from Borrow
    (select
    m.block_id,
    m.event_attributes:"to"::string as sender,
    m.tx_id,
    m.event_attributes:withdraw_amount[0]:amount as uaust_collateralised,
    m.event_attributes:withdraw_amount[0]:amount / pow(10, 6) as aust_collateralised,
    m.event_attributes:"0_position_idx"::string as position_idx,
    'Withdraw from Borrow' as position_type
    from terra.msg_events m
    where m.event_type = 'from_contract'
    and m.event_attributes:withdraw_amount[0]:denom::string = 'terra1hzh9vpxhsk8253se0vv5jj6etdvxu3nv8z07zu'
    and m.event_attributes:"0_contract_address"::string = 'terra1wfz7h3aqf4cjmjcvc6s8lxdhh7k30nkczyf0mj'
    and m.event_attributes:"0_position_idx"::string is NOT NULL
    Union
    select
    m.block_id,
    m.event_attributes:"to"::string as sender,
    m.tx_id,
    m.event_attributes:withdraw_amount[0]:amount as uaust_collateralised,
    m.event_attributes:withdraw_amount[0]:amount / pow(10, 6) as aust_collateralised,
    m.event_attributes:"position_idx"::string as position_idx,
    'Withdraw from Borrow' as position_type
    from terra.msg_events m
    where m.event_type = 'from_contract'
    and m.event_attributes:withdraw_amount[0]:denom::string = 'terra1hzh9vpxhsk8253se0vv5jj6etdvxu3nv8z07zu'
    and m.event_attributes:"0_contract_address"::string = 'terra1wfz7h3aqf4cjmjcvc6s8lxdhh7k30nkczyf0mj'
    and m.event_attributes:"position_idx"::string is NOT NULL)
    UNION
    -- Withdraw Protocol Fee
    select
    m.block_id,
    m.event_attributes:"0_from"::string as sender,
    m.tx_id,
    m.event_attributes:protocol_fee[0]:amount as uaust_collateralised,
    m.event_attributes:protocol_fee[0]:amount / pow(10, 6) as aust_collateralised,
    Run a query to Download Data