Afonso_DiazGrouping txns
    Updated 2 days ago
    with

    main as (
    select
    tx_hash,
    block_timestamp,
    a.old_owner_id as swapper,
    a.amount_raw as amount_in_unadj,
    b.amount_raw as amount_out_unadj,
    trim(replace(replace(replace(replace(replace(a.token_id, 'nep141:'), 'eth-'), 'arb-'), 'base-'), '.omft.near')) as token_in_contract,
    trim(replace(replace(replace(replace(replace(b.token_id, 'nep141:'), 'eth-'), 'arb-'), 'base-'), '.omft.near')) as token_out_contract
    from
    near.defi.fact_intents a
    join
    near.defi.fact_intents b using (tx_hash, log_event)
    where
    log_event = 'mt_transfer'
    and not a.old_owner_id ilike any ('solver-%.near', 'intents.near', 'intents.sputnik-dao.near', 'defuse-relay.near', 'solver-priv-liq.near')
    and a.new_owner_id ilike any ('solver-%.near', 'intents.near', 'intents.sputnik-dao.near', 'defuse-relay.near', 'solver-priv-liq.near')
    and b.old_owner_id ilike any ('solver-%.near', 'intents.near', 'intents.sputnik-dao.near', 'defuse-relay.near', 'solver-priv-liq.near')
    and not b.new_owner_id ilike any ('solver-%.near', 'intents.near', 'intents.sputnik-dao.near', 'defuse-relay.near', 'solver-priv-liq.near')
    and a.old_owner_id != 'defuse-ops.near'
    and token_in_contract <> token_out_contract
    ),

    pricet as (
    select
    hour::date as date,
    decimals,
    token_address,
    symbol,
    avg(price) as price_usd
    from
    crosschain.price.ez_prices_hourly
    where
    token_address in (
    Last run: 2 days ago
    TYPE
    TRANSACTIONS
    1
    Crab ($50 - $100)10547
    2
    Dolphin ($1,000 - $5,000)7456
    3
    Fish ($500 - $1,000)10601
    4
    Giant Squid (More than $100,000)3613
    5
    Octopus ($100 - $500)5986
    6
    Plankton (Less than $10)71105
    7
    Shark ($5,000 - $10,000)1219
    8
    Shrimp ($10 - $50)17725
    9
    Whale ($10,000 - $100,000)1085
    9
    302B
    42s