freemartianNative ETH Bridgoors
    Updated 2022-07-31
    with eth_bridges as (
    select
    origin_from_address as user, tx_hash, block_timestamp,
    sum(amount_usd) as eth_volume
    from ethereum.core.ez_eth_transfers
    where origin_to_address = '0xa0c68c638235ee32657e8f720a23cec1bfc77c77'
    and block_timestamp > '2022-05-02'
    group by 1, 2, 3
    order by eth_volume desc
    ),

    next_transactions as (
    select ft.tx_hash as tx, from_address, ft.block_timestamp
    from ethereum.core.fact_transactions ft
    inner join eth_bridges e on e.user = ft.from_address
    where from_address in (select user from eth_bridges)
    and ft.block_timestamp::date = e.block_timestamp::date
    and ft.block_timestamp > e.block_timestamp
    order by ft.block_timestamp ASC)

    select count(tx_hash) as count, event_name, origin_to_address as contract,
    case
    when contract = '0xa0c68c638235ee32657e8f720a23cec1bfc77c77' then 'Bridge ETH Again'
    when contract = '0x881d40237659c251811cec9c364ef91dc08d300c' then 'Metamask Swap'
    when contract = '0x7f268357a8c2552623316e2562d90e642bb538e5' then 'OpenSea: Wyvern Exchange v2'
    when contract = '0x68b3465833fb72a70ecdf485e0e4c7bd8665fc45' then 'UniSwap'
    when contract = '0x1111111254fb6c44bac0bed2854e76f90643097d' then '1inch v4: Router'
    else 'others'
    end as interactions
    from ethereum.core.fact_event_logs
    where tx_hash in (select tx from next_transactions)
    and event_name is not null
    and interactions != 'others'
    and event_name in ('LockedEther', 'Transfer', 'Swap')
    group by 2, 3,4
    Run a query to Download Data