Updated 2022-01-12
    WITH send_native_tokens as (
    select
    msgs.tx_id,
    msgs.block_timestamp,
    'Native' as type,
    msgs.msg_value:execute_msg:initiate_transfer:asset:amount::numeric / 1e6 as amount,
    msgs.msg_value:execute_msg:initiate_transfer:asset:info:native_token:denom::string as token,
    msgs.msg_value:sender::string as wallet,
    msgs.msg_value:execute_msg:initiate_transfer:recipient_chain::numeric as block_chain_id,
    case
    when block_chain_id = 1 then 'Solana'
    when block_chain_id = 2 then 'Ethereum'
    when block_chain_id = 3 then 'Terra'
    when block_chain_id = 4 then 'Binance'
    when block_chain_id = 5 then 'Polygon'
    else 'unknown'
    end as block_chain_name,
    'Terra -> ' || block_chain_name as direction,
    msgs.msg_value:execute_msg:initiate_transfer:recipient::string as recipient,
    case when token = 'uusd' then 'UST'
    when token = 'uluna' then 'LUNA'
    else token
    end as token_name,
    chain_id,
    f.Value:amount / 1e6 as fees,
    f.Value:denom::string as denom
    from terra.msgs as msgs
    INNER JOIN terra.transactions txns using(tx_id),
    table(flatten(input => fee[0]:amount)) f
    where msg_value:contract::string = 'terra10nmmwe8r3g99a9newtqa7a75xfgs2e8z87r2sf'
    and msg_value:execute_msg:initiate_transfer is not null
    and msgs.tx_status = 'SUCCEEDED'
    AND token IS NOT NULL
    and denom = 'uusd'
    and msgs.block_timestamp > CURRENT_DATE - 180
    and txns.block_timestamp > CURRENT_DATE - 180
    Run a query to Download Data