Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ton Dex Volumes Data #92

Merged
merged 1 commit into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion models/projects/ton/core/ez_ton_metrics.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ with
),
price_data as ({{ get_coingecko_metrics("the-open-network") }}),
defillama_data as ({{ get_defillama_metrics("ton") }}),
dex_data as (
select
date,
dex_volumes
from {{ ref("fact_ton_dex_volumes") }}
),
github_data as ({{ get_github_metrics("ton") }})
select
fundamental_data.date,
Expand All @@ -39,7 +45,7 @@ select
market_cap,
fdmc,
tvl,
dex_volumes,
dex_data.dex_volumes,
weekly_commits_core_ecosystem,
weekly_commits_sub_ecosystem,
weekly_developers_core_ecosystem,
Expand All @@ -48,4 +54,5 @@ from fundamental_data
left join price_data on fundamental_data.date = price_data.date
left join defillama_data on fundamental_data.date = defillama_data.date
left join github_data on fundamental_data.date = github_data.date
left join dex_data on fundamental_data.date = dex_data.date
where fundamental_data.date < to_date(sysdate())
1 change: 1 addition & 0 deletions models/staging/ton/__ton__sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ sources:
- name: raw_ton_gas
- name: raw_ton_revenue
- name: raw_ton_txns
- name: raw_ton_dex_volumes
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
models:
- name: fact_ton_daa_txns_gas_gas_usd_revenue_revenue_native
tests:
- "dbt_expectations.expect_table_row_count_to_be_between:":
min_value: 1
max_value: 1000000
columns:
- name: CHAIN
tests:
- not_null
- dbt_expectations.expect_column_to_exist
- name: txns
tests:
- not_null
- dbt_expectations.expect_column_to_exist
- dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs:
date_column_name: DATE
period: day
lookback_periods: 1
trend_periods: 14
test_periods: 28
sigma_threshold: 3
take_logs: true
severity: warn
- name: dau
tests:
- dbt_expectations.expect_column_to_exist
- dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs:
date_column_name: DATE
period: day
lookback_periods: 1
trend_periods: 14
test_periods: 28
sigma_threshold: 3
take_logs: true
severity: warn
- name: date
tests:
- not_null
- dbt_expectations.expect_column_to_exist
- dbt_expectations.expect_row_values_to_have_recent_data:
datepart: day
interval: 3
severity: warn
- name: revenue
tests:
- dbt_expectations.expect_column_to_exist
- dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs:
date_column_name: DATE
period: day
lookback_periods: 1
trend_periods: 14
test_periods: 28
sigma_threshold: 3
take_logs: true
severity: warn
- name: fees
tests:
- dbt_expectations.expect_column_to_exist
- dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs:
date_column_name: DATE
period: day
lookback_periods: 1
trend_periods: 14
test_periods: 28
sigma_threshold: 3
take_logs: true
severity: warn
- name: fees_native
tests:
- dbt_expectations.expect_column_to_exist
- dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs:
date_column_name: DATE
period: day
lookback_periods: 1
trend_periods: 14
test_periods: 28
sigma_threshold: 3
take_logs: true
severity: warn
22 changes: 22 additions & 0 deletions models/staging/ton/fact_ton_dex_volumes.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
with
max_extraction as (
select
max(extraction_date) as max_extraction,
value:date::date as date
from landing_database.prod_landing.raw_ton_dex_volumes,
lateral flatten(input => source_json)
group by date
),
flattened_data as (
select value:"date"::date as date, value:"dex_volumes"::float as dex_volumes, extraction_date
from landing_database.prod_landing.raw_ton_dex_volumes,
lateral flatten(input => source_json)
),
prices as ({{ get_coingecko_price_with_latest("the-open-network") }})
select
t1.date,
'ton' as chain,
dex_volumes * price as dex_volumes
from flattened_data t1
inner join max_extraction t2 on t1.date = t2.date and t1.extraction_date = t2.max_extraction
left join prices on t1.date = prices.date
Loading