diff --git a/models/defillama/bronze/bronze__defillama_chainlist.sql b/models/defillama/bronze/bronze__defillama_chainlist.sql new file mode 100644 index 0000000..ea18480 --- /dev/null +++ b/models/defillama/bronze/bronze__defillama_chainlist.sql @@ -0,0 +1,66 @@ +{{ config( + materialized = 'incremental', + incremental_strategy = 'delete+insert', + unique_key = 'chain_id', + tags = ['defillama'] +) }} + +WITH chainlist_base AS ( + + SELECT + ethereum.streamline.udf_api( + 'GET', + 'https://chainid.network/chains.json',{},{} + ) AS READ, + SYSDATE() AS _inserted_timestamp +), +FINAL AS ( + SELECT + VALUE :name :: STRING AS chain, + VALUE :chain :: STRING AS chain_symbol, + VALUE :icon :: STRING AS icon, + VALUE :rpc AS rpc, + VALUE :faucets AS faucets, + VALUE :nativeCurrency AS native_currency_obj, + native_currency_obj :name :: STRING AS token_name, + TRY_TO_NUMBER( + native_currency_obj :decimals :: STRING + ) AS token_decimals, + native_currency_obj :symbol :: STRING AS token_symbol, + VALUE :infoURL :: STRING AS info_url, + VALUE :shortName :: STRING AS short_name, + VALUE :chainId :: STRING AS chain_id, + VALUE :networkId :: STRING AS network_id, + VALUE :explorers AS explorers, + _inserted_timestamp + FROM + chainlist_base, + LATERAL FLATTEN (input => READ :data) + +{% if is_incremental() %} +WHERE + chain_id NOT IN ( + SELECT + DISTINCT chain_id + FROM + {{ this }} + ) +{% endif %} +) +SELECT + chain, + chain_symbol, + token_name, + token_decimals, + token_symbol, + chain_id, + network_id, + icon, + rpc, + faucets, + info_url, + short_name, + explorers, + _inserted_timestamp +FROM + FINAL diff --git a/models/defillama/bronze/bronze__defillama_chainlist.yml b/models/defillama/bronze/bronze__defillama_chainlist.yml new file mode 100644 index 0000000..aa9d859 --- /dev/null +++ b/models/defillama/bronze/bronze__defillama_chainlist.yml @@ -0,0 +1,22 @@ +version: 2 +models: + - name: bronze__defillama_chainlist + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - CHAIN_ID + + columns: + - name: CHAIN_ID + tests: + - not_null + - name: CHAIN + tests: + - not_null + - name: TOKEN_SYMBOL + - name: _INSERTED_TIMESTAMP + tests: + - not_null + - dbt_expectations.expect_column_values_to_be_in_type_list: + column_type_list: + - TIMESTAMP_NTZ diff --git a/models/defillama/gold/defillama__dim_chains.sql b/models/defillama/gold/defillama__dim_chains.sql index 5b8fee6..9f6a17e 100644 --- a/models/defillama/gold/defillama__dim_chains.sql +++ b/models/defillama/gold/defillama__dim_chains.sql @@ -13,7 +13,17 @@ ) }} SELECT - chain_id, chain, - token_symbol -FROM {{ ref('bronze__defillama_chains') }} \ No newline at end of file + chain_symbol, + token_name, + token_decimals, + token_symbol, + chain_id, + network_id, + rpc, + faucets, + info_url, + short_name, + explorers +FROM + {{ ref('bronze__defillama_chainlist') }} \ No newline at end of file diff --git a/models/defillama/gold/defillama__dim_chains.yml b/models/defillama/gold/defillama__dim_chains.yml index c29725f..2010401 100644 --- a/models/defillama/gold/defillama__dim_chains.yml +++ b/models/defillama/gold/defillama__dim_chains.yml @@ -2,11 +2,28 @@ version: 2 models: - name: defillama__dim_chains description: This table contains dimensional information about the blockchains and networks listed on Defillama. - columns: - name: CHAIN_ID description: Unique identifier of the chain. - name: CHAIN description: Name of the blockchain. - name: TOKEN_SYMBOL - description: Symbol for the primary token of the chain. \ No newline at end of file + description: Symbol for the native token of the chain. + - name: CHAIN_SYMBOL + description: The official abbreviation or symbol representing the blockchain. + - name: TOKEN_NAME + description: The full name of the native token used on the blockchain. + - name: TOKEN_DECIMALS + description: The number of decimals used by the native token, dictating its smallest divisible unit. + - name: NETWORK_ID + description: Identifier that distinguishes between multiple networks within a single blockchain (e.g., Mainnet vs Testnet). + - name: RPC + description: URL of the primary RPC endpoint used to interact with the blockchain. + - name: FAUCETS + description: List or URLs of faucets available for obtaining test tokens on the chain's testnets. + - name: INFO_URL + description: URL to an official or authoritative information source about the blockchain. + - name: SHORT_NAME + description: A shorter or abbreviated version of the blockchain's name, used in contexts with limited space. + - name: EXPLORERS + description: List of URLs or platforms where transactions, blocks, and other chain activities can be explored and verified.