mirror of
https://github.com/FlipsideCrypto/sei-models.git
synced 2026-02-06 15:21:52 +00:00
AN-5350 deploy prices, update stats (#63)
* deploy prices, update stats * add pricing to overview
This commit is contained in:
parent
766f1132b1
commit
222b4842ef
@ -0,0 +1,25 @@
|
||||
{{ config (
|
||||
materialized = 'view'
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
asset_id,
|
||||
symbol,
|
||||
NAME,
|
||||
decimals,
|
||||
blockchain,
|
||||
is_deprecated,
|
||||
provider,
|
||||
source,
|
||||
_inserted_timestamp,
|
||||
inserted_timestamp,
|
||||
modified_timestamp,
|
||||
complete_native_asset_metadata_id,
|
||||
_invocation_id
|
||||
FROM
|
||||
{{ source(
|
||||
'crosschain_silver',
|
||||
'complete_native_asset_metadata'
|
||||
) }}
|
||||
WHERE
|
||||
blockchain = 'sei'
|
||||
@ -0,0 +1,28 @@
|
||||
{{ config (
|
||||
materialized = 'view'
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
asset_id,
|
||||
token_address,
|
||||
NAME,
|
||||
symbol,
|
||||
platform,
|
||||
platform_id,
|
||||
provider,
|
||||
source,
|
||||
_inserted_timestamp,
|
||||
inserted_timestamp,
|
||||
modified_timestamp,
|
||||
complete_provider_asset_metadata_id,
|
||||
_invocation_id
|
||||
FROM
|
||||
{{ source(
|
||||
'crosschain_silver',
|
||||
'complete_provider_asset_metadata'
|
||||
) }}
|
||||
WHERE
|
||||
platform IN (
|
||||
'sei-network',
|
||||
'sei-v2'
|
||||
)
|
||||
24
models/bronze/prices/bronze__complete_provider_prices.sql
Normal file
24
models/bronze/prices/bronze__complete_provider_prices.sql
Normal file
@ -0,0 +1,24 @@
|
||||
{{ config (
|
||||
materialized = 'view'
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
asset_id,
|
||||
recorded_hour,
|
||||
OPEN,
|
||||
high,
|
||||
low,
|
||||
CLOSE,
|
||||
provider,
|
||||
source,
|
||||
_inserted_timestamp,
|
||||
inserted_timestamp,
|
||||
modified_timestamp,
|
||||
complete_provider_prices_id,
|
||||
_invocation_id
|
||||
FROM
|
||||
{{ source(
|
||||
'crosschain_silver',
|
||||
'complete_provider_prices'
|
||||
) }}
|
||||
-- prices for all ids
|
||||
@ -0,0 +1,31 @@
|
||||
{{ config (
|
||||
materialized = 'view'
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
token_address,
|
||||
asset_id,
|
||||
symbol,
|
||||
NAME,
|
||||
decimals,
|
||||
blockchain,
|
||||
blockchain_name,
|
||||
blockchain_id,
|
||||
is_deprecated,
|
||||
provider,
|
||||
source,
|
||||
_inserted_timestamp,
|
||||
inserted_timestamp,
|
||||
modified_timestamp,
|
||||
complete_token_asset_metadata_id,
|
||||
_invocation_id
|
||||
FROM
|
||||
{{ source(
|
||||
'crosschain_silver',
|
||||
'complete_token_asset_metadata'
|
||||
) }}
|
||||
WHERE
|
||||
blockchain IN (
|
||||
'sei network',
|
||||
'sei v2'
|
||||
)
|
||||
34
models/bronze/prices/bronze__complete_token_prices.sql
Normal file
34
models/bronze/prices/bronze__complete_token_prices.sql
Normal file
@ -0,0 +1,34 @@
|
||||
{{ config (
|
||||
materialized = 'view'
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
HOUR,
|
||||
token_address,
|
||||
asset_id,
|
||||
symbol,
|
||||
NAME,
|
||||
decimals,
|
||||
price,
|
||||
blockchain,
|
||||
blockchain_name,
|
||||
blockchain_id,
|
||||
is_imputed,
|
||||
is_deprecated,
|
||||
provider,
|
||||
source,
|
||||
_inserted_timestamp,
|
||||
inserted_timestamp,
|
||||
modified_timestamp,
|
||||
complete_token_prices_id,
|
||||
_invocation_id
|
||||
FROM
|
||||
{{ source(
|
||||
'crosschain_silver',
|
||||
'complete_token_prices'
|
||||
) }}
|
||||
WHERE
|
||||
blockchain IN (
|
||||
'sei network',
|
||||
'sei v2'
|
||||
)
|
||||
@ -20,6 +20,7 @@ There is more information on how to use dbt docs in the last section of this doc
|
||||
### Core Tables (`SEI`.`CORE`.`<table_name>`)
|
||||
### Defi Tables (`SEI`.`DEFI`.`<table_name>`)
|
||||
### Governance Tables (`SEI`.`GOV`.`<table_name>`)
|
||||
### Pricing Tables (`SEI`.`PRICE`.`<table_name>`)
|
||||
### Statistics/Analytics Tables (`SEI`.`STATS`.`<table_name>`)
|
||||
### EVM Tables (`SEI`.`CORE_EVM`.`<table_name>`)
|
||||
|
||||
@ -49,6 +50,12 @@ There is more information on how to use dbt docs in the last section of this doc
|
||||
- [fact_dex_swaps](#!/model/model.sei_models.defi__fact_dex_swaps)
|
||||
- [fact_lp_actions](#!/model/model.sei_models.defi__fact_lp_actions)
|
||||
|
||||
**Pricing Tables:**
|
||||
- [dim_asset_metadata](#!/model/model.sei_models.price__dim_asset_metadata)
|
||||
- [fact_prices_ohlc_hourly](#!/model/model.sei_models.price__fact_prices_ohlc_hourly)
|
||||
- [ez_asset_metadata](#!/model/model.sei_models.price__ez_asset_metadata)
|
||||
- [ez_prices_hourly](#!/model/model.sei_models.price__ez_prices_hourly)
|
||||
|
||||
**Stats EZ Tables:**
|
||||
- [ez_core_metrics_hourly](#!/model/model.sei_models.ez_core_metrics_hourly)
|
||||
|
||||
|
||||
143
models/descriptions/prices/prices.md
Normal file
143
models/descriptions/prices/prices.md
Normal file
@ -0,0 +1,143 @@
|
||||
{% docs prices_dim_asset_metadata_table_doc %}
|
||||
|
||||
A comprehensive dimensional table holding asset metadata and other relevant details pertaining to each id, from multiple providers. This data set includes raw, non-transformed data coming directly from the provider APIs and rows are not intended to be unique. As a result, there may be data quality issues persisting in the APIs that flow through to this dimensional model. If you are interested in using a curated data set instead, please utilize ez_asset_metadata.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs prices_ez_asset_metadata_table_doc %}
|
||||
|
||||
A convenience table holding prioritized asset metadata and other relevant details pertaining to each token_address and native asset. This data set is highly curated and contains metadata for one unique asset per blockchain.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs prices_fact_prices_ohlc_hourly_table_doc %}
|
||||
|
||||
A comprehensive fact table holding id and provider specific open, high, low, close hourly prices, from multiple providers. This data set includes raw, non-transformed data coming directly from the provider APIs and rows are not intended to be unique. As a result, there may be data quality issues persisting in the APIs that flow through to this fact based model. If you are interested in using a curated data set instead, please utilize ez_prices_hourly.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs prices_ez_prices_hourly_table_doc %}
|
||||
|
||||
A convenience table for determining token prices by address and blockchain, and native asset prices by symbol and blockchain. This data set is highly curated and contains metadata for one price per hour per unique asset and blockchain.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs prices_provider %}
|
||||
|
||||
The provider or source of the data.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs prices_asset_id %}
|
||||
|
||||
The unique identifier representing the asset.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs prices_name %}
|
||||
|
||||
The name of asset.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs prices_symbol %}
|
||||
|
||||
The symbol of asset.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs prices_token_address %}
|
||||
|
||||
The specific address representing the asset on a specific platform. This will be NULL if referring to a native asset.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs prices_token_address_evm %}
|
||||
|
||||
The specific address representing the asset on a specific platform. This will be NULL if referring to a native asset. The case (upper / lower) may or may not be specified within the `dim_asset_metadata` table, as this column is raw and not transformed, coming directly from the provider APIs. However, in the `ez_` views, it will be lowercase by default for all EVMs.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs prices_blockchain %}
|
||||
|
||||
The Blockchain, Network, or Platform for this asset.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs prices_blockchain_id %}
|
||||
|
||||
The unique identifier of the Blockchain, Network, or Platform for this asset.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs prices_decimals %}
|
||||
|
||||
The number of decimals for the asset. May be NULL.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs prices_is_native %}
|
||||
|
||||
A flag indicating assets native to the respective blockchain.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs prices_is_deprecated %}
|
||||
|
||||
A flag indicating if the asset is deprecated or no longer supported by the provider.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs prices_id_deprecation %}
|
||||
|
||||
Deprecating soon! Please use the `asset_id` column instead.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs prices_decimals_deprecation %}
|
||||
|
||||
Deprecating soon! Please use the decimals column in `ez_asset_metadata` or join in `dim_contracts` instead.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs prices_hour %}
|
||||
|
||||
Hour that the price was recorded at.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs prices_price %}
|
||||
|
||||
Closing price of the recorded hour in USD.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs prices_is_imputed %}
|
||||
|
||||
A flag indicating if the price was imputed, or derived, from the last arriving record. This is generally used for tokens with low-liquidity or inconsistent reporting.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs prices_open %}
|
||||
|
||||
Opening price of the recorded hour in USD.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs prices_high %}
|
||||
|
||||
Highest price of the recorded hour in USD
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs prices_low %}
|
||||
|
||||
Lowest price of the recorded hour in USD
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs prices_close %}
|
||||
|
||||
Closing price of the recorded hour in USD
|
||||
|
||||
{% enddocs %}
|
||||
58
models/gold/price/price__dim_asset_metadata.sql
Normal file
58
models/gold/price/price__dim_asset_metadata.sql
Normal file
@ -0,0 +1,58 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'dim_asset_metadata_id',
|
||||
tags = ['core']
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
token_address,
|
||||
asset_id,
|
||||
symbol,
|
||||
NAME,
|
||||
platform AS blockchain,
|
||||
platform_id AS blockchain_id,
|
||||
provider,
|
||||
inserted_timestamp,
|
||||
modified_timestamp,
|
||||
complete_provider_asset_metadata_id AS dim_asset_metadata_id
|
||||
FROM
|
||||
{{ ref('silver__complete_provider_asset_metadata') }}
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
modified_timestamp
|
||||
)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
UNION ALL
|
||||
SELECT
|
||||
'usei' AS token_address,
|
||||
asset_id,
|
||||
LOWER(symbol) AS symbol,
|
||||
NAME,
|
||||
'sei-network' AS blockchain,
|
||||
'sei-network' AS blockchain_id,
|
||||
provider,
|
||||
inserted_timestamp,
|
||||
modified_timestamp,
|
||||
complete_native_asset_metadata_id AS dim_asset_metadata_id
|
||||
FROM
|
||||
{{ ref('silver__complete_native_asset_metadata') }}
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
modified_timestamp
|
||||
)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
41
models/gold/price/price__dim_asset_metadata.yml
Normal file
41
models/gold/price/price__dim_asset_metadata.yml
Normal file
@ -0,0 +1,41 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: price__dim_asset_metadata
|
||||
description: '{{ doc("prices_dim_asset_metadata_table_doc") }}'
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- ASSET_ID
|
||||
- TOKEN_ADDRESS
|
||||
- NAME
|
||||
- SYMBOL
|
||||
- BLOCKCHAIN
|
||||
- BLOCKCHAIN_ID
|
||||
- PROVIDER
|
||||
columns:
|
||||
- name: PROVIDER
|
||||
description: '{{ doc("prices_provider")}}'
|
||||
tests:
|
||||
- not_null
|
||||
- name: ASSET_ID
|
||||
description: '{{ doc("prices_asset_id") }}'
|
||||
tests:
|
||||
- not_null
|
||||
- name: NAME
|
||||
description: '{{ doc("prices_name") }}'
|
||||
- name: SYMBOL
|
||||
description: '{{ doc("prices_symbol") }}'
|
||||
- name: TOKEN_ADDRESS
|
||||
description: '{{ doc("prices_token_address_evm") }}'
|
||||
- name: BLOCKCHAIN
|
||||
description: '{{ doc("prices_blockchain") }}'
|
||||
- name: BLOCKCHAIN_ID
|
||||
description: '{{ doc("prices_blockchain_id") }}'
|
||||
- name: DIM_ASSET_METADATA_ID
|
||||
description: '{{ doc("pk") }}'
|
||||
- name: INSERTED_TIMESTAMP
|
||||
description: '{{ doc("inserted_timestamp") }}'
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: '{{ doc("modified_timestamp") }}'
|
||||
tests:
|
||||
- not_null
|
||||
106
models/gold/price/price__ez_asset_metadata.sql
Normal file
106
models/gold/price/price__ez_asset_metadata.sql
Normal file
@ -0,0 +1,106 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'ez_asset_metadata_id',
|
||||
tags = ['core']
|
||||
) }}
|
||||
|
||||
WITH base AS (
|
||||
|
||||
SELECT
|
||||
token_address,
|
||||
asset_id,
|
||||
symbol,
|
||||
NAME,
|
||||
decimals,
|
||||
blockchain,
|
||||
FALSE AS is_native,
|
||||
is_deprecated,
|
||||
inserted_timestamp,
|
||||
modified_timestamp,
|
||||
complete_token_asset_metadata_id AS ez_asset_metadata_id
|
||||
FROM
|
||||
{{ ref('silver__complete_token_asset_metadata') }}
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
DATEADD(
|
||||
'minute',
|
||||
-90,
|
||||
modified_timestamp
|
||||
)
|
||||
)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
|
||||
qualify(ROW_NUMBER() over (PARTITION BY token_address
|
||||
ORDER BY
|
||||
provider, inserted_timestamp DESC) = 1)
|
||||
UNION ALL
|
||||
SELECT
|
||||
'usei' AS token_address,
|
||||
asset_id,
|
||||
symbol,
|
||||
NAME,
|
||||
decimals,
|
||||
blockchain,
|
||||
TRUE AS is_native,
|
||||
is_deprecated,
|
||||
inserted_timestamp,
|
||||
modified_timestamp,
|
||||
complete_native_asset_metadata_id AS ez_asset_metadata_id
|
||||
FROM
|
||||
{{ ref('silver__complete_native_asset_metadata') }}
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
DATEADD(
|
||||
'minute',
|
||||
-90,
|
||||
modified_timestamp
|
||||
)
|
||||
)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
)
|
||||
SELECT
|
||||
token_address,
|
||||
asset_id,
|
||||
COALESCE(
|
||||
b.symbol,
|
||||
C.symbol,
|
||||
A.symbol
|
||||
) AS symbol,
|
||||
COALESCE(
|
||||
b.token_name,
|
||||
C.name,
|
||||
A.name
|
||||
) AS NAME,
|
||||
COALESCE(
|
||||
b.decimals,
|
||||
C.decimals,
|
||||
A.decimals
|
||||
) AS decimals,
|
||||
blockchain,
|
||||
is_native,
|
||||
is_deprecated,
|
||||
A.inserted_timestamp,
|
||||
A.modified_timestamp,
|
||||
ez_asset_metadata_id
|
||||
FROM
|
||||
base A
|
||||
LEFT JOIN {{ ref('core__dim_tokens') }}
|
||||
b
|
||||
ON A.token_address = b.currency
|
||||
LEFT JOIN {{ ref('core_evm__dim_contracts') }} C
|
||||
ON A.token_address = C.address
|
||||
39
models/gold/price/price__ez_asset_metadata.yml
Normal file
39
models/gold/price/price__ez_asset_metadata.yml
Normal file
@ -0,0 +1,39 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: price__ez_asset_metadata
|
||||
description: '{{ doc("prices_ez_asset_metadata_table_doc") }}'
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- TOKEN_ADDRESS
|
||||
- BLOCKCHAIN
|
||||
columns:
|
||||
- name: ASSET_ID
|
||||
description: '{{ doc("prices_asset_id") }}'
|
||||
tests:
|
||||
- not_null
|
||||
- name: NAME
|
||||
description: '{{ doc("prices_name") }}'
|
||||
- name: SYMBOL
|
||||
description: '{{ doc("prices_symbol") }}'
|
||||
- name: TOKEN_ADDRESS
|
||||
description: '{{ doc("prices_token_address_evm") }}'
|
||||
tests:
|
||||
- not_null
|
||||
- name: BLOCKCHAIN
|
||||
description: '{{ doc("prices_blockchain") }}'
|
||||
tests:
|
||||
- not_null
|
||||
- name: DECIMALS
|
||||
description: '{{ doc("prices_decimals") }}'
|
||||
- name: IS_NATIVE
|
||||
description: '{{ doc("prices_is_native") }}'
|
||||
- name: IS_DEPRECATED
|
||||
description: '{{ doc("prices_is_deprecated") }}'
|
||||
- name: EZ_ASSET_METADATA_ID
|
||||
description: '{{ doc("pk") }}'
|
||||
- name: INSERTED_TIMESTAMP
|
||||
description: '{{ doc("inserted_timestamp") }}'
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: '{{ doc("modified_timestamp") }}'
|
||||
|
||||
90
models/gold/price/price__ez_prices_hourly.sql
Normal file
90
models/gold/price/price__ez_prices_hourly.sql
Normal file
@ -0,0 +1,90 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'ez_prices_hourly_id',
|
||||
cluster_by = ['hour::DATE'],
|
||||
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(token_address, symbol, name)",
|
||||
tags = ['core']
|
||||
) }}
|
||||
|
||||
WITH base AS (
|
||||
|
||||
SELECT
|
||||
HOUR,
|
||||
token_address,
|
||||
price,
|
||||
blockchain,
|
||||
FALSE AS is_native,
|
||||
is_imputed,
|
||||
is_deprecated,
|
||||
inserted_timestamp,
|
||||
modified_timestamp,
|
||||
complete_token_prices_id AS ez_prices_hourly_id
|
||||
FROM
|
||||
{{ ref('silver__complete_token_prices') }}
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
DATEADD(
|
||||
'minute',
|
||||
-90,
|
||||
modified_timestamp
|
||||
)
|
||||
)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
UNION ALL
|
||||
SELECT
|
||||
HOUR,
|
||||
'usei' AS token_address,
|
||||
price,
|
||||
blockchain,
|
||||
TRUE AS is_native,
|
||||
is_imputed,
|
||||
is_deprecated,
|
||||
inserted_timestamp,
|
||||
modified_timestamp,
|
||||
complete_native_prices_id AS ez_prices_hourly_id
|
||||
FROM
|
||||
{{ ref('silver__complete_native_prices') }}
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
DATEADD(
|
||||
'minute',
|
||||
-90,
|
||||
modified_timestamp
|
||||
)
|
||||
)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
)
|
||||
SELECT
|
||||
HOUR,
|
||||
A.token_address,
|
||||
b.symbol,
|
||||
b.name,
|
||||
b.decimals,
|
||||
price,
|
||||
A.blockchain,
|
||||
A.is_native,
|
||||
A.is_imputed,
|
||||
A.is_deprecated,
|
||||
A.inserted_timestamp,
|
||||
A.modified_timestamp,
|
||||
A.ez_prices_hourly_id
|
||||
FROM
|
||||
base A
|
||||
LEFT JOIN {{ ref('price__ez_asset_metadata') }}
|
||||
b
|
||||
ON A.token_address = b.token_address
|
||||
47
models/gold/price/price__ez_prices_hourly.yml
Normal file
47
models/gold/price/price__ez_prices_hourly.yml
Normal file
@ -0,0 +1,47 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: price__ez_prices_hourly
|
||||
description: '{{ doc("prices_ez_prices_hourly_table_doc") }}'
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- HOUR
|
||||
- TOKEN_ADDRESS
|
||||
- BLOCKCHAIN
|
||||
columns:
|
||||
- name: HOUR
|
||||
description: '{{ doc("prices_hour")}}'
|
||||
tests:
|
||||
- not_null
|
||||
- name: TOKEN_ADDRESS
|
||||
description: '{{ doc("prices_token_address_evm") }}'
|
||||
tests:
|
||||
- not_null
|
||||
- name: SYMBOL
|
||||
description: '{{ doc("prices_symbol") }}'
|
||||
- name: BLOCKCHAIN
|
||||
description: '{{ doc("prices_blockchain") }}'
|
||||
- name: DECIMALS
|
||||
description: '{{ doc("prices_decimals") }}'
|
||||
- name: PRICE
|
||||
description: '{{ doc("prices_price") }}'
|
||||
tests:
|
||||
- not_null
|
||||
- name: IS_NATIVE
|
||||
description: '{{ doc("prices_is_native") }}'
|
||||
tests:
|
||||
- not_null
|
||||
- name: IS_IMPUTED
|
||||
description: '{{ doc("prices_is_imputed") }}'
|
||||
tests:
|
||||
- not_null
|
||||
- name: IS_DEPRECATED
|
||||
description: '{{ doc("prices_is_deprecated") }}'
|
||||
tests:
|
||||
- not_null
|
||||
- name: EZ_PRICES_HOURLY_ID
|
||||
description: '{{ doc("pk") }}'
|
||||
- name: INSERTED_TIMESTAMP
|
||||
description: '{{ doc("inserted_timestamp") }}'
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: '{{ doc("modified_timestamp") }}'
|
||||
33
models/gold/price/price__fact_prices_ohlc_hourly.sql
Normal file
33
models/gold/price/price__fact_prices_ohlc_hourly.sql
Normal file
@ -0,0 +1,33 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'fact_prices_ohlc_hourly_id',
|
||||
cluster_by = ['HOUR::DATE','asset_id'],
|
||||
tags = ['core']
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
asset_id,
|
||||
recorded_hour AS HOUR,
|
||||
OPEN,
|
||||
high,
|
||||
low,
|
||||
CLOSE,
|
||||
provider,
|
||||
inserted_timestamp,
|
||||
modified_timestamp,
|
||||
complete_provider_prices_id AS fact_prices_ohlc_hourly_id
|
||||
FROM
|
||||
{{ ref('silver__complete_provider_prices') }}
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
modified_timestamp
|
||||
)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
37
models/gold/price/price__fact_prices_ohlc_hourly.yml
Normal file
37
models/gold/price/price__fact_prices_ohlc_hourly.yml
Normal file
@ -0,0 +1,37 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: price__fact_prices_ohlc_hourly
|
||||
description: '{{ doc("prices_fact_prices_ohlc_hourly_table_doc") }}'
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- HOUR
|
||||
- ASSET_ID
|
||||
- PROVIDER
|
||||
columns:
|
||||
- name: HOUR
|
||||
description: '{{ doc("prices_hour")}}'
|
||||
tests:
|
||||
- not_null
|
||||
- name: ASSET_ID
|
||||
description: '{{ doc("prices_asset_id") }}'
|
||||
tests:
|
||||
- not_null
|
||||
- name: OPEN
|
||||
description: '{{ doc("prices_open") }}'
|
||||
- name: HIGH
|
||||
description: '{{ doc("prices_high") }}'
|
||||
- name: LOW
|
||||
description: '{{ doc("prices_low") }}'
|
||||
- name: CLOSE
|
||||
description: '{{ doc("prices_close") }}'
|
||||
tests:
|
||||
- not_null
|
||||
- name: FACT_PRICES_OHLC_HOURLY_ID
|
||||
description: '{{ doc("pk") }}'
|
||||
tests:
|
||||
- not_null
|
||||
- name: INSERTED_TIMESTAMP
|
||||
description: '{{ doc("inserted_timestamp") }}'
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: '{{ doc("modified_timestamp") }}'
|
||||
@ -15,7 +15,7 @@ WITH txs AS (
|
||||
unique_from_count,
|
||||
total_fees AS total_fees_native,
|
||||
LAST_VALUE(
|
||||
p.close ignore nulls
|
||||
p.price ignore nulls
|
||||
) over (
|
||||
ORDER BY
|
||||
block_timestamp_hour rows unbounded preceding
|
||||
@ -26,10 +26,10 @@ WITH txs AS (
|
||||
FROM
|
||||
{{ ref('silver_stats__core_metrics_hourly') }}
|
||||
s
|
||||
LEFT JOIN {{ ref('silver__hourly_prices_coin_gecko') }}
|
||||
LEFT JOIN {{ ref('price__ez_prices_hourly') }}
|
||||
p
|
||||
ON s.block_timestamp_hour = p.recorded_hour
|
||||
AND p.id = 'sei-network'
|
||||
ON s.block_timestamp_hour = p.hour
|
||||
AND p.token_address = 'usei'
|
||||
)
|
||||
SELECT
|
||||
A.block_timestamp_hour,
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
{{ config(
|
||||
materialized = 'view'
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
asset_id,
|
||||
symbol,
|
||||
NAME,
|
||||
decimals,
|
||||
blockchain,
|
||||
is_deprecated,
|
||||
provider,
|
||||
source,
|
||||
_inserted_timestamp,
|
||||
inserted_timestamp,
|
||||
modified_timestamp,
|
||||
complete_native_asset_metadata_id,
|
||||
_invocation_id
|
||||
FROM
|
||||
{{ ref(
|
||||
'bronze__complete_native_asset_metadata'
|
||||
) }}
|
||||
@ -0,0 +1,10 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: silver__complete_native_asset_metadata
|
||||
|
||||
columns:
|
||||
- name: PROVIDER
|
||||
- name: SYMBOL
|
||||
- name: BLOCKCHAIN
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
- name: COMPLETE_NATIVE_ASSET_METADATA_ID
|
||||
@ -1,8 +1,5 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'complete_native_prices_id',
|
||||
tags = ['core']
|
||||
materialized = 'view'
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
@ -26,15 +23,3 @@ FROM
|
||||
{{ ref(
|
||||
'bronze__complete_native_prices'
|
||||
) }}
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
modified_timestamp
|
||||
)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
{{ config(
|
||||
materialized = 'view'
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
asset_id,
|
||||
token_address,
|
||||
NAME,
|
||||
symbol,
|
||||
platform,
|
||||
platform_id,
|
||||
provider,
|
||||
source,
|
||||
_inserted_timestamp,
|
||||
inserted_timestamp,
|
||||
modified_timestamp,
|
||||
complete_provider_asset_metadata_id,
|
||||
_invocation_id
|
||||
FROM
|
||||
{{ ref(
|
||||
'bronze__complete_provider_asset_metadata'
|
||||
) }}
|
||||
@ -0,0 +1,8 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: silver__complete_provider_asset_metadata
|
||||
columns:
|
||||
- name: PROVIDER
|
||||
- name: ASSET_ID
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
- name: COMPLETE_PROVIDER_ASSET_METADATA_ID
|
||||
47
models/silver/price/silver__complete_provider_prices.sql
Normal file
47
models/silver/price/silver__complete_provider_prices.sql
Normal file
@ -0,0 +1,47 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'complete_provider_prices_id',
|
||||
cluster_by = ['recorded_hour::DATE'],
|
||||
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(asset_id)",
|
||||
tags = ['core']
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
p.asset_id,
|
||||
recorded_hour,
|
||||
OPEN,
|
||||
high,
|
||||
low,
|
||||
CLOSE,
|
||||
p.provider,
|
||||
p.source,
|
||||
p._inserted_timestamp,
|
||||
p.inserted_timestamp,
|
||||
p.modified_timestamp,
|
||||
p.complete_provider_prices_id,
|
||||
p._invocation_id
|
||||
FROM
|
||||
{{ ref(
|
||||
'bronze__complete_provider_prices'
|
||||
) }}
|
||||
p
|
||||
INNER JOIN {{ ref('bronze__complete_provider_asset_metadata') }}
|
||||
m
|
||||
ON p.asset_id = m.asset_id
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
p.modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
modified_timestamp
|
||||
)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
|
||||
qualify(ROW_NUMBER() over (PARTITION BY p.asset_id, recorded_hour, p.provider
|
||||
ORDER BY
|
||||
p.modified_timestamp DESC)) = 1
|
||||
25
models/silver/price/silver__complete_provider_prices.yml
Normal file
25
models/silver/price/silver__complete_provider_prices.yml
Normal file
@ -0,0 +1,25 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: silver__complete_provider_prices
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- ASSET_ID
|
||||
- RECORDED_HOUR
|
||||
- PROVIDER
|
||||
columns:
|
||||
- name: PROVIDER
|
||||
tests:
|
||||
- not_null
|
||||
- name: ASSET_ID
|
||||
tests:
|
||||
- not_null
|
||||
- name: RECORDED_HOUR
|
||||
tests:
|
||||
- not_null
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
tests:
|
||||
- not_null
|
||||
- name: COMPLETE_PROVIDER_PRICES_ID
|
||||
tests:
|
||||
- unique
|
||||
@ -0,0 +1,27 @@
|
||||
{{ config(
|
||||
materialized = 'view'
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
LOWER(
|
||||
A.token_address
|
||||
) AS token_address,
|
||||
asset_id,
|
||||
symbol,
|
||||
NAME,
|
||||
decimals,
|
||||
blockchain,
|
||||
blockchain_name,
|
||||
blockchain_id,
|
||||
is_deprecated,
|
||||
provider,
|
||||
source,
|
||||
_inserted_timestamp,
|
||||
inserted_timestamp,
|
||||
modified_timestamp,
|
||||
complete_token_asset_metadata_id,
|
||||
_invocation_id
|
||||
FROM
|
||||
{{ ref(
|
||||
'bronze__complete_token_asset_metadata'
|
||||
) }} A
|
||||
@ -0,0 +1,10 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: silver__complete_token_asset_metadata
|
||||
columns:
|
||||
- name: PROVIDER
|
||||
- name: TOKEN_ADDRESS
|
||||
- name: BLOCKCHAIN
|
||||
- name: BLOCKCHAIN_ID
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
- name: COMPLETE_TOKEN_ASSET_METADATA_ID
|
||||
31
models/silver/price/silver__complete_token_prices.sql
Normal file
31
models/silver/price/silver__complete_token_prices.sql
Normal file
@ -0,0 +1,31 @@
|
||||
{{ config(
|
||||
materialized = 'view'
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
HOUR,
|
||||
LOWER(
|
||||
p.token_address
|
||||
) AS token_address,
|
||||
asset_id,
|
||||
symbol,
|
||||
NAME,
|
||||
decimals,
|
||||
price,
|
||||
blockchain,
|
||||
blockchain_name,
|
||||
blockchain_id,
|
||||
is_imputed,
|
||||
is_deprecated,
|
||||
provider,
|
||||
source,
|
||||
_inserted_timestamp,
|
||||
inserted_timestamp,
|
||||
modified_timestamp,
|
||||
complete_token_prices_id,
|
||||
_invocation_id
|
||||
FROM
|
||||
{{ ref(
|
||||
'bronze__complete_token_prices'
|
||||
) }}
|
||||
p
|
||||
15
models/silver/price/silver__complete_token_prices.yml
Normal file
15
models/silver/price/silver__complete_token_prices.yml
Normal file
@ -0,0 +1,15 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: silver__complete_token_prices
|
||||
|
||||
columns:
|
||||
- name: HOUR
|
||||
- name: TOKEN_ADDRESS
|
||||
- name: BLOCKCHAIN
|
||||
- name: BLOCKCHAIN_ID
|
||||
- name: PROVIDER
|
||||
- name: PRICE
|
||||
- name: IS_IMPUTED
|
||||
- name: _INSERTED_TIMESTAMP
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
- name: COMPLETE_TOKEN_PRICES_ID
|
||||
@ -31,6 +31,10 @@ sources:
|
||||
- name: labels_combined
|
||||
- name: complete_native_asset_metadata
|
||||
- name: complete_native_prices
|
||||
- name: complete_token_asset_metadata
|
||||
- name: complete_token_prices
|
||||
- name: complete_provider_asset_metadata
|
||||
- name: complete_provider_prices
|
||||
- name: bronze_streamline
|
||||
database: streamline
|
||||
schema: |
|
||||
|
||||
Loading…
Reference in New Issue
Block a user