mirror of
https://github.com/FlipsideCrypto/fsc-evm.git
synced 2026-02-06 14:06:47 +00:00
tags and uni v4 fix
This commit is contained in:
parent
dfcdc7563b
commit
1a6536c67e
@ -8,7 +8,7 @@
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'aave_v1_reads_id',
|
||||
tags = ['silver','contract_reads']
|
||||
tags = ['streamline','contract_reads','records']
|
||||
) }}
|
||||
|
||||
WITH all_tokens AS (
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'aave_v2_reads_id',
|
||||
tags = ['silver','contract_reads']
|
||||
tags = ['streamline','contract_reads','records']
|
||||
) }}
|
||||
|
||||
WITH all_tokens AS (
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'aave_v3_reads_id',
|
||||
tags = ['silver','contract_reads']
|
||||
tags = ['streamline','contract_reads','records']
|
||||
) }}
|
||||
|
||||
WITH all_tokens AS (
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'aerodrome_v1_reads_id',
|
||||
tags = ['silver','contract_reads']
|
||||
tags = ['streamline','contract_reads','records']
|
||||
) }}
|
||||
|
||||
WITH liquidity_pools AS (
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'binance_v1_reads_id',
|
||||
tags = ['silver','contract_reads']
|
||||
tags = ['streamline','contract_reads','records']
|
||||
) }}
|
||||
|
||||
WITH contracts AS (
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'compound_v1_reads_id',
|
||||
tags = ['silver','contract_reads']
|
||||
tags = ['streamline','contract_reads','records']
|
||||
) }}
|
||||
|
||||
-- Compound V1 TVL: balanceOf(MoneyMarket) for each collateral token
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'compound_v2_reads_id',
|
||||
tags = ['silver','contract_reads']
|
||||
tags = ['streamline','contract_reads','records']
|
||||
) }}
|
||||
|
||||
WITH all_tokens AS (
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'compound_v3_reads_id',
|
||||
tags = ['silver','contract_reads']
|
||||
tags = ['streamline','contract_reads','records']
|
||||
) }}
|
||||
|
||||
WITH base_tokens AS (
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'curve_reads_id',
|
||||
tags = ['silver','contract_reads']
|
||||
tags = ['streamline','contract_reads','records']
|
||||
) }}
|
||||
|
||||
WITH liquidity_pools AS (
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'eigenlayer_v1_reads_id',
|
||||
tags = ['silver','contract_reads']
|
||||
tags = ['streamline','contract_reads','records']
|
||||
) }}
|
||||
|
||||
WITH strategy_events AS (
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'etherfi_v1_reads_id',
|
||||
tags = ['silver','contract_reads']
|
||||
tags = ['streamline','contract_reads','records']
|
||||
) }}
|
||||
|
||||
WITH contracts AS (
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'lido_reads_id',
|
||||
tags = ['silver','contract_reads']
|
||||
tags = ['streamline','contract_reads','records']
|
||||
) }}
|
||||
|
||||
WITH pooled_assets AS (
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'morpho_blue_v1_reads_id',
|
||||
tags = ['silver','contract_reads']
|
||||
tags = ['streamline','contract_reads','records']
|
||||
) }}
|
||||
|
||||
WITH market_tokens AS (
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'polymarket_v1_reads_id',
|
||||
tags = ['silver','contract_reads']
|
||||
tags = ['streamline','contract_reads','records']
|
||||
) }}
|
||||
|
||||
WITH contracts AS (
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'rocketpool_v1_reads_id',
|
||||
tags = ['silver','contract_reads']
|
||||
tags = ['streamline','contract_reads','records']
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'sky_v1_collateral_joins_id',
|
||||
tags = ['silver','contract_reads','sky']
|
||||
tags = ['streamline','contract_reads','records','sky']
|
||||
) }}
|
||||
|
||||
-- Sky Protocol (MakerDAO) collateral join discovery
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'sky_v1_reads_id',
|
||||
tags = ['silver','contract_reads']
|
||||
tags = ['streamline','contract_reads','records']
|
||||
) }}
|
||||
|
||||
WITH collateral_joins AS (
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'stablecoins_reads_id',
|
||||
post_hook = '{{ unverify_stablecoins() }}',
|
||||
tags = ['silver','contract_reads','heal']
|
||||
tags = ['streamline','contract_reads','records','heal']
|
||||
) }}
|
||||
|
||||
WITH verified_stablecoins AS (
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'superchain_slipstream_v1_reads_id',
|
||||
tags = ['silver','contract_reads']
|
||||
tags = ['streamline','contract_reads','records']
|
||||
) }}
|
||||
|
||||
WITH blacklisted_tokens AS (
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'tornado_cash_reads_id',
|
||||
tags = ['silver','contract_reads']
|
||||
tags = ['streamline','contract_reads','records']
|
||||
) }}
|
||||
|
||||
WITH mixers AS (
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'uniswap_v2_reads_id',
|
||||
post_hook = '{{ unverify_contract_reads() }}',
|
||||
tags = ['silver','contract_reads','heal']
|
||||
tags = ['streamline','contract_reads','records','heal']
|
||||
) }}
|
||||
|
||||
WITH verified_contracts AS (
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'uniswap_v3_reads_id',
|
||||
post_hook = '{{ unverify_contract_reads() }}',
|
||||
tags = ['silver','contract_reads','heal']
|
||||
tags = ['streamline','contract_reads','records','heal']
|
||||
) }}
|
||||
|
||||
WITH verified_contracts AS (
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'uniswap_v4_reads_id',
|
||||
post_hook = '{{ unverify_contract_reads() }}',
|
||||
tags = ['silver','contract_reads','heal']
|
||||
tags = ['streamline','contract_reads','records','heal']
|
||||
) }}
|
||||
|
||||
WITH verified_contracts AS (
|
||||
@ -20,29 +20,38 @@ WITH verified_contracts AS (
|
||||
WHERE
|
||||
is_verified
|
||||
AND token_address IS NOT NULL
|
||||
),
|
||||
),
|
||||
{% if is_incremental() %}
|
||||
existing_pairs AS (
|
||||
SELECT DISTINCT
|
||||
metadata:token0::STRING AS token0,
|
||||
metadata:token1::STRING AS token1
|
||||
FROM {{ this }}
|
||||
),
|
||||
{% endif %}
|
||||
liquidity_pools AS (
|
||||
|
||||
SELECT
|
||||
token0,
|
||||
token1,
|
||||
pool_address AS factory_address,
|
||||
hook_address,
|
||||
protocol,
|
||||
version,
|
||||
platform
|
||||
pools.token0,
|
||||
pools.token1,
|
||||
pools.pool_address AS factory_address,
|
||||
pools.hook_address,
|
||||
pools.protocol,
|
||||
pools.version,
|
||||
pools.platform
|
||||
FROM
|
||||
{{ ref('silver_dex__uniswap_v4_pools') }}
|
||||
WHERE token0 IN (SELECT token_address FROM verified_contracts)
|
||||
AND token1 IN (SELECT token_address FROM verified_contracts)
|
||||
{{ ref('silver_dex__uniswap_v4_pools') }} pools
|
||||
{% if is_incremental() %}
|
||||
LEFT JOIN existing_pairs ep
|
||||
ON pools.token0 = ep.token0
|
||||
AND pools.token1 = ep.token1
|
||||
{% endif %}
|
||||
WHERE pools.token0 IN (SELECT token_address FROM verified_contracts)
|
||||
AND pools.token1 IN (SELECT token_address FROM verified_contracts)
|
||||
{% if is_incremental() %}
|
||||
AND (
|
||||
modified_timestamp > (SELECT MAX(modified_timestamp) FROM {{ this }})
|
||||
OR CONCAT(token0,'-',token1) NOT IN (
|
||||
SELECT CONCAT(metadata:token0::STRING,'-',metadata:token1::STRING)
|
||||
FROM {{ this }}
|
||||
)
|
||||
-- pull in pools with newly verified tokens
|
||||
pools.modified_timestamp > (SELECT MAX(modified_timestamp) FROM {{ this }})
|
||||
OR ep.token0 IS NULL -- pull in pools with newly verified tokens
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user