Afonso_Diazserious-sapphire
    Updated 2025-03-06
    with

    pricet as (
    select
    hour::date as date,
    token_address,
    avg(price) as token_price_usd
    from
    ink.price.ez_prices_hourly
    group by 1, 2
    ),

    txns as (
    -- select
    -- tx_hash,
    -- block_timestamp,
    -- origin_from_address as swapper,
    -- a.contract_address as token_out,
    -- b.contract_address as token_in,
    -- nvl(a.decoded_log:value, a.decoded_log:wad) as amount_out_unadj,
    -- nvl(b.decoded_log:value, b.decoded_log:wad) as amount_in_unadj
    -- from
    -- ink.core.ez_decoded_event_logs a
    -- join
    -- ink.core.ez_decoded_event_logs b using (tx_hash, block_timestamp, event_name)
    -- where
    -- a.event_name = 'Transfer'
    -- and nvl(a.decoded_log:from, a.decoded_log:src) = swapper
    -- and nvl(b.decoded_log:to, b.decoded_log:dst) = swapper
    -- and tx_succeeded
    -- and origin_to_address = '0xaaaaaaae92cc1ceef79a038017889fdd26d23d4d'
    -- and tx_hash in (select distinct tx_hash from ink.core.ez_decoded_event_logs where event_name = 'Swap')

    -- union all

    select
    QueryRunArchived: QueryRun has been archived