Changes to be committed:

new file:   models/bronze/prices/bronze__complete_token_asset_metadata.sql
	new file:   models/bronze/prices/bronze__complete_token_prices.sql
	modified:   models/descriptions/columns.md
	new file:   models/descriptions/prices.md
	new file:   models/gold/prices/price__ez_asset_metadata.sql
	new file:   models/gold/prices/price__ez_asset_metadata.yml
	new file:   models/gold/prices/price__ez_prices_hourly.sql
	new file:   models/gold/prices/price__ez_prices_hourly.yml
	new file:   models/silver/prices/silver__complete_token_asset_metadata.sql
	new file:   models/silver/prices/silver__complete_token_asset_metadata.yml
	new file:   models/silver/prices/silver__complete_token_prices.sql
	new file:   models/silver/prices/silver__complete_token_prices.yml
	modified:   models/sources.yml
This commit is contained in:
Eric Laurello 2025-07-21 15:40:57 -04:00
parent 82a453b443
commit 83ed1930af
13 changed files with 484 additions and 3 deletions

View File

@ -0,0 +1,31 @@
{{ config (
materialized = 'view',
tags = ['bronze_prices']
) }}
SELECT
token_address,
asset_id,
symbol,
NAME,
decimals,
blockchain,
blockchain_name,
blockchain_id,
is_deprecated,
is_verified,
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 = 'sui'
AND len(token_address) > 1

View File

@ -0,0 +1,34 @@
{{ config (
materialized = 'view',
tags = ['bronze_prices']
) }}
SELECT
HOUR,
token_address,
asset_id,
symbol,
NAME,
decimals,
price,
blockchain,
blockchain_name,
blockchain_id,
is_imputed,
is_deprecated,
is_verified,
provider,
source,
_inserted_timestamp,
inserted_timestamp,
modified_timestamp,
complete_token_prices_id,
_invocation_id
FROM
{{ source(
'crosschain_silver',
'complete_token_prices'
) }}
WHERE
blockchain = 'sui'
AND len(token_address) > 1

View File

@ -272,4 +272,8 @@ Web URL pointing to the token's icon image. Used for visual representation in wa
{% docs id %}
Unique identifier for the token metadata record, linking metadata to on-chain token types. Used for metadata management, registry operations, and analytics joins. Example: 'tokenmeta_123'.
{% enddocs %}
{% enddocs %}
{% docs token_is_verified %}
Boolean flag indicating whether the token or price record is verified by Flipside's crosschain curation process. Verified tokens are prioritized for analytics and are considered reliable for most use cases. Unverified tokens may be incomplete, deprecated, or experimental.
{% enddocs %}

View File

@ -0,0 +1,128 @@
{% 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_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_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 %}

View File

@ -0,0 +1,36 @@
{{ config(
materialized = 'incremental',
incremental_strategy = 'merge',
merge_exclude_columns = ["inserted_timestamp"],
unique_key = 'ez_asset_metadata_id',
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(token_address, symbol)",
tags = ['gold_prices','core']
) }}
SELECT
token_address,
asset_id,
symbol,
NAME,
decimals,
blockchain,
FALSE AS is_native,
is_deprecated,
COALESCE(
is_verified,
FALSE
) AS token_is_verified,
{{ dbt_utils.generate_surrogate_key(['complete_token_asset_metadata_id']) }} AS ez_asset_metadata_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp
FROM
{{ ref('silver__complete_token_asset_metadata') }}
{% if is_incremental() %}
WHERE
modified_timestamp > (
SELECT
COALESCE(MAX(modified_timestamp), '1970-01-01' :: TIMESTAMP) AS modified_timestamp
FROM
{{ this }})
{% endif %}

View File

@ -0,0 +1,34 @@
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
columns:
- name: ASSET_ID
description: '{{ doc("prices_asset_id") }}'
- name: NAME
description: '{{ doc("prices_name") }}'
- name: SYMBOL
description: '{{ doc("prices_symbol") }}'
- name: TOKEN_ADDRESS
description: '{{ doc("prices_token_address") }}'
- name: BLOCKCHAIN
description: '{{ doc("prices_blockchain") }}'
- name: DECIMALS
description: '{{ doc("prices_decimals") }}'
- name: IS_NATIVE
description: '{{ doc("prices_is_native") }}'
- name: TOKEN_IS_VERIFIED
description: "{{ doc('token_is_verified') }}"
- name: IS_DEPRECATED
description: '{{ doc("prices_is_deprecated") }}'
- name: EZ_ASSET_METADATA_ID
description: '{{ doc("id") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("modified_timestamp") }}'

View File

