Skip to content

Commit

Permalink
creating new ez metrics tables (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
SebMelendez01 authored Jun 14, 2024
1 parent 29ca958 commit ed4e31b
Show file tree
Hide file tree
Showing 16 changed files with 187 additions and 10 deletions.
36 changes: 36 additions & 0 deletions models/projects/axelar/core/ez_axelar_metrics.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{
config(
materialized="table"
, snowflake_warehouse="AXELAR"
, database="axelar"
, schema="core"
, alias="ez_metrics"
)
}}

with
fundamental_data as (
select
date
, txns
, daa as dau
from {{ ref("fact_axelar_daa_txns") }}
)
, github_data as ({{ get_github_metrics("Axelar Network") }})
, price_data as ({{ get_coingecko_metrics("axelar") }})
select
fundamental_data.date
, 'axelar' as chain
, txns
, dau
, weekly_commits_core_ecosystem
, weekly_commits_sub_ecosystem
, weekly_developers_core_ecosystem
, weekly_developers_sub_ecosystem
, price
, market_cap
, fdmc
from fundamental_data
left join github_data using (date)
left join price_data using (date)
where fundamental_data.date < to_date(sysdate())
50 changes: 50 additions & 0 deletions models/projects/gnosis/core/ez_gnosis_metrics.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{{
config(
materialized="table"
, snowflake_warehouse="GNOSIS"
, database="gnosis"
, schema="core"
, alias="ez_metrics"
)
}}


with
fundamental_data as (
select
date
, txns
, daa as dau
, gas_usd as fees
, gas as fees_native
, native_token_burn as revenue
, revenue
from {{ ref("fact_gnosis_daa_txns_gas_gas_usd") }}
left join {{ ref("agg_daily_gnosis_revenue") }} using (date)
)
, github_data as ({{ get_github_metrics("gnosis") }})
, defillama_data as ({{ get_defillama_metrics("gnosis") }})
, price_data as ({{ get_coingecko_metrics("gnosis") }})

select
fundamental_data.date
, 'gnosis' as chain
, txns
, dau
, fees
, fees_native
, revenue
, revenue as revenue_native
, weekly_commits_core_ecosystem
, weekly_commits_sub_ecosystem
, weekly_developers_core_ecosystem
, weekly_developers_sub_ecosystem
, dex_volumes
, price
, market_cap
, fdmc
from fundamental_data
left join github_data using (date)
left join defillama_data using (date)
left join price_data using (date)
where fundamental_data.date < to_date(sysdate())
51 changes: 51 additions & 0 deletions models/projects/mantle/core/ez_mantle_metrics.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{{
config(
materialized='table'
, snowflake_warehouse='MANTLE'
, database="mantle"
, schema="core"
, alias="ez_metrics"
)
}}


with fundamental_data as (
select
date
, txns
, daa as dau
, gas_usd as fees
, gas as fees_native
, revenue
, l1_data_cost
, l1_data_cost_native
from {{ ref("fact_mantle_daa_txns_gas_gas_usd_revenue") }}
)
, github_data as ({{ get_github_metrics("mantle") }})
, defillama_data as ({{ get_defillama_metrics("mantle") }})
, price_data as ({{ get_coingecko_metrics("mantle") }})

select
fundamental_data.date
, 'mantle' as chain
, txns
, dau
, fees
, fees_native
, revenue
, l1_data_cost
, l1_data_cost_native
, tvl
, dex_volumes
, weekly_commits_core_ecosystem
, weekly_commits_sub_ecosystem
, weekly_developers_core_ecosystem
, weekly_developers_sub_ecosystem
, price
, market_cap
, fdmc
from fundamental_data
left join github_data using (date)
left join defillama_data using (date)
left join price_data using (date)
where fundamental_data.date < to_date(sysdate())
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{
config(
materialized="table"
, snowflake_warehouse="PARALLEL_FINANCE"
, database="parallel_finance"
, schema="core"
, alias="ez_metrics"
)
}}

with
fundamental_data as (
select
date
, txns
, daa as dau
, gas_usd as fees
, gas as fees_native
from {{ ref("fact_parallel_finance_daa_gas_gas_usd_txns") }}
)
, defillama_data as ({{ get_defillama_metrics("parallel") }})

