Afonso_DiazBy symbol
    Updated 2024-11-19
    with

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

    main as (
    select
    source_chain,
    destination_chain,
    direction,
    symbol,
    a.token_address,
    amount,
    nvl(amount_usd, amount * price_usd) as amount_usd,
    source_address,
    destination_address,
    tx_hash,
    block_timestamp,
    iff(direction = 'inbound', destination_address, source_address) as user
    from
    near.defi.ez_bridge_activity a
    left join
    pricet on block_timestamp::date = date and
    case
    when a.token_address = '33.contract.portalbridge.near' then '7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9.factory.bridge.near'
    when a.token_address = '23.contract.portalbridge.near' then 'aaaaaa20d9e0e2461697782ef11675f668207961'
    when a.token_address = '2.contract.portalbridge.near' then 'celo.token.a11bd.near'
    when a.token_address = '28.contract.portalbridge.near' then 'wrap.near'
    when a.token_address = '22.contract.portalbridge.near' then 'sol.token.a11bd.near'
    QueryRunArchived: QueryRun has been archived