add is_verified flag AND limit to just near. Use crosschain for ez_intents

This commit is contained in:
Jack Forgash 2025-07-07 12:03:44 -06:00
parent c089b6d604
commit 8d09bd8c22
19 changed files with 74 additions and 15 deletions

View File

@ -24,3 +24,6 @@ FROM
'crosschain_silver',
'complete_native_prices'
) }}
WHERE
blockchain = 'near protocol'
AND symbol = 'NEAR'

View File

@ -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')

View File

@ -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')

View File

@ -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 %}

View File

@ -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

View File

@ -112,3 +112,6 @@ models:
- name: MODIFIED_TIMESTAMP
description: "{{ doc('modified_timestamp')}}"
- name: TOKEN_IS_VERIFIED
description: "{{ doc('token_is_verified') }}"

View File

@ -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

View File

@ -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') }}"

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -79,3 +79,6 @@ models:
description: "{{ doc('id')}}"
tests:
- not_null
- name: TOKEN_IS_VERIFIED
description: "{{ doc('token_is_verified') }}"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -18,6 +18,7 @@ SELECT
blockchain_name,
blockchain_id,
is_deprecated,
is_verified,
provider,
source,
_inserted_timestamp,

View File

@ -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,

View File

@ -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