select
fundamental_data.date
, 'parallel_finance' as chain
, txns
, dau
, fees
, fees_native
, tvl
from fundamental_data
left join defillama_data using (date)
where fundamental_data.date < to_date(sysdate())
2 changes: 1 addition & 1 deletion models/staging/axelar/fact_axelar_daa_txns.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{ config(materialized="view") }}
{{ config(materialized="view", snowflake_warehouse="AXELAR") }}
select
block_timestamp::date as date,
count(distinct tx_from) as daa,
Expand Down
2 changes: 1 addition & 1 deletion models/staging/gnosis/fact_gnosis_blocks.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{ config(materialized="incremental", unique_key="block_number") }}
{{ config(materialized="incremental", unique_key="block_number", snowflake_warehouse="GNOSIS") }}
select
block_number,
block_timestamp,
Expand Down
2 changes: 1 addition & 1 deletion models/staging/gnosis/fact_gnosis_daa_txns_gas_gas_usd.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{ config(materialized="view") }}
{{ config(materialized="view", snowflake_warehouse="GNOSIS") }}
with
min_date as (
select dateadd(day, -5, min(to_timestamp(block_timestamp))::date) date
Expand Down
2 changes: 2 additions & 0 deletions models/staging/mantle/fact_mantle_daa.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
-- depends_on: {{ source("PROD_LANDING", "raw_mantle_daa") }}
{{ config(materialized="view", snowflake_warehouse="MANTLE") }}

select date, dau::integer as daa, 'mantle' as chain
from
(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ with
left join mantle_prices on grouped_data.date = mantle_prices.date
),
expenses_usd_table as (
select grouped_data.date, expenses * price as expenses_usd
select grouped_data.date, expenses * price as expenses_usd, expenses
from grouped_data
left join eth_prices on grouped_data.date = eth_prices.date
),
revenue as (
select gas_usd_table.date, gas_usd - expenses_usd as revenue
select gas_usd_table.date, gas_usd - expenses_usd as revenue, expenses_usd, expenses
from gas_usd_table
left join expenses_usd_table on gas_usd_table.date = expenses_usd_table.date
)
select grouped_data.date, daa, txns, gas, gas_usd, revenue, 'mantle' as chain
select grouped_data.date, daa, txns, gas, gas_usd, revenue, 'mantle' as chain, revenue.expenses as l1_data_cost_native, revenue.expenses_usd as l1_data_cost
from grouped_data
left join gas_usd_table on grouped_data.date = gas_usd_table.date
left join revenue on grouped_data.date = revenue.date
Expand Down
1 change: 1 addition & 0 deletions models/staging/mantle/fact_mantle_expenses.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
-- depends_on: {{ source("PROD_LANDING", "raw_mantle_expenses") }}
{{ config(materialized="view", snowflake_warehouse="MANTLE") }}
select
date,
case
Expand Down
2 changes: 2 additions & 0 deletions models/staging/mantle/fact_mantle_gas.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
-- depends_on: {{ source("PROD_LANDING", "raw_mantle_gas") }}
{{ config(materialized="view", snowflake_warehouse="MANTLE") }}

select date, gas::float / 1e18 as gas, 'mantle' as chain
from
(
Expand Down
2 changes: 2 additions & 0 deletions models/staging/mantle/fact_mantle_txns.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
-- depends_on: {{ source("PROD_LANDING", "raw_mantle_txns") }}
{{ config(materialized="view", snowflake_warehouse="MANTLE") }}

select date, txns::integer as txns, 'mantle' as chain
from
(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{ config(materialized="view") }}
{{ config(materialized="view", snowflake_warehouse="PARALLEL_FINANCE") }}

with
max_extraction as (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{ config(materialized="view") }}
{{ config(materialized="view", snowflake_warehouse="PARALLEL_FINANCE") }}
select t1.date, t1.chain, daa, txns, gas, gas_usd
from {{ ref("fact_parallel_finance_txns") }} t1
left join {{ ref("fact_parallel_finance_daa") }} t2 on t1.date = t2.date
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{ config(materialized="view") }}
{{ config(materialized="view", snowflake_warehouse="PARALLEL_FINANCE") }}

with
max_extraction as (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{ config(materialized="view") }}
{{ config(materialized="view", snowflake_warehouse="PARALLEL_FINANCE") }}

with
max_extraction as (
Expand Down

0 comments on commit ed4e31b

Please sign in to comment.