Afonso_DiazTop Trade Routes
    Updated 2025-05-18
    with

    swaps as (
    select
    tx_hash,
    block_timestamp,
    origin_from_address as swapper,
    a.contract_address as token_in,
    b.contract_address as token_out,
    a.amount as amount_in,
    b.amount as amount_out,
    a.amount_usd as amount_in_usd,
    b.amount_usd as amount_out_usd,
    a.symbol as symbol_in,
    b.symbol as symbol_out
    from
    ronin.core.ez_token_transfers a
    join
    ronin.core.ez_token_transfers b using (tx_hash, block_timestamp)
    where
    a.contract_address != b.contract_address
    and b.to_address = origin_from_address
    and a.to_address != '0x22cefc91e9b7c0f3890ebf9527ea89053490694e'
    and b.to_address != '0x22cefc91e9b7c0f3890ebf9527ea89053490694e'
    and a.from_address != '0x0000000000000000000000000000000000000000'
    and b.from_address != '0x0000000000000000000000000000000000000000'
    and tx_hash not in (select distinct tx_hash from ronin.core.fact_transactions where input_data = '0x')
    ),

    main as (
    select
    *,
    nvl(amount_in_usd, amount_out_usd) as amount_usd,
    iff(token_in = '0xf988f63bf26c3ed3fbf39922149e3e7b1e5c27cb', amount_in, amount_out) as amount,
    iff(token_in = '0xf988f63bf26c3ed3fbf39922149e3e7b1e5c27cb', 'Sell', 'Buy') as type
    QueryRunArchived: QueryRun has been archived