Afonso_DiazTop symbols
    Updated 2024-09-18
    with

    pricet as (
    select
    hour::date as date,
    symbol,
    token_address,
    avg(price) as price_usd
    from base.price.ez_prices_hourly
    group by 1, 2, 3
    ),

    main as (
    select
    tx_hash,
    block_timestamp,
    origin_from_address as user,
    case
    when amount_in_usd is not null then amount_in_usd
    when token_in in ('0x833589fcd6edb6e08f4c7c32d4f71b54bda02913', '0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca', '0x50c5725949a6f0c72e6c4a641f24049a917db0cb', '0xb79dd08ea68a908a97220c76d19a6aa9cbde4376', '0x4a3a6dd60a34bb2aba60d73b4c88315e9ceb6a3d', '0x4621b7a9c75199271f773ebd9a499dbd165c3191') then amount_in
    when s1.price_usd is not null then amount_in * s1.price_usd
    end as amount_in_usdd,

    case
    when amount_out_usd is not null then amount_out_usd
    when token_out in ('0x833589fcd6edb6e08f4c7c32d4f71b54bda02913', '0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca', '0x50c5725949a6f0c72e6c4a641f24049a917db0cb', '0xb79dd08ea68a908a97220c76d19a6aa9cbde4376', '0x4a3a6dd60a34bb2aba60d73b4c88315e9ceb6a3d', '0x4621b7a9c75199271f773ebd9a499dbd165c3191') then amount_out
    when s2.price_usd is not null then amount_out * s2.price_usd
    end as amount_out_usdd,
    case
    when amount_in_usdd < 1e6 then amount_in_usdd
    when amount_out_usdd < 1e6 then amount_out_usdd
    end as amount_usd,
    symbol_in,
    symbol_out,
    token_in,
    token_out,
    QueryRunArchived: QueryRun has been archived