binhachonUST BRIDGE
    Updated 2021-10-08
    with sent_across_the_bridge as (
    select
    date(block_timestamp) as block_date,
    'Sent to Ethereum' as transaction_type,
    msg_value:amount[0]:denom as original_denom,
    substring(msg_value:amount[0]:denom, 2, 6) as dervied_denom,
    concat(dervied_denom, ' sent to Ethereum') as derived_transaction_type,
    sum(msg_value:amount[0]:amount / POW(10, 6)) as derived_amount
    from terra.msgs m
    where msg_value:to_address::string = 'terra13yxhrk08qvdf5zdc9ss5mwsg5sf7zva9xrgwgc'
    and tx_status = 'SUCCEEDED'
    and original_denom in ('uusd')
    group by 1, 2, 3, 4
    ),
    received_from_bridge as (
    select
    date(block_timestamp) as block_date,
    'Received from Ethereum' as transaction_type,
    msg_value:amount[0]:denom as original_denom,
    substring(msg_value:amount[0]:denom, 2, 6) as dervied_denom,
    concat(dervied_denom, ' received from Ethereum') as derived_transaction_type,
    sum(msg_value:amount[0]:amount / POW(10, 6)) as derived_amount
    from terra.msgs m
    where msg_value:from_address::string = 'terra13yxhrk08qvdf5zdc9ss5mwsg5sf7zva9xrgwgc'
    and tx_status = 'SUCCEEDED'
    and original_denom in ('uusd')
    group by 1, 2, 3, 4
    ),
    joined_bridge_transactions as (
    select
    *
    from sent_across_the_bridge
    union
    select
    *
    from received_from_bridge
    Run a query to Download Data