General: Prices: Prices Pipeline - FlipsideCrypto/fsc-evm GitHub Wiki
This guide covers the Prices & Asset Metadata Pipeline, deployed to Crosschain, which involves Streamline, Bronze, Silver and Gold DBT models associated with various third-party price-based APIs, such as Coingecko and Coinmarketcap.
- There are three (3) general pipelines: Tokens, Native, Provider
- Tokens: Assets with token addresses
- This pipeline serves the
ez_asset_metadata
andez_prices_hourly
views -
token_address
is a crucial column for joining prices into other tables for USD pricing and other analysis
- This pipeline serves the
- Native: Assets that are Native to the respective blockchain, such as ETH, POL, BNB, SOL etc.
- Managed manually via the
silver__native_assets_seed.csv
seed file - This pipeline is unioned into
ez_asset_metadata
andez_prices_hourly
, with theis_native
column to differentiate between native assets and token assets
- Managed manually via the
- Provider: Raw, non-transformed, non-imputed prices and asset metadata directly from the APIs
- Includes QUALIFY filter(s) to ensure uniqueness
- This pipeline serves the
dim_asset_metadata
andfact_prices_ohlc_hourly
views
- Tokens: Assets with token addresses
- Raw prices and asset metadata are built using third-party price APIs: Coingecko and Coinmarketcap
- These are external APIs and we do not have control over the outputs, uptime or integrity of the data. We build the pipeline in a way that mitigates outages, missing or incorrect data.
-
Bronze Layer
- x
-
Silver Layer
- x
-
Gold Layer
- x
- crosschain.bronze.x
- crosschain.bronze.x
- crosschain.bronze.x
- crosschain.silver.x
- crosschain.silver.x
- crosschain.silver.x
- crosschain.price.x
- crosschain.price.x
This guide covers how to build and deploy all tables and views associated with the Prices & Asset Metadata pipeline, in each respective Blockchain's repository, primarily with references to the Bronze, Silver and Gold fsc_evm price macros.
Please reference the Prices & Asset Metadata Pipeline
section above for more information regarding how the pipeline was established, and how each underlying model is intended to function.
- Use the crosschain.price.dim/fact tables to research which blockchains, platforms and symbols should be included in each respective chain's set up. Because this data is primarily sourced from third-party APIs, we do not have control over the names/symbols and therefore, data may be labeled incorrectly or in a misleading/incomplete fashion.
- Some blockchains, such as Kaia or Polygon, may require multiple blockchains, platforms, symbols or
token_address
filters for thecomplete_token_prices/asset_metadata
tables. See theprices
macros documentation for more information on how to handle.
- Some blockchains, such as Kaia or Polygon, may require multiple blockchains, platforms, symbols or
-
Bronze Schema
- Each
bronze
model should be materialized as aview
. No other model-level configuration parameters are necessary.
{{ config ( materialized = 'view' ) }}
- Add the following
bronze
schema models (bronze__<table_name>
). Please reference fsc_evm price macros for details.-
bronze__complete_native_asset_metadata.sql
: Asset metadata associated with a specific blockchain(s) Native Asset(s) and the applicable symbol(s). -
bronze__complete_native_prices.sql
: Prices associated with a specific blockchain(s) Native Asset(s) and the applicable symbol(s). -
bronze__complete_provider_asset_metadata.sql
: Raw asset metadata for a specific platform(s), non-transformed and sourced directly from third-party price providers such as Coingecko and Coinmarketcap. -
bronze__complete_provider_prices.sql
: Raw open, high, low, close prices for all platforms, non-transformed and sourced directly from third-party price providers such as Coingecko and Coinmarketcap. This view will be joined withbronze__complete_provider_asset_metadata.sql
in the silver layer to enable platform specific filtering. -
bronze__complete_token_asset_metadata.sql
: Metadata for assets withtoken_address
, associated with a specific blockchain(s). -
bronze__complete_token_prices.sql
: Prices for assets withtoken_address
, associated with a specific blockchain(s).
-
- Define or update the definitions for the following variables in
dbt_project.yml
:## PRICES PRICES_SYMBOLS: 'ETH' ### REQUIRED PRICES_PLATFORMS: 'Ethereum' ### REQUIRED # PRICES_BLOCKCHAINS: ### OPTIONAL (defaults to target.database (excluding _dev) if not specified) # PRICES_TOKEN_ADDRESSES: ### OPTIONAL
- Each
-
Silver Schema
- Each
silver
model should be materialized as anincremental
table, with the following configuration parameters.
{{ config( materialized = 'incremental', incremental_strategy = 'delete+insert', unique_key = 'complete_native_asset_metadata_id', post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(asset_id, symbol, name),SUBSTRING(asset_id, symbol, name)", tags = ['non_realtime'] ) }}
- Add the following
silver
schema models (silver__<table_name>
). Please reference fsc_evm price macros for details.-
silver__complete_native_asset_metadata.sql
: Directly referencesbronze__complete_native_asset_metadata.sql
and includes incremental logic onmodified_timestamp
. -
silver__complete_native_prices.sql
: Directly referencesbronze__complete_native_prices.sql
and includes incremental logic onmodified_timestamp
. -
silver__complete_provider_asset_metadata.sql
: Directly referencesbronze__complete_provider_asset_metadata.sql
and includes incremental logic onmodified_timestamp
. -
silver__complete_provider_prices.sql
: Includes an INNER JOIN betweenbronze__complete_provider_prices.sql
andbronze__complete_provider_asset_metadata
onasset_id
to enable platform specific filtering and adds incremental logic onmodified_timestamp
. -
silver__complete_token_asset_metadata.sql
: Directly referencesbronze__complete_token_asset_metadata.sql
and includes incremental logic onmodified_timestamp
. -
silver__complete_token_prices.sql
: Directly referencesbronze__complete_token_prices.sql
and includes incremental logic onmodified_timestamp
.
-
- Add respective
.yml
files for each silver model, which includes DBT tests.
- Each
-
Gold Schema (
price
)- Each Gold
price
model should be materialized as aview
and includes thepersist_docs
param.
{{ config( materialized = 'view', persist_docs ={ "relation": true, "columns": true } ) }}
- Add the following
price
schema models (price__<table_name>
). Please reference fsc_evm price macros for details.-
price__dim_asset_metadata.sql
: Directly referencessilver__complete_provider_asset_metadata.sql
and updates column names. -
price__ez_asset_metadata.sql
: Unions all data fromsilver__complete_token_asset_metadata.sql
andsilver__complete_native_asset_metadata.sql
, adds theis_native
BOOL column and updates other column names. -
price__ez_prices_hourly.sql
: Unions all data fromsilver__complete_token_prices.sql
andsilver__complete_native_prices.sql
, adds theis_native
BOOL column and updates other column names. -
price__fact_prices_ohlc_hourly.sql
: Directly referencessilver__complete_provider_prices.sql
and updates column names.
-
- Add respective
.yml
files for each gold model, which includes table and column level descriptions.
- Each Gold