vendettaUntitled Query copy
    -- forked from 6af77fab-f4d1-449d-bd68-33174ba9baf1

    with aurora_to_near as ( --=============================================>>>>>>>>>>>>>>>> Aurora to NEAR <<<<<<<<<<<<<<<<<<<<<<==================================================
    with bridge_from_aurora_to_near as (
    select
    BLOCK_TIMESTAMP::date as date,
    txn_hash,
    TX_RECEIPT[1]:outcome:executor_id as contract_in_near,
    case
    when contract_in_near = 'wrap.near' then 'NEAR'
    when contract_in_near = 'aurora' then '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' -- WETH
    else concat('0x', substring(contract_in_near, 1, CHARINDEX('.', contract_in_near)-1))
    end as token_address,
    TX_RECEIPT[1]:outcome:logs[0] as log,
    substring(log, 1, CHARINDEX(' from aurora to ', log)) as first_part,
    regexp_replace(first_part, '[^0-9]', '') as asset_amount,
    substring(log, CHARINDEX('from aurora to ', log)+15, len(log)) as receiver
    from flipside_prod_db.mdao_near.transactions n_t
    --
    where tx_signer = 'relay.aurora'
    and tx_receiver = 'aurora'
    and (contract_in_near like '%.factory.bridge.near' -- ERC20-Assets
    or contract_in_near like 'aurora' -- ETH
    or contract_in_near like 'wrap.near' -- NEAR
    )
    and TX_RECEIPT[1]:outcome:logs[0] like 'Transfer % from aurora %'
    -- and receiver = 'mohammadhs.near'
    ), erc20_prices as (
    select hour::date as date, symbol, token_address, avg(price) as price
    from ethereum.core.fact_hourly_token_prices
    where token_address in (select distinct token_address from bridge_from_aurora_to_near)
    group by 1,2,3
    ), near_prices as (
    with swaps as (
    select
    Run a query to Download Data