Updated 2025-04-21
    WITH base AS (
    SELECT
    tx_hash,
    block_timestamp
    FROM ronin.core.ez_decoded_event_logs
    WHERE
    contract_address = '0x4f7687affc10857fccd0938ecda0947de7ad3812'
    AND origin_to_address = '0x5f0acdd3ec767514ff1bf7e79949640bf94576bd'
    AND origin_function_signature = '0x3593564c'
    AND event_name = 'Swap'
    ),

    joined_fees AS (
    SELECT
    b.tx_hash,
    b.block_timestamp,
    t.tx_fee
    FROM base b
    LEFT JOIN ronin.core.fact_transactions t
    ON b.tx_hash = t.tx_hash
    ),

    fees_with_price AS (
    SELECT
    j.tx_hash,
    j.tx_fee,
    j.block_timestamp,
    p.price AS ron_price_usd,
    j.tx_fee * p.price AS tx_fee_usd
    FROM joined_fees j
    LEFT JOIN ronin.price.ez_prices_hourly p
    ON DATE_TRUNC('hour', j.block_timestamp) = p.hour
    AND p.symbol = 'RON'
    )

    SELECT
    Last run: about 1 month ago
    TOTAL_FEES_USD
    AVG_FEE_USD
    1
    1371.1559428760.008884514083
    1
    33B
    12s