mirror of
https://github.com/FlipsideCrypto/arbitrum-models.git
synced 2026-02-06 18:01:52 +00:00
add/shares-ref-usage (#49)
* added models for shares references * adds lookback
This commit is contained in:
parent
f58146564e
commit
fd8199cea8
22
models/bronze/labels/bronze__labels.sql
Normal file
22
models/bronze/labels/bronze__labels.sql
Normal file
@ -0,0 +1,22 @@
|
||||
{{ config(
|
||||
materialized = 'view'
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
system_created_at,
|
||||
insert_date,
|
||||
blockchain,
|
||||
address,
|
||||
creator,
|
||||
label_type,
|
||||
label_subtype,
|
||||
address_name,
|
||||
project_name
|
||||
FROM
|
||||
{{ source(
|
||||
'crosschain',
|
||||
'address_labels'
|
||||
) }}
|
||||
WHERE
|
||||
blockchain = 'arbitrum'
|
||||
AND address LIKE '0x%'
|
||||
17
models/bronze/prices/bronze__asset_metadata.sql
Normal file
17
models/bronze/prices/bronze__asset_metadata.sql
Normal file
@ -0,0 +1,17 @@
|
||||
{{ config (
|
||||
materialized = 'view'
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
token_address,
|
||||
symbol,
|
||||
provider,
|
||||
id,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
{{ source(
|
||||
'crosschain_silver',
|
||||
'asset_metadata_priority'
|
||||
) }}
|
||||
WHERE
|
||||
blockchain = 'arbitrum'
|
||||
17
models/bronze/prices/bronze__hourly_prices.sql
Normal file
17
models/bronze/prices/bronze__hourly_prices.sql
Normal file
@ -0,0 +1,17 @@
|
||||
{{ config (
|
||||
materialized = 'view'
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
HOUR,
|
||||
token_address,
|
||||
price,
|
||||
is_imputed,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
{{ source(
|
||||
'crosschain_silver',
|
||||
'token_prices_priority_hourly'
|
||||
) }}
|
||||
WHERE
|
||||
blockchain = 'arbitrum'
|
||||
18
models/bronze/prices/bronze__hourly_prices_eth.sql
Normal file
18
models/bronze/prices/bronze__hourly_prices_eth.sql
Normal file
@ -0,0 +1,18 @@
|
||||
{{ config (
|
||||
materialized = 'view'
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
HOUR,
|
||||
token_address,
|
||||
price,
|
||||
is_imputed,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
{{ source(
|
||||
'crosschain_silver',
|
||||
'token_prices_priority_hourly'
|
||||
) }}
|
||||
WHERE
|
||||
blockchain = 'ethereum'
|
||||
AND token_address = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
|
||||
@ -13,10 +13,4 @@ SELECT
|
||||
label_subtype,
|
||||
project_name
|
||||
FROM
|
||||
{{ source(
|
||||
'crosschain_silver',
|
||||
'address_labels'
|
||||
) }}
|
||||
WHERE
|
||||
blockchain = 'arbitrum'
|
||||
AND address LIKE '0x%'
|
||||
{{ ref('silver__labels') }}
|
||||
|
||||
@ -26,12 +26,7 @@ eth_price AS (
|
||||
HOUR,
|
||||
price AS eth_price
|
||||
FROM
|
||||
{{ source(
|
||||
'ethereum',
|
||||
'fact_hourly_token_prices'
|
||||
) }}
|
||||
WHERE
|
||||
token_address = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
|
||||
{{ ref('silver__prices_eth') }}
|
||||
)
|
||||
SELECT
|
||||
A.tx_hash AS tx_hash,
|
||||
|
||||
@ -12,8 +12,4 @@ SELECT
|
||||
price,
|
||||
is_imputed
|
||||
FROM
|
||||
{{ source(
|
||||
'crosschain',
|
||||
'ez_hourly_prices'
|
||||
) }}
|
||||
WHERE blockchain = 'arbitrum'
|
||||
{{ ref('silver__prices') }}
|
||||
|
||||
30
models/silver/labels/silver__labels.sql
Normal file
30
models/silver/labels/silver__labels.sql
Normal file
@ -0,0 +1,30 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
unique_key = 'address'
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
system_created_at,
|
||||
insert_date,
|
||||
blockchain,
|
||||
address,
|
||||
creator,
|
||||
label_type,
|
||||
label_subtype,
|
||||
address_name,
|
||||
project_name
|
||||
FROM
|
||||
{{ ref('bronze__labels') }}
|
||||
WHERE
|
||||
1 = 1
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND insert_date >= (
|
||||
SELECT
|
||||
MAX(
|
||||
insert_date
|
||||
)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
34
models/silver/prices/silver__asset_metadata.sql
Normal file
34
models/silver/prices/silver__asset_metadata.sql
Normal file
@ -0,0 +1,34 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
unique_key = 'token_address'
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
token_address,
|
||||
symbol,
|
||||
provider,
|
||||
id,
|
||||
CASE
|
||||
WHEN provider = 'coingecko' THEN 1
|
||||
WHEN provider = 'coinmarketcap' THEN 2
|
||||
END AS priority,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
{{ ref('bronze__asset_metadata') }}
|
||||
WHERE
|
||||
1 = 1
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
|
||||
qualify(ROW_NUMBER() over (PARTITION BY token_address
|
||||
ORDER BY
|
||||
priority ASC)) = 1
|
||||
26
models/silver/prices/silver__hourly_prices.sql
Normal file
26
models/silver/prices/silver__hourly_prices.sql
Normal file
@ -0,0 +1,26 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
unique_key = ['token_address', 'hour']
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
HOUR,
|
||||
token_address,
|
||||
price,
|
||||
is_imputed,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
{{ ref('bronze__hourly_prices') }}
|
||||
WHERE
|
||||
1 = 1
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
37
models/silver/prices/silver__prices.sql
Normal file
37
models/silver/prices/silver__prices.sql
Normal file
@ -0,0 +1,37 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
unique_key = ['token_address', 'hour']
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
p.hour,
|
||||
p.token_address,
|
||||
p.price,
|
||||
p.is_imputed,
|
||||
p._inserted_timestamp,
|
||||
COALESCE(
|
||||
C.token_symbol,
|
||||
m.symbol
|
||||
) AS symbol,
|
||||
C.token_decimals AS decimals
|
||||
FROM
|
||||
{{ ref('silver__hourly_prices') }}
|
||||
p
|
||||
LEFT JOIN {{ ref('silver__asset_metadata') }}
|
||||
m
|
||||
ON p.token_address = m.token_address
|
||||
LEFT JOIN {{ ref('silver__contracts') }} C
|
||||
ON p.token_address = C.contract_address
|
||||
WHERE
|
||||
1 = 1
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND p._inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) :: DATE - 1
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
16
models/silver/prices/silver__prices.yml
Normal file
16
models/silver/prices/silver__prices.yml
Normal file
@ -0,0 +1,16 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: silver__prices
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- TOKEN_ADDRESS
|
||||
- HOUR
|
||||
|
||||
columns:
|
||||
- name: HOUR
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 1
|
||||
26
models/silver/prices/silver__prices_eth.sql
Normal file
26
models/silver/prices/silver__prices_eth.sql
Normal file
@ -0,0 +1,26 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
unique_key = ['token_address', 'hour']
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
HOUR,
|
||||
token_address,
|
||||
price,
|
||||
is_imputed,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
{{ ref('bronze__hourly_prices_eth') }}
|
||||
WHERE
|
||||
1 = 1
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
16
models/silver/prices/silver__prices_eth.yml
Normal file
16
models/silver/prices/silver__prices_eth.yml
Normal file
@ -0,0 +1,16 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: silver__prices_eth
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- TOKEN_ADDRESS
|
||||
- HOUR
|
||||
|
||||
columns:
|
||||
- name: HOUR
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 1
|
||||
@ -44,4 +44,6 @@ sources:
|
||||
schema: silver
|
||||
tables:
|
||||
- name: apis_keys
|
||||
- name: address_labels
|
||||
- name: address_labels
|
||||
- name: token_prices_priority_hourly
|
||||
- name: asset_metadata_priority
|
||||
Loading…
Reference in New Issue
Block a user