@ -0,0 +1,40 @@
{{ config(
materialized = 'incremental',
incremental_strategy = 'merge',
merge_exclude_columns = ["inserted_timestamp"],
incremental_predicates = ["dynamic_range_predicate", "HOUR::date"],
unique_key = 'ez_prices_hourly_id',
cluster_by = ['hour::DATE'],
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(token_address, symbol)",
tags = ['gold_prices','core']
) }}
SELECT
HOUR,
token_address,
symbol,
NAME,
decimals,
price,
blockchain,
FALSE AS is_native,
is_deprecated,
is_imputed,
COALESCE(
is_verified,
FALSE
) AS token_is_verified,
{{ dbt_utils.generate_surrogate_key(['complete_token_prices_id']) }} AS ez_prices_hourly_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp
FROM
{{ ref('silver__complete_token_prices') }}
{% if is_incremental() %}
WHERE
modified_timestamp > (
SELECT
COALESCE(MAX(modified_timestamp), '1970-01-01' :: TIMESTAMP) AS modified_timestamp
FROM
{{ this }})
{% endif %}

View File

@ -0,0 +1,40 @@
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
columns:
- name: HOUR
description: '{{ doc("prices_hour")}}'
tests:
- dbt_expectations.expect_row_values_to_have_recent_data:
datepart: day
interval: 2
- name: TOKEN_ADDRESS
description: '{{ doc("prices_token_address") }}'
- name: SYMBOL
description: '{{ doc("prices_symbol") }}'
- name: BLOCKCHAIN
description: '{{ doc("prices_blockchain") }}'
- name: DECIMALS
description: '{{ doc("prices_decimals") }}'
- name: PRICE
description: '{{ doc("prices_price") }}'
- name: IS_NATIVE
description: '{{ doc("prices_is_native") }}'
- name: IS_IMPUTED
description: '{{ doc("prices_is_imputed") }}'
- name: TOKEN_IS_VERIFIED
description: "{{ doc('token_is_verified') }}"
- name: IS_DEPRECATED
description: '{{ doc("prices_is_deprecated") }}'
- name: EZ_PRICES_HOURLY_ID
description: '{{ doc("id") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("modified_timestamp") }}'

View File

@ -0,0 +1,41 @@
{{ config(
materialized = 'view',
tags = ['silver','core']
) }}
SELECT
LOWER(
A.token_address
) AS token_address,
asset_id,
symbol,
NAME,
decimals,
blockchain,
blockchain_name,
blockchain_id,
is_deprecated,
is_verified,
provider,
source,
_inserted_timestamp,
inserted_timestamp,
modified_timestamp,
{{ dbt_utils.generate_surrogate_key(['complete_token_asset_metadata_id']) }} AS complete_token_asset_metadata_id,
'{{ invocation_id }}' AS _invocation_id
FROM
{{ ref(
'bronze__complete_token_asset_metadata'
) }} A
{% if is_incremental() %}
WHERE
modified_timestamp >= (
SELECT
MAX(
modified_timestamp
)
FROM
{{ this }}
)
{% endif %}

View File

@ -0,0 +1,24 @@
version: 2
models:
- name: silver__complete_token_asset_metadata
columns:
- name: PROVIDER
tests:
- not_null
- name: TOKEN_ADDRESS
tests:
- not_null
- name: BLOCKCHAIN
tests:
- not_null
- name: BLOCKCHAIN_ID
tests:
- not_null
- name: MODIFIED_TIMESTAMP
tests:
- not_null
- name: COMPLETE_TOKEN_ASSET_METADATA_ID
tests:
- unique

View File

@ -0,0 +1,33 @@
{{ config(
materialized = 'view',
tags = ['silver','core']
) }}
SELECT
HOUR,
LOWER(
p.token_address
) AS token_address,
asset_id,
symbol,
NAME,
decimals,
price,
blockchain,
blockchain_name,
blockchain_id,
is_imputed,
is_deprecated,
is_verified,
provider,
source,
_inserted_timestamp,
inserted_timestamp,
modified_timestamp,
{{ dbt_utils.generate_surrogate_key(['complete_token_prices_id']) }} AS complete_token_prices_id,
'{{ invocation_id }}' AS _invocation_id
FROM
{{ ref(
'bronze__complete_token_prices'
) }}
p

View File

@ -0,0 +1,35 @@
version: 2
models:
- name: silver__complete_token_prices
columns:
- name: HOUR
tests:
- not_null
- name: TOKEN_ADDRESS
tests:
- not_null
- name: BLOCKCHAIN
tests:
- not_null
- name: BLOCKCHAIN_ID
tests:
- not_null
- name: PROVIDER
tests:
- not_null
- name: PRICE
tests:
- not_null
- name: IS_IMPUTED
tests:
- not_null
- name: _INSERTED_TIMESTAMP
tests:
- not_null
- name: MODIFIED_TIMESTAMP
tests:
- not_null
- name: COMPLETE_TOKEN_PRICES_ID
tests:
- unique

View File

@ -19,5 +19,6 @@ sources:
schema: silver
tables:
- name: number_sequence
- name: complete_native_prices
- name: labels_combined
- name: labels_combined
- name: complete_token_asset_metadata
- name: complete_token_prices