From 8d09bd8c220ab4836276df6852a4d67ec6d015b2 Mon Sep 17 00:00:00 2001 From: Jack Forgash <58153492+forgxyz@users.noreply.github.com> Date: Mon, 7 Jul 2025 12:03:44 -0600 Subject: [PATCH] add is_verified flag AND limit to just near. Use crosschain for ez_intents --- .../bronze/prices/bronze__complete_native_prices.sql | 3 +++ .../prices/bronze__complete_token_asset_metadata.sql | 8 +++----- models/bronze/prices/bronze__complete_token_prices.sql | 3 +++ models/descriptions/token_is_verified.md | 3 +++ models/gold/defi/defi__ez_bridge_activity.sql | 10 +++++++--- models/gold/defi/defi__ez_bridge_activity.yml | 3 +++ models/gold/defi/defi__ez_dex_swaps.sql | 9 +++++++-- models/gold/defi/defi__ez_dex_swaps.yml | 6 ++++++ models/gold/defi/defi__ez_intents.sql | 10 +++++++--- models/gold/defi/defi__ez_intents.yml | 7 +++++++ models/gold/defi/defi__ez_lending.sql | 7 +++++-- models/gold/defi/defi__ez_lending.yml | 3 +++ models/gold/price/price__ez_asset_metadata.sql | 2 ++ models/gold/price/price__ez_asset_metadata.yml | 2 ++ models/gold/price/price__ez_prices_hourly.sql | 2 ++ models/gold/price/price__ez_prices_hourly.yml | 2 ++ .../prices/silver__complete_token_asset_metadata.sql | 1 + models/silver/prices/silver__complete_token_prices.sql | 2 ++ models/sources.yml | 6 ++++++ 19 files changed, 74 insertions(+), 15 deletions(-) create mode 100644 models/descriptions/token_is_verified.md diff --git a/models/bronze/prices/bronze__complete_native_prices.sql b/models/bronze/prices/bronze__complete_native_prices.sql index 2a5d43e..adcd940 100644 --- a/models/bronze/prices/bronze__complete_native_prices.sql +++ b/models/bronze/prices/bronze__complete_native_prices.sql @@ -24,3 +24,6 @@ FROM 'crosschain_silver', 'complete_native_prices' ) }} +WHERE + blockchain = 'near protocol' + AND symbol = 'NEAR' diff --git a/models/bronze/prices/bronze__complete_token_asset_metadata.sql b/models/bronze/prices/bronze__complete_token_asset_metadata.sql index 7bd8f12..9ef3a0f 100644 --- a/models/bronze/prices/bronze__complete_token_asset_metadata.sql +++ b/models/bronze/prices/bronze__complete_token_asset_metadata.sql @@ -12,6 +12,7 @@ SELECT blockchain_name, blockchain_id, is_deprecated, + is_verified, provider, source, _inserted_timestamp, @@ -24,8 +25,5 @@ FROM 'crosschain_silver', 'complete_token_asset_metadata' ) }} --- WHERE --- blockchain IN ( --- 'near', --- 'near protocol' --- ) +WHERE + lower(blockchain) IN ('near', 'near protocol') diff --git a/models/bronze/prices/bronze__complete_token_prices.sql b/models/bronze/prices/bronze__complete_token_prices.sql index 7260f7b..f226767 100644 --- a/models/bronze/prices/bronze__complete_token_prices.sql +++ b/models/bronze/prices/bronze__complete_token_prices.sql @@ -15,6 +15,7 @@ SELECT blockchain_id, is_imputed, is_deprecated, + is_verified, provider, source, _inserted_timestamp, @@ -27,3 +28,5 @@ FROM 'crosschain_silver', 'complete_token_prices' ) }} +WHERE + lower(blockchain) IN ('near', 'near protocol') diff --git a/models/descriptions/token_is_verified.md b/models/descriptions/token_is_verified.md new file mode 100644 index 0000000..966fadb --- /dev/null +++ b/models/descriptions/token_is_verified.md @@ -0,0 +1,3 @@ +{% docs token_is_verified %} +Boolean flag indicating whether the token or price record is verified by Flipside's crosschain curation process. Verified tokens are prioritized for analytics and are considered reliable for most use cases. Unverified tokens may be incomplete, deprecated, or experimental. +{% enddocs %} \ No newline at end of file diff --git a/models/gold/defi/defi__ez_bridge_activity.sql b/models/gold/defi/defi__ez_bridge_activity.sql index 51b2384..4529f13 100644 --- a/models/gold/defi/defi__ez_bridge_activity.sql +++ b/models/gold/defi/defi__ez_bridge_activity.sql @@ -46,7 +46,8 @@ prices AS ( ) AS block_timestamp, token_address AS contract_address, AVG(price) AS price_usd, - MAX(SYMBOL) AS symbol + MAX(symbol) AS symbol, + MAX(is_verified) AS token_is_verified FROM {{ ref('silver__complete_token_prices') }} GROUP BY @@ -65,7 +66,8 @@ prices_mapping AS ( ELSE contract_address END AS contract_address, symbol, - price_usd + price_usd, + token_is_verified FROM prices ), @@ -83,6 +85,7 @@ FINAL AS ( l1.decimals ) AS amount, amount * p1.price_usd AS amount_usd, + p1.token_is_verified AS token_is_verified, b.destination_address, b.source_address, b.platform, @@ -105,6 +108,7 @@ FINAL AS ( AND DATE_TRUNC('hour', b.block_timestamp) = p1.block_timestamp ) SELECT - * + *, + COALESCE(token_is_verified, FALSE) AS token_is_verified FROM FINAL diff --git a/models/gold/defi/defi__ez_bridge_activity.yml b/models/gold/defi/defi__ez_bridge_activity.yml index a92dc6f..9fa302c 100644 --- a/models/gold/defi/defi__ez_bridge_activity.yml +++ b/models/gold/defi/defi__ez_bridge_activity.yml @@ -112,3 +112,6 @@ models: - name: MODIFIED_TIMESTAMP description: "{{ doc('modified_timestamp')}}" + + - name: TOKEN_IS_VERIFIED + description: "{{ doc('token_is_verified') }}" diff --git a/models/gold/defi/defi__ez_dex_swaps.sql b/models/gold/defi/defi__ez_dex_swaps.sql index 66262f6..55293dd 100644 --- a/models/gold/defi/defi__ez_dex_swaps.sql +++ b/models/gold/defi/defi__ez_dex_swaps.sql @@ -43,7 +43,8 @@ prices AS ( hour ) AS block_timestamp, token_address AS contract_address, - AVG(price) AS price_usd + AVG(price) AS price_usd, + MAX(is_verified) AS token_is_verified FROM {{ ref('silver__complete_token_prices') }} GROUP BY @@ -68,6 +69,7 @@ FINAL AS ( amount_out * p1.price_usd AS amount_out_usd, s.token_out AS token_out_contract, l1.symbol AS symbol_out, + p1.token_is_verified AS token_out_is_verified, s.amount_in_raw, s.amount_in_raw / pow( 10, @@ -76,6 +78,7 @@ FINAL AS ( amount_in * p2.price_usd AS amount_in_usd, s.token_in AS token_in_contract, l2.symbol AS symbol_in, + p2.token_is_verified AS token_in_is_verified, s.swap_input_data, s.log, s.ez_dex_swaps_id, @@ -101,6 +104,8 @@ FINAL AS ( AND s.token_in = p2.contract_address ) SELECT - * + *, + COALESCE(token_in_is_verified, FALSE) AS token_in_is_verified, + COALESCE(token_out_is_verified, FALSE) AS token_out_is_verified FROM FINAL diff --git a/models/gold/defi/defi__ez_dex_swaps.yml b/models/gold/defi/defi__ez_dex_swaps.yml index 7c66c7f..1876ec8 100644 --- a/models/gold/defi/defi__ez_dex_swaps.yml +++ b/models/gold/defi/defi__ez_dex_swaps.yml @@ -93,3 +93,9 @@ models: - name: MODIFIED_TIMESTAMP description: "{{doc('modified_timestamp')}}" + + - name: TOKEN_OUT_IS_VERIFIED + description: "{{ doc('token_is_verified') }}" + + - name: TOKEN_IN_IS_VERIFIED + description: "{{ doc('token_is_verified') }}" diff --git a/models/gold/defi/defi__ez_intents.sql b/models/gold/defi/defi__ez_intents.sql index 0ac349d..e4473ad 100644 --- a/models/gold/defi/defi__ez_intents.sql +++ b/models/gold/defi/defi__ez_intents.sql @@ -138,9 +138,10 @@ prices AS ( symbol, price, is_native, + is_verified, HOUR FROM - {{ ref('price__ez_prices_hourly') }} + {{ source('crosschain_price', 'ez_prices_hourly') }} WHERE NOT is_native @@ -162,9 +163,10 @@ prices_native AS ( symbol, price, is_native, + is_verified, HOUR FROM - {{ ref('price__ez_prices_hourly') }} + {{ source('crosschain_price', 'ez_prices_hourly') }} WHERE is_native @@ -220,7 +222,8 @@ FINAL AS ( COALESCE(p.price, 1), COALESCE(p.price, p2.price) ) - ) AS amount_usd + ) AS amount_usd, + COALESCE(p.is_verified, p2.is_verified, FALSE) AS token_is_verified FROM intents i LEFT JOIN labels l @@ -268,6 +271,7 @@ SELECT log_event_index, amount_index, receipt_succeeded, + token_is_verified, ez_intents_id, SYSDATE() AS inserted_timestamp, SYSDATE() AS modified_timestamp diff --git a/models/gold/defi/defi__ez_intents.yml b/models/gold/defi/defi__ez_intents.yml index 80982a6..f04b55f 100644 --- a/models/gold/defi/defi__ez_intents.yml +++ b/models/gold/defi/defi__ez_intents.yml @@ -154,6 +154,13 @@ models: - NUMBER - FLOAT + - name: TOKEN_IS_VERIFIED + description: "{{ doc('token_is_verified') }}" + tests: + - dbt_expectations.expect_column_values_to_be_in_type_list: + column_type_list: + - BOOLEAN + - name: EZ_INTENTS_ID description: "{{ doc('id') }}" tests: diff --git a/models/gold/defi/defi__ez_lending.sql b/models/gold/defi/defi__ez_lending.sql index e56154e..af2a439 100644 --- a/models/gold/defi/defi__ez_lending.sql +++ b/models/gold/defi/defi__ez_lending.sql @@ -55,7 +55,8 @@ prices AS ( HOUR ) AS block_timestamp, token_address AS contract_address, - AVG(price) AS price_usd + AVG(price) AS price_usd, + MAX(is_verified) AS token_is_verified FROM {{ ref('silver__complete_token_prices') }} GROUP BY @@ -81,6 +82,7 @@ FINAL AS ( lb.decimals ) AS amount, p.price_usd, + p.token_is_verified AS token_is_verified, amount * p.price_usd AS amount_usd, l.ez_lending_id, l.inserted_timestamp, @@ -97,6 +99,7 @@ FINAL AS ( AND l.token_address = p.contract_address ) SELECT - * + *, + COALESCE(token_is_verified, FALSE) AS token_is_verified FROM FINAL diff --git a/models/gold/defi/defi__ez_lending.yml b/models/gold/defi/defi__ez_lending.yml index fbbb056..c7f1f49 100644 --- a/models/gold/defi/defi__ez_lending.yml +++ b/models/gold/defi/defi__ez_lending.yml @@ -79,3 +79,6 @@ models: description: "{{ doc('id')}}" tests: - not_null + + - name: TOKEN_IS_VERIFIED + description: "{{ doc('token_is_verified') }}" diff --git a/models/gold/price/price__ez_asset_metadata.sql b/models/gold/price/price__ez_asset_metadata.sql index 241e286..db8b49f 100644 --- a/models/gold/price/price__ez_asset_metadata.sql +++ b/models/gold/price/price__ez_asset_metadata.sql @@ -14,6 +14,7 @@ SELECT blockchain, FALSE AS is_native, is_deprecated, + COALESCE(is_verified, FALSE) AS token_is_verified, inserted_timestamp, modified_timestamp, complete_token_asset_metadata_id AS ez_asset_metadata_id @@ -29,6 +30,7 @@ SELECT blockchain, is_deprecated, TRUE AS is_native, + FALSE AS token_is_verified, inserted_timestamp, modified_timestamp, complete_native_asset_metadata_id AS ez_asset_metadata_id diff --git a/models/gold/price/price__ez_asset_metadata.yml b/models/gold/price/price__ez_asset_metadata.yml index fd4db59..b09243a 100644 --- a/models/gold/price/price__ez_asset_metadata.yml +++ b/models/gold/price/price__ez_asset_metadata.yml @@ -18,6 +18,8 @@ models: description: '{{ doc("prices_decimals") }}' - name: IS_NATIVE description: '{{ doc("prices_is_native") }}' + - name: TOKEN_IS_VERIFIED + description: "{{ doc('token_is_verified') }}" - name: IS_DEPRECATED description: '{{ doc("prices_is_deprecated") }}' - name: EZ_ASSET_METADATA_ID diff --git a/models/gold/price/price__ez_prices_hourly.sql b/models/gold/price/price__ez_prices_hourly.sql index d4aaef7..4075b45 100644 --- a/models/gold/price/price__ez_prices_hourly.sql +++ b/models/gold/price/price__ez_prices_hourly.sql @@ -16,6 +16,7 @@ SELECT FALSE AS is_native, is_deprecated, is_imputed, + COALESCE(is_verified, FALSE) AS token_is_verified, inserted_timestamp, modified_timestamp, complete_token_prices_id AS ez_prices_hourly_id @@ -33,6 +34,7 @@ SELECT TRUE AS is_native, is_deprecated, is_imputed, + TRUE AS token_is_verified, inserted_timestamp, modified_timestamp, complete_native_prices_id AS ez_prices_hourly_id diff --git a/models/gold/price/price__ez_prices_hourly.yml b/models/gold/price/price__ez_prices_hourly.yml index 6f99a86..ab8098d 100644 --- a/models/gold/price/price__ez_prices_hourly.yml +++ b/models/gold/price/price__ez_prices_hourly.yml @@ -20,6 +20,8 @@ models: description: '{{ doc("prices_is_native") }}' - name: IS_IMPUTED description: '{{ doc("prices_is_imputed") }}' + - name: TOKEN_IS_VERIFIED + description: "{{ doc('token_is_verified') }}" - name: IS_DEPRECATED description: '{{ doc("prices_is_deprecated") }}' - name: EZ_PRICES_HOURLY_ID diff --git a/models/silver/prices/silver__complete_token_asset_metadata.sql b/models/silver/prices/silver__complete_token_asset_metadata.sql index 82ee3a1..7797670 100644 --- a/models/silver/prices/silver__complete_token_asset_metadata.sql +++ b/models/silver/prices/silver__complete_token_asset_metadata.sql @@ -18,6 +18,7 @@ SELECT blockchain_name, blockchain_id, is_deprecated, + is_verified, provider, source, _inserted_timestamp, diff --git a/models/silver/prices/silver__complete_token_prices.sql b/models/silver/prices/silver__complete_token_prices.sql index b845710..da4df74 100644 --- a/models/silver/prices/silver__complete_token_prices.sql +++ b/models/silver/prices/silver__complete_token_prices.sql @@ -24,6 +24,7 @@ WITH complete_token_prices AS ( blockchain_id, is_imputed, is_deprecated, + is_verified, provider, source, _inserted_timestamp, @@ -73,6 +74,7 @@ SELECT blockchain_id, is_imputed, is_deprecated, + is_verified, provider, source, p._inserted_timestamp, diff --git a/models/sources.yml b/models/sources.yml index 12dc903..8af652b 100644 --- a/models/sources.yml +++ b/models/sources.yml @@ -21,6 +21,12 @@ sources: - name: complete_native_asset_metadata - name: complete_native_prices + - name: crosschain_price + database: crosschain + schema: price + tables: + - name: ez_prices_hourly + - name: streamline database: streamline schema: near_lake