Updated 2024-10-10
    with

    pricet as (
    select
    hour::date as date,
    avg(price) as flow_price_usd
    from
    flow.price.ez_prices_hourly
    where
    symbol = 'FLOW'
    group by 1
    ),

    main as (
    select
    tx_id,
    block_timestamp,
    nvl(event_data:buyer, b.proposer) as buyer,
    iff(event_data:salePaymentVaultType ilike '%DapperUtilityCoin%', 'USDC', 'FLOW') as symbol,
    event_data:salePrice as price,
    price * iff(symbol = 'USDC', 1, flow_price_usd) as price_usd,
    event_data:commissionAmount as commision_amount,
    commision_amount * iff(symbol = 'USDC', 1, flow_price_usd) as commission_amount_usd
    from
    flow.core.fact_events a
    left join
    pricet on date = block_timestamp::date
    join
    flow.core.fact_transactions b
    using(tx_id)
    where
    nvl(event_data:nftType:typeID, event_data:nftType) = 'A.8b148183c28ff88f.Gaia.NFT'
    and event_data:purchased = 'true'
    and event_type = 'ListingCompleted'
    and price > 0
    )
    QueryRunArchived: QueryRun has been archived