From f2fba5cc7b4848bbf0db84b0cbde15dbd3d3acef Mon Sep 17 00:00:00 2001 From: eric-laurello <102970824+eric-laurello@users.noreply.github.com> Date: Mon, 25 Nov 2024 11:38:27 -0500 Subject: [PATCH] log solar dex tvl (#32) * log solar dex tvl * tests, program_id recorded_at * typo, url, FR off --- models/gold/defi/defi__fact_solar_dex_tvl.sql | 27 +++++++++++++++++++ models/gold/defi/defi__fact_solar_dex_tvl.yml | 23 ++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 models/gold/defi/defi__fact_solar_dex_tvl.sql create mode 100644 models/gold/defi/defi__fact_solar_dex_tvl.yml diff --git a/models/gold/defi/defi__fact_solar_dex_tvl.sql b/models/gold/defi/defi__fact_solar_dex_tvl.sql new file mode 100644 index 0000000..4734ab8 --- /dev/null +++ b/models/gold/defi/defi__fact_solar_dex_tvl.sql @@ -0,0 +1,27 @@ +{{ config( + materialized = 'incremental', + tags = ['scheduled_non_core'], + full_refresh = false +) }} + +WITH lq AS ( + + SELECT + {{ target.database }}.live.udf_api( + '{Service}/main/info', + 'Vault/prod/eclipse/solar_dex' + ) :data :data AS response +) +SELECT + SYSDATE() AS recorded_at, + 'sooGfQwJ6enHfLTPfasFZtFR7DgobkJD77maDNEqGkD' AS program_id, + response :tvl :: FLOAT AS tvl, + response :users :: INT AS users, + response :volume24 :: FLOAT AS volume_24, + {{ dbt_utils.generate_surrogate_key( + ['recorded_at'] + ) }} AS fact_solar_dex_tvl_id, + SYSDATE() AS inserted_timestamp, + SYSDATE() AS modified_timestamp +FROM + lq diff --git a/models/gold/defi/defi__fact_solar_dex_tvl.yml b/models/gold/defi/defi__fact_solar_dex_tvl.yml new file mode 100644 index 0000000..9fc07b6 --- /dev/null +++ b/models/gold/defi/defi__fact_solar_dex_tvl.yml @@ -0,0 +1,23 @@ +version: 2 +models: + - name: defi__fact_solar_dex_tvl + description: Contains tvl for solar dex - data starts as of 2024-11-25 + recent_date_filter: &recent_date_filter + config: + where: modified_timestamp >= current_date - 7 + columns: + - name: recorded_at + description: "the date the tvl was recorded" + data_tests: + - dbt_expectations.expect_row_values_to_have_recent_data: + datepart: day + interval: 2 + - name: tvl + data_tests: + - not_null: *recent_date_filter + - name: users + data_tests: + - not_null: *recent_date_filter + - name: volume_24 + data_tests: + - not_null: *recent_date_filter \ No newline at end of file