Salehherewallet_swap_date_asset
    Updated 2024-08-24
    with lst_price as (
    select
    date_trunc(hour,HOUR) as price_date
    -- ,token_contract
    ,avg(CLOSE) as avg_price
    from near.price.fact_prices_ohlc_hourly
    -- where token_contract='wrap.near'
    where ASSET_ID='wrapped-near'
    and price_date is not null
    group by 1
    )
    ,lst_check as (
    ------------------check herewallet swap--------------------------------
    select
    tx_hash
    ,split( array_to_string(LOGS,' '),'Referral')
    from near.core.fact_receipts
    -- where tx_hash='4FmN3sCGKbSGD1F28qwx37coys49vFG1i9fhETEeci68'
    where BLOCK_TIMESTAMP::date >= '2023-11-07'
    and array_to_string(logs,' ') ilike '%owner.herewallet.near%'
    and RECEIVER_ID='v2.ref-finance.near'
    )
    ----------------this section from saeed--------------------------------
    ,min_max_swap_indexes as (
    select
    tx_hash
    ,min (swap_index) min_index
    ,max(swap_index) max_index
    from near.defi.ez_dex_swaps
    where BLOCK_TIMESTAMP::date >= '2023-11-07'
    group by 1
    ),
    swapped_in as (
    select
    block_timestamp::date date
    ,tx_hash
    QueryRunArchived: QueryRun has been archived