diff --git a/models/gold/defi/defi__ez_intents.sql b/models/gold/defi/defi__ez_intents.sql index f9a7a53..31fb2dc 100644 --- a/models/gold/defi/defi__ez_intents.sql +++ b/models/gold/defi/defi__ez_intents.sql @@ -123,32 +123,38 @@ WITH intents AS ( ), labels AS ( SELECT - contract_address AS contract_address_raw, - CASE - WHEN source = 'defuse' THEN SPLIT( - omni_address, - ':' - ) [0] :: STRING - ELSE 'near' - END AS ecosystem, - CASE - WHEN source = 'defuse' THEN SPLIT( - omni_address, - ':' - ) [1] :: STRING - ELSE '397' - END AS chain_id, - CASE - WHEN source = 'defuse' THEN SPLIT( - omni_address, - ':' - ) [2] :: STRING - ELSE contract_address - END AS contract_address, + near_token_id AS contract_address_raw, + SPLIT( + defuse_asset_identifier, + ':' + ) [0] :: STRING AS ecosystem, + SPLIT( + defuse_asset_identifier, + ':' + ) [1] :: STRING AS chain_id, + SPLIT( + defuse_asset_identifier, + ':' + ) [2] :: STRING AS contract_address, asset_name AS symbol, decimals - FROM + FROM + {{ ref('silver__defuse_tokens_metadata') }} + UNION ALL + SELECT + contract_address AS contract_address_raw, + 'near' AS ecosystem, + '397' AS chain_id, + contract_address, + symbol, + decimals + FROM {{ ref('silver__ft_contract_metadata') }} + WHERE + contract_address not in ( + select distinct near_token_id + from {{ ref('silver__defuse_tokens_metadata') }} + ) ), prices AS ( SELECT @@ -271,4 +277,4 @@ FROM qualify(ROW_NUMBER() over (PARTITION BY ez_intents_id ORDER BY - price IS NOT NULL DESC, is_native DESC) = 1) + price IS NOT NULL DESC, is_native DESC) = 1) \ No newline at end of file