mirror of
https://github.com/FlipsideCrypto/external-models.git
synced 2026-02-06 13:57:17 +00:00
add/chainlist (#41)
This commit is contained in:
parent
71fd6d78da
commit
58b610e3f6
66
models/defillama/bronze/bronze__defillama_chainlist.sql
Normal file
66
models/defillama/bronze/bronze__defillama_chainlist.sql
Normal file
@ -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
|
||||
22
models/defillama/bronze/bronze__defillama_chainlist.yml
Normal file
22
models/defillama/bronze/bronze__defillama_chainlist.yml
Normal file
@ -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
|
||||
@ -13,7 +13,17 @@
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
chain_id,
|
||||
chain,
|
||||
token_symbol
|
||||
FROM {{ ref('bronze__defillama_chains') }}
|
||||
chain_symbol,
|
||||
token_name,
|
||||
token_decimals,
|
||||
token_symbol,
|
||||
chain_id,
|
||||
network_id,
|
||||
rpc,
|
||||
faucets,
|
||||
info_url,
|
||||
short_name,
|
||||
explorers
|
||||
FROM
|
||||
{{ ref('bronze__defillama_chainlist') }}
|
||||
@ -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.
|
||||
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.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user