From c3e03a1111cd24fd516d7d3316c54faeea6031a2 Mon Sep 17 00:00:00 2001 From: Austin <93135983+austinFlipside@users.noreply.github.com> Date: Tue, 15 Jul 2025 18:38:33 -0400 Subject: [PATCH] new assets (#367) --- ...ilver_bridge__complete_bridge_activity.sql | 47 +++++++++++++++ .../dex/silver_dex__complete_dex_swaps.sql | 59 +++++++++++++++++++ packages.yml | 2 +- 3 files changed, 107 insertions(+), 1 deletion(-) diff --git a/models/silver/defi/bridge/silver_bridge__complete_bridge_activity.sql b/models/silver/defi/bridge/silver_bridge__complete_bridge_activity.sql index 2f40646d..94097f99 100644 --- a/models/silver/defi/bridge/silver_bridge__complete_bridge_activity.sql +++ b/models/silver/defi/bridge/silver_bridge__complete_bridge_activity.sql @@ -1,4 +1,5 @@ -- depends_on: {{ ref('silver__complete_token_prices') }} +-- depends_on: {{ ref('price__ez_asset_metadata') }} {{ config( materialized = 'incremental', incremental_strategy = 'delete+insert', @@ -980,6 +981,47 @@ heal_model AS ( GROUP BY 1 ) + newly_verified_tokens as ( + select token_address + from {{ ref('price__ez_asset_metadata') }} + where ifnull(is_verified_modified_timestamp, '1970-01-01' :: TIMESTAMP) > dateadd('day', -10, SYSDATE()) + ), + heal_newly_verified_tokens as ( + SELECT + t0.block_number, + t0.block_timestamp, + t0.origin_from_address, + t0.origin_to_address, + t0.origin_function_signature, + t0.tx_hash, + t0.event_index, + t0.bridge_address, + t0.event_name, + t0.platform, + t0.version, + t0.sender, + t0.receiver, + t0.destination_chain_receiver, + t0.destination_chain_id, + t0.destination_chain, + t0.token_address, + t0.token_symbol, + t0.token_decimals, + t0.amount_unadj, + t0.amount, + CASE + WHEN t0.token_decimals IS NOT NULL THEN t0.amount * p.price + ELSE NULL + END AS amount_usd_heal, + p.is_verified AS token_is_verified, + t0._id, + t0._inserted_timestamp + from {{ this }} t0 + join newly_verified_tokens nv + on t0.token_address = nv.token_address + left join {{ ref('price__ez_prices_hourly')}} p + on t0.token_address = p.token_address + and date_trunc('hour', t0.block_timestamp) = p.hour ), {% endif %} @@ -1021,6 +1063,11 @@ SELECT _inserted_timestamp FROM heal_model +UNION ALL +SELECT + * +FROM + heal_newly_verified_tokens {% endif %} ) SELECT diff --git a/models/silver/defi/dex/silver_dex__complete_dex_swaps.sql b/models/silver/defi/dex/silver_dex__complete_dex_swaps.sql index 59c57c3d..27819a75 100644 --- a/models/silver/defi/dex/silver_dex__complete_dex_swaps.sql +++ b/models/silver/defi/dex/silver_dex__complete_dex_swaps.sql @@ -1,4 +1,5 @@ -- depends_on: {{ ref('silver__complete_token_prices') }} +-- depends_on: {{ ref('price__ez_asset_metadata') }} {{ config( materialized = 'incremental', incremental_strategy = 'delete+insert', @@ -995,6 +996,59 @@ heal_model AS ( GROUP BY 1 ) + ), newly_verified_tokens as ( + select token_address + from {{ ref('price__ez_asset_metadata') }} + where ifnull(is_verified_modified_timestamp, '1970-01-01' :: TIMESTAMP) > dateadd('day', -10, SYSDATE()) + ), + heal_newly_verified_tokens as ( + select + t0.block_number, + t0.block_timestamp, + t0.tx_hash, + t0.origin_function_signature, + t0.origin_from_address, + t0.origin_to_address, + t0.contract_address, + t0.event_name, + t0.token_in, + p1.is_verified AS token_in_is_verified, + t0.decimals_in, + t0.symbol_in, + t0.amount_in_unadj, + t0.amount_in, + CASE + WHEN decimals_in IS NOT NULL THEN amount_in * p1.price + ELSE NULL + END AS amount_in_usd_heal, + token_out, + p2.is_verified AS token_out_is_verified, + t0.decimals_out, + t0.symbol_out, + t0.amount_out_unadj, + t0.amount_out, + CASE + WHEN decimals_out IS NOT NULL THEN amount_out * p2.price + ELSE NULL + END AS amount_out_usd_heal, + t0.pool_name, + t0.sender, + t0.tx_to, + t0.event_index, + t0.platform, + t0.protocol, + t0.version, + t0._log_id, + t0._inserted_timestamp + from {{ this }} t0 + join newly_verified_tokens nv + on (t0.token_in = nv.token_address or t0.token_out = nv.token_address) + left join {{ ref('price__ez_prices_hourly')}} p1 + on t0.token_in = p1.token_address + and date_trunc('hour', t0.block_timestamp) = p1.hour + left join {{ ref('price__ez_prices_hourly')}} p2 + on t0.token_out = p2.token_address + and date_trunc('hour', t0.block_timestamp) = p2.hour ), {% endif %} @@ -1042,6 +1096,11 @@ SELECT _inserted_timestamp FROM heal_model +UNION ALL +SELECT + * +FROM + heal_newly_verified_tokens {% endif %} ) SELECT diff --git a/packages.yml b/packages.yml index 06db1f38..4da60721 100644 --- a/packages.yml +++ b/packages.yml @@ -1,3 +1,3 @@ packages: - git: https://github.com/FlipsideCrypto/fsc-evm.git - revision: v4.6.0 \ No newline at end of file + revision: v4.8.0 \ No newline at end of file