lxv0umOwn Arbitrage Bot performance (Overall)
    Updated 2022-07-07

    with contract_addresses as (select DISTINCT msg_value:contract from terra.msgs
    where msg_value:sender = 'terra18dc0shnv6nqnvw2zsl2xcjym56zzat60lxv0um' and msg_value:execute_msg:ww IS NOT NULL),
    arbitrage_entries as (
    select to_char(block_timestamp, 'yyyy-MM-dd') as activity_date, tx_id,
    case when event_attributes:profit > 0 then event_attributes:profit
    else event_attributes:uusd_after - event_attributes:uusd_before
    end as profit,
    0 as gas
    from terra.msg_events
    where
    event_type = 'wasm'
    and tx_id IN (SELECT tx_id FROM terra.msgs WHERE msg_value:contract IN
    (select * from contract_addresses)
    and tx_status = 'SUCCEEDED')
    UNION ALL
    select to_char(block_timestamp, 'yyyy-MM-dd') as activity_date, tx_id, 0 as profit, 0 as gas
    from terra.msgs
    where
    msg_value:contract IN
    (select * from contract_addresses)
    and tx_status = 'FAILED'
    ), fee_entries as (
    SELECT to_char(block_timestamp, 'yyyy-MM-dd') as activity_date, tx_id, fee[0]:amount[0]:amount as gas
    from terra.transactions
    where tx_id IN (SELECT tx_id FROM arbitrage_entries)
    ), final_entries as (
    SELECT arbitrage_entries.activity_date, arbitrage_entries.tx_id, arbitrage_entries.profit, fee_entries.gas
    FROM arbitrage_entries
    inner join fee_entries ON arbitrage_entries.tx_id = fee_entries.tx_id
    )

    Run a query to Download Data