10BlockchainMarge brut gas L2 - L1
    Updated 2025-02-21
    WITH daily_l2 AS (
    SELECT
    DATE_TRUNC('day', block_timestamp) AS dt,
    -- 1. Tous les frais L2 (en ETH), convertis en Gwei
    SUM(tx_fee * 1e9) AS cost_l2_gwei
    FROM mantle.core.fact_transactions
    GROUP BY 1
    ),
    daily_l1 AS (
    SELECT
    DATE_TRUNC('day', block_timestamp) AS dt,
    -- 2. Frais L1 du batcher Mantle (effective_gas_price est en Gwei)
    SUM(gas_used * effective_gas_price) AS cost_l1_gwei
    FROM ethereum.core.fact_transactions
    WHERE from_address = LOWER('0x2f40D796917ffB642bD2e2bdD2C762A5e40fd749') -- batcher Mantle
    GROUP BY 1
    )
    SELECT
    COALESCE(l2.dt, l1.dt) AS dt,
    l2.cost_l2_gwei,
    l1.cost_l1_gwei,
    -- RENTA_GWEI : (Revenus L2 totaux) - (Coûts L1 batcher)
    (l2.cost_l2_gwei - l1.cost_l1_gwei) AS renta_gwei,
    -- Conversion en ETH : Gwei ÷ 1e9
    ((l2.cost_l2_gwei - l1.cost_l1_gwei) / 1e9) AS renta_eth
    FROM daily_l2 l2
    FULL JOIN daily_l1 l1
    ON l2.dt = l1.dt
    ORDER BY dt;

    Last run: about 2 months ago
    DT
    COST_L2_GWEI
    COST_L1_GWEI
    RENTA_GWEI
    RENTA_ETH
    1
    2023-07-02 00:00:00.0000.000021408
    2
    2023-07-03 00:00:00.00048607576850.1412
    3
    2023-07-04 00:00:00.00067700167123.676986074462.69008866714092660.985966.714092661
    4
    2023-07-05 00:00:00.000144812823294.196130012985.532522144682810308.663144.682810309
    5
    2023-07-06 00:00:00.00094832315320.84231314935560.3058493517379760.536493.517379761
    6
    2023-07-07 00:00:00.00070682232497.05211490501690.999869191730806.052369.191730806
    7
    2023-07-08 00:00:00.00037190992632.8415901032981.67182936289959651.169636.289959651
    8
    2023-07-09 00:00:00.00033590461446.7754818081161.63672132772380285.138732.772380285
    9
    2023-07-10 00:00:00.00047718794753.73211007492946.2226546711301807.509546.711301808
    10
    2023-07-11 00:00:00.00084907822892.74271012768819.2397583895054073.50383.895054074
    11
    2023-07-12 00:00:00.00088174987278.84221246600532.5642286928386746.27886.928386746
    12
    2023-07-13 00:00:00.00092705978029.07921451586015.6872791254392013.39291.254392013
    13
    2023-07-14 00:00:00.00087304334797.01111104120293.1306986200214503.880486.200214504
    14
    2023-07-15 00:00:00.00043105863320.5561649284377.95934742456578942.596742.456578943
    15
    2023-07-16 00:00:00.00040884347154.6285729250973.70472440155096180.923840.155096181
    16
    2023-07-17 00:00:00.0001472939924294.411013061254.561291471926863039.851471.92686304
    17
    2023-07-18 00:00:00.0004704509370554.211371822470.59454703137548083.614703.137548084
    18
    2023-07-19 00:00:00.0002005090242868.731151907863.744182003938335004.992003.938335005
    19
    2023-07-20 00:00:00.0003264182959655.341226840733.640633262956118921.73262.956118922
    20
    2023-07-21 00:00:00.0004773908527805.721315132105.394084772593395700.324772.5933957
    ...
    601
    55KB
    30s