mirror of
https://github.com/FlipsideCrypto/crosschain-models.git
synced 2026-02-06 15:26:44 +00:00
parent
f9c286f87e
commit
94a0974229
@ -33,6 +33,7 @@ aptos,0x5ae6789dd2fec1a9ec9cccfb3acaf12e93d432f0a3a42c92fe1a9d490b7bbc06::mkl_to
|
||||
aptos,0x8d87a65ba30e09357fa2edea2c80dbac296e5dec2b18287113500b902942929d::celer_coin_manager::WethCoin,wrapped-ether-celer,,,TRUE
|
||||
aptos,0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDT,layerzero-bridged-usdt-aptos,,,TRUE
|
||||
aptos,0x50038be55be5b964cfa32cf128b5cf05f123959f286b4cc02b86cafd48945f89,blackrock-usd-institutional-digital-liquidity-fund,,,TRUE
|
||||
arbitrum,0x7751e2f4b8ae93ef6b79d86419d42fe3295a4559,lift-dollar,,,TRUE
|
||||
arbitrum,0x0c84331e39d6658cd6e6b9ba04736cc4c4734351,,,variableDebtArbWETH?,FALSE
|
||||
arbitrum,0x2bcc6d6cdbbdc0a4071e48bb3b969b06b3330c07,solana,,,
|
||||
arbitrum,0x3caae25ee616f2c8e13c74da0813402eae3f496b,camelot-token,,,TRUE
|
||||
|
||||
|
@ -0,0 +1,84 @@
|
||||
{{ config(
|
||||
materialized='incremental',
|
||||
unique_key=['blockchain', 'address'],
|
||||
on_schema_change='sync_all_columns',
|
||||
tags=['daily']
|
||||
) }}
|
||||
|
||||
WITH seed_data AS (
|
||||
SELECT
|
||||
blockchain,
|
||||
address,
|
||||
cg_id,
|
||||
cmc_id,
|
||||
invalid_reason,
|
||||
verified_override,
|
||||
HASH(
|
||||
blockchain,
|
||||
COALESCE(address, ''),
|
||||
COALESCE(cg_id, ''),
|
||||
COALESCE(cmc_id, 0),
|
||||
COALESCE(invalid_reason, ''),
|
||||
COALESCE(verified_override, FALSE)
|
||||
) as row_hash
|
||||
FROM {{ ref('silver__manual_verified_token_mapping') }}
|
||||
QUALIFY ROW_NUMBER() OVER (
|
||||
PARTITION BY blockchain, address
|
||||
ORDER BY 1
|
||||
) = 1
|
||||
)
|
||||
|
||||
{% if is_incremental() %}
|
||||
,existing_data AS (
|
||||
SELECT
|
||||
blockchain,
|
||||
address,
|
||||
row_hash,
|
||||
inserted_timestamp,
|
||||
modified_timestamp
|
||||
FROM {{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
|
||||
,final AS (
|
||||
SELECT
|
||||
s.blockchain,
|
||||
s.address,
|
||||
s.cg_id,
|
||||
s.cmc_id,
|
||||
s.invalid_reason,
|
||||
s.verified_override,
|
||||
s.row_hash,
|
||||
{% if is_incremental() %}
|
||||
COALESCE(e.inserted_timestamp, SYSDATE()) as inserted_timestamp,
|
||||
CASE
|
||||
WHEN e.blockchain IS NULL OR e.row_hash != s.row_hash
|
||||
THEN SYSDATE()
|
||||
ELSE e.modified_timestamp
|
||||
END as modified_timestamp,
|
||||
CASE
|
||||
WHEN e.blockchain IS NULL THEN 'INSERT'
|
||||
WHEN e.row_hash != s.row_hash THEN 'UPDATE'
|
||||
ELSE 'NO_CHANGE'
|
||||
END as change_type
|
||||
{% else %}
|
||||
'2020-01-01 00:00:00'::TIMESTAMP_LTZ as inserted_timestamp,
|
||||
'2020-01-01 00:00:00'::TIMESTAMP_LTZ as modified_timestamp,
|
||||
'INITIAL_LOAD' as change_type
|
||||
{% endif %}
|
||||
FROM seed_data s
|
||||
{% if is_incremental() %}
|
||||
LEFT JOIN existing_data e
|
||||
ON s.blockchain = e.blockchain
|
||||
AND COALESCE(s.address, '') = COALESCE(e.address, '')
|
||||
WHERE e.blockchain IS NULL
|
||||
OR e.row_hash != s.row_hash
|
||||
{% endif %}
|
||||
)
|
||||
|
||||
SELECT *
|
||||
FROM final
|
||||
QUALIFY ROW_NUMBER() OVER (
|
||||
PARTITION BY blockchain, address
|
||||
ORDER BY modified_timestamp DESC
|
||||
) = 1
|
||||
@ -208,7 +208,7 @@ man AS (
|
||||
cg_id,
|
||||
cmc_id
|
||||
FROM
|
||||
{{ ref('silver__manual_verified_token_mapping') }}
|
||||
{{ ref('silver__manually_verified_tokens') }}
|
||||
WHERE
|
||||
COALESCE(
|
||||
cg_id :: STRING,
|
||||
@ -228,9 +228,10 @@ man_ver AS (
|
||||
blockchain,
|
||||
address,
|
||||
LOWER(address) AS address_lower,
|
||||
verified_override
|
||||
verified_override,
|
||||
modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver__manual_verified_token_mapping') }}
|
||||
{{ ref('silver__manually_verified_tokens') }}
|
||||
WHERE
|
||||
verified_override IS NOT NULL qualify ROW_NUMBER() over(
|
||||
PARTITION BY blockchain,
|
||||
@ -269,6 +270,7 @@ WHERE
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
OR address in (select address from man_ver where modified_timestamp > (select max(modified_timestamp) from {{ this }}))
|
||||
{% endif %}
|
||||
),
|
||||
FINAL AS (
|
||||
|
||||
Loading…
Reference in New Issue
Block a user