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_metadataandez_prices_hourlyviews -
token_addressis 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.csvseed file - This pipeline is unioned into
ez_asset_metadataandez_prices_hourly, with theis_nativecolumn 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_metadataandfact_prices_ohlc_hourlyviews
- 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.
- 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_addressfilters for thecomplete_token_prices/asset_metadatatables. See thepricesmacros 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
bronzemodel should be materialized as aview. No other model-level configuration parameters are necessary.
{{ config ( materialized = 'view', tags = ['bronze','prices','native','phase_3'] ) }}- Add the following
bronzeschema 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.sqlin 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).
-
- Each
-
Silver Schema
- Each
silvermodel should be materialized as anincrementaltable, with the following configuration parameters.
{{ config( materialized = 'incremental', incremental_strategy = 'delete+insert', unique_key = 'complete_native_asset_metadata_id', tags = ['silver','prices','native','phase_3'] ) }}- Add the following
silverschema models (silver__<table_name>).-
silver__complete_native_asset_metadata.sql: Directly referencesbronze__complete_native_asset_metadata.sqland includes incremental logic onmodified_timestamp. -
silver__complete_native_prices.sql: Directly referencesbronze__complete_native_prices.sqland includes incremental logic onmodified_timestamp. -
silver__complete_provider_asset_metadata.sql: Directly referencesbronze__complete_provider_asset_metadata.sqland includes incremental logic onmodified_timestamp. -
silver__complete_provider_prices.sql: Includes an INNER JOIN betweenbronze__complete_provider_prices.sqlandbronze__complete_provider_asset_metadataonasset_idto enable platform specific filtering and adds incremental logic onmodified_timestamp. -
silver__complete_token_asset_metadata.sql: Directly referencesbronze__complete_token_asset_metadata.sqland includes incremental logic onmodified_timestamp. -
silver__complete_token_prices.sql: Directly referencesbronze__complete_token_prices.sqland includes incremental logic onmodified_timestamp.
-
- Add respective
.ymlfiles for each silver model, which includes DBT tests.
- Each
-
Gold Schema (
price)- Each Gold
pricemodel should be materialized as aviewand includes thepersist_docsparam.
{{ config( materialized = 'incremental', incremental_strategy = 'delete+insert', unique_key = 'dim_asset_metadata_id', post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(asset_id, token_address, symbol, name),SUBSTRING(asset_id, token_address, symbol, name)", tags = ['gold','prices','phase_3'] ) }}- Add the following
priceschema models (price__<table_name>).-
price__dim_asset_metadata.sql: Directly referencessilver__complete_provider_asset_metadata.sqland updates column names. -
price__ez_asset_metadata.sql: Unions all data fromsilver__complete_token_asset_metadata.sqlandsilver__complete_native_asset_metadata.sql, adds theis_nativeBOOL column and updates other column names. -
price__ez_prices_hourly.sql: Unions all data fromsilver__complete_token_prices.sqlandsilver__complete_native_prices.sql, adds theis_nativeBOOL column and updates other column names. -
price__fact_prices_ohlc_hourly.sql: Directly referencessilver__complete_provider_prices.sqland updates column names.
-
- Add respective
.ymlfiles for each gold model, which includes table and column level descriptions.
- Each Gold