MostlyData_Gas & Fee data
    Updated 2024-11-27
    -- forked from PF left by position @ https://flipsidecrypto.xyz/studio/queries/b5192a23-92f4-468b-afce-3fa469fee639

    -- forked from PF by position @ https://flipsidecrypto.xyz/studio/queries/88bff19e-c35e-416d-9b87-7a4841aae922

    with block_info as(
    select
    block_number
    ,tx_count
    ,block_header_json['baseFeePerGas'] as baseFeePerGas

    from ethereum.core.fact_blocks

    where
    block_timestamp >= current_date() - interval '{{n_days}} days'
    )

    ,tx_data as(
    select
    txs.tx_hash
    ,txs.position
    ,txs.cumulative_gas_used
    ,txs.tx_fee_precise
    ,txs.gas_used
    ,bi.baseFeePerGas
    ,txs.max_priority_fee_per_gas
    ,txs.max_fee_per_gas
    ,bi.baseFeePerGas * txs.gas_used * pow(10,-18) as burnt_fee
    ,txs.max_priority_fee_per_gas * txs.gas_used * pow(10,-9) as max_pf_fee
    ,txs.tx_fee_precise - bi.baseFeePerGas * txs.gas_used * pow(10,-18) as pf
    ,case
    when txs.max_priority_fee_per_gas * txs.gas_used * pow(10, -9) - (txs.tx_fee_precise - bi.baseFeePerGas * txs.gas_used * pow(10, -18)) < pow(10, -15)
    then 0
    else txs.max_priority_fee_per_gas * txs.gas_used * pow(10, -9) - (txs.tx_fee_precise - bi.baseFeePerGas * txs.gas_used * pow(10, -18))
    end as delta_pf
    from ethereum.core.fact_transactions txs
    QueryRunArchived: QueryRun has been archived