-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |