opensource-observer / insights

Insights and exploratory data analysis on the health of open source software ecosystems
Apache License 2.0
20 stars 10 forks source link

[Impact Metric Submission]: Ratio of Daily L1 Gas Used to L2 Gas Used #29

Closed nutkung1 closed 3 months ago

nutkung1 commented 4 months ago

Ratio of Daily L1 Gas Used to L2 Gas Used

Tags

Add one or more keywords to help us categorize your metric. Don't overthink this! Optimism Superchain Gas Efficiency Layer Usage

Brief description

Describe how your impact metric is calculated in 2-3 sentences: This metric calculates the daily ratio of L1 gas used to L2 gas used for each project. A high ratio might indicate projects that rely more heavily on L1 or have less optimized L2 implementations. A lower ratio suggests a preference for the more scalable L2 network.

SQL code block

Insert the SQL that we should run to replicate your impact metric:

WITH project_events AS (
  SELECT
    project_id,
    DATE(bucket_day) AS event_date,
    SUM(CASE WHEN event_type = 'CONTRACT_INVOCATION_DAILY_L1_GAS_USED' THEN amount ELSE 0 END) AS daily_l1_gas_used,
    SUM(CASE WHEN event_type = 'CONTRACT_INVOCATION_DAILY_L2_GAS_USED' THEN amount ELSE 0 END) AS daily_l2_gas_used
  FROM `opensource-observer.oso.events_daily_from_project`
  GROUP BY project_id, DATE(bucket_day)
)
SELECT
  project_id,
  event_date,
  CASE WHEN daily_l2_gas_used > 0 THEN daily_l1_gas_used / daily_l2_gas_used ELSE NULL END AS l1_to_l2_gas_used_ratio
FROM project_events
WHERE daily_l2_gas_used > 0;

Optional: link

Add a link to script/notebook or longer form write-up about the metric:

ccerv1 commented 3 months ago