Afonso_DiazTop pairs
    Updated 2025-01-24
    with

    pricet as (
    select
    hour::date as date,
    symbol,
    decimals,
    token_address,
    avg(price) as token_price_usd
    from
    sei.price.ez_prices_hourly
    group by 1, 2, 3, 4
    ),

    main as (
    select
    tx_id,
    block_timestamp,
    swapper,
    platform,
    a.symbol as symbol_in,
    (amount_in / pow(10, a.decimals)) * a.token_price_usd as amount_in_usd,
    b.symbol as symbol_out,
    (amount_out / pow(10, b.decimals)) * b.token_price_usd as amount_out_usd,
    nvl(amount_in_usd, amount_out_usd) as amount_usd
    from
    sei.defi.fact_dex_swaps
    left join
    pricet a on block_timestamp::date = a.date and a.token_address = currency_in
    left join
    pricet b on block_timestamp::date = b.date and b.token_address = currency_out
    where
    tx_succeeded
    and platform = 'astroport'
    )

    QueryRunArchived: QueryRun has been archived