Updated 2024-03-29
    with nft_buy as (
    select
    a.tx_hash,
    a.receiver_id as platform,
    a.block_id,
    a.block_timestamp,
    a.args:receiver_id as buyer,
    a.args:token_series_id as token_id,
    PARSE_JSON(PARSE_JSON(b.clean_log):data[0]:memo) : price / 1e24 as price
    from near.core.fact_actions_events_function_call a
    join near.core.fact_logs b ON a.tx_hash = b.tx_hash
    where method_name = 'nft_buy'
    and a.RECEIVER_ID = 'x.paras.near'
    and a.block_timestamp :: date >= current_date - 7
    )
    ,
    transfer as (
    select
    a.tx_hash,
    a.block_timestamp,
    a.receiver_id as collection
    from near.core.fact_transfers a
    join nft_buy b using(tx_hash)
    where a.block_timestamp :: date >= current_date - 7
    and a.PREDECESSOR_ID = 'x.paras.near'
    and receiver_id <> 'plutus.paras.near'
    )
    ,
    near_price as (
    select
    date_trunc('hour', timestamp) as date,
    AVG(price_usd) as price_usd
    from near.price.fact_prices
    where symbol ilike 'wNEAR'
    group by 1
    )
    QueryRunArchived: QueryRun has been archived