Skip to content

Commit

Permalink
Add DFL yields data
Browse files Browse the repository at this point in the history
  • Loading branch information
akan72 committed Dec 5, 2024
1 parent 6069dfa commit 7dab4dc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions models/staging/defillama/_defillama_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ sources:
database: LANDING_DATABASE
tables:
- name: raw_defillama_chain_data
- name: raw_defillama_yield_data
- name: raw_defillama_protocol_data
- name: raw_defillama_protocol_tvls
- name: raw_defillama_chain_tvls
Expand Down
29 changes: 29 additions & 0 deletions models/staging/defillama/fact_defillama_yields.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
WITH max_extraction AS (
SELECT max(extraction_date) AS max_date
FROM {{ source("PROD_LANDING", "raw_defillama_yield_data") }}
),
protocol_data AS (
SELECT
extraction_date::date as date,
parse_json(source_json):"data" AS data
FROM {{ source("PROD_LANDING", "raw_defillama_yield_data") }}
WHERE extraction_date = (SELECT max_date FROM max_extraction)

)
SELECT
date,
value:"chain"::string AS chain,
value:"project"::string AS project,
value:"symbol"::string AS symbol,
value:"tvlUsd"::float AS tvl_usd,
value:"apyBase" AS apy_base,
value:"apyReward" AS apy_reward,
value:"apy"::float AS apy,
value:"pool"::string AS pool,
value:"apyPct1D"::string AS apy_pct_1d,
value:"apyPct7D"::string AS apy_pct_7d,
value:"apyPct30D"::string AS apy_pct_30d,
value:"stablecoin"::boolean AS is_stablecoin,
value:"apyBase7d"::string AS apy_base_7d,
value:"apyMean30d"::string AS apy_mean_30d
FROM protocol_data, lateral flatten(input => data)

0 comments on commit 7dab4dc

Please sign in to comment.