Merge branch 'main' into dat2-253-monad-staking-reads

This commit is contained in:
Eric Laurello 2026-01-22 11:59:49 -05:00
commit d2514b52a6
67 changed files with 1958 additions and 131 deletions

View File

@ -0,0 +1,9 @@
chain,token_address,contract_address
ink,0x0200C29006150606B650577BBE7B6248F58470c1,0xD218103918C19D0A10cf35300E4CfAfbD444c5fE
ink,0x0200C29006150606B650577BBE7B6248F58470c1,0x05ec92D78ED421f3D3Ada77FFdE167106565974E
ink,0x4200000000000000000000000000000000000006,0xD218103918C19D0A10cf35300E4CfAfbD444c5fE
ink,0x4200000000000000000000000000000000000006,0x05ec92D78ED421f3D3Ada77FFdE167106565974E
ink,0x73E0C0d45E048D25Fc26Fa3159b0aA04BfA4Db98,0xD218103918C19D0A10cf35300E4CfAfbD444c5fE
ink,0x73E0C0d45E048D25Fc26Fa3159b0aA04BfA4Db98,0x05ec92D78ED421f3D3Ada77FFdE167106565974E
ink,0x2D270e6886d130D724215A266106e6832161EAEd,0xD218103918C19D0A10cf35300E4CfAfbD444c5fE
ink,0x2D270e6886d130D724215A266106e6832161EAEd,0x05ec92D78ED421f3D3Ada77FFdE167106565974E
1 chain token_address contract_address
2 ink 0x0200C29006150606B650577BBE7B6248F58470c1 0xD218103918C19D0A10cf35300E4CfAfbD444c5fE
3 ink 0x0200C29006150606B650577BBE7B6248F58470c1 0x05ec92D78ED421f3D3Ada77FFdE167106565974E
4 ink 0x4200000000000000000000000000000000000006 0xD218103918C19D0A10cf35300E4CfAfbD444c5fE
5 ink 0x4200000000000000000000000000000000000006 0x05ec92D78ED421f3D3Ada77FFdE167106565974E
6 ink 0x73E0C0d45E048D25Fc26Fa3159b0aA04BfA4Db98 0xD218103918C19D0A10cf35300E4CfAfbD444c5fE
7 ink 0x73E0C0d45E048D25Fc26Fa3159b0aA04BfA4Db98 0x05ec92D78ED421f3D3Ada77FFdE167106565974E
8 ink 0x2D270e6886d130D724215A266106e6832161EAEd 0xD218103918C19D0A10cf35300E4CfAfbD444c5fE
9 ink 0x2D270e6886d130D724215A266106e6832161EAEd 0x05ec92D78ED421f3D3Ada77FFdE167106565974E

View File

@ -1,32 +1,44 @@
{% macro unverify_tvl() %}
{% if var('HEAL_MODEL', false) and is_incremental() %}
-- Only target platforms that use verified_check_enabled
-- Delete rows that are invalid in BOTH v2 and v3/v4 styles
/*
Delete TVL rows that no longer have a corresponding reads record.
Only applies to platforms that use the verified_check_enabled system.
Reads records can be removed upstream by unverify_contract_reads() when tokens lose verification,
but high-value pools (verified_check_enabled='false') are protected and kept.
TVL structure varies by version:
- v2 style: contract_address=token, address=pool | reads: contract_address=pool, address=NULL
- v3/v4 style: contract_address=token, address=pool | reads: contract_address=token, address=pool
Note: Snowflake does not support CTEs with DELETE, so we use inline subqueries.
*/
DELETE FROM {{ this }} t
WHERE EXISTS (
SELECT 1
WHERE t.platform IN (
-- Platforms that have at least one record using the verified_check system
SELECT DISTINCT platform
FROM {{ ref('streamline__contract_reads_records') }}
WHERE metadata:verified_check_enabled::STRING = 'true'
AND platform = t.platform
) --necessary for the complete_tvl model
AND
-- Not valid in v2 style (address as pool)
NOT EXISTS (
SELECT 1
FROM {{ ref('streamline__contract_reads_records') }} r
WHERE r.metadata:verified_check_enabled::STRING = 'true'
AND r.address IS NULL
AND r.contract_address = t.address
)
AND
-- Not valid in v3/v4 style (token-address combo)
NOT EXISTS (
SELECT 1
FROM {{ ref('streamline__contract_reads_records') }} r
WHERE r.metadata:verified_check_enabled::STRING = 'true'
AND r.address IS NOT NULL
AND r.contract_address = t.contract_address
AND r.address = t.address
);
)
AND NOT (
-- Keep if valid in v2 style (t.address is the pool)
EXISTS (
SELECT 1
FROM {{ ref('streamline__contract_reads_records') }} v
WHERE v.address IS NULL
AND v.contract_address = t.address
AND v.platform = t.platform
)
OR
-- Keep if valid in v3/v4 style (t.contract_address is token, t.address is pool)
EXISTS (
SELECT 1
FROM {{ ref('streamline__contract_reads_records') }} v
WHERE v.address IS NOT NULL
AND v.contract_address = t.contract_address
AND v.address = t.address
AND v.platform = t.platform
)
);
{% endif %}
{% endmacro %}

View File

@ -323,15 +323,18 @@
},
'radiant': {
'v1': {
'aave_version_address': '0x2032b9a8e9f7e76768ca9271003d3e43e1616b1f'
'aave_version_address': '0x2032b9a8e9f7e76768ca9271003d3e43e1616b1f',
'fork_version': 'v2'
},
'v2': {
'aave_version_address': '0xf4b1486dd74d07706052a33d31d7c0aafd0659e1'
'aave_version_address': '0xf4b1486dd74d07706052a33d31d7c0aafd0659e1',
'fork_version': 'v2'
}
},
'aave': {
'v3': {
'aave_version_address': '0x794a61358d6845594f94dc1db02a252b5b4814ad'
'aave_version_address': '0x794a61358d6845594f94dc1db02a252b5b4814ad',
'fork_version': 'v3'
}
},
'morpho': {

View File

@ -253,10 +253,12 @@
},
'aave': {
'v3': {
'aave_version_address': '0x794a61358d6845594f94dc1db02a252b5b4814ad'
'aave_version_address': '0x794a61358d6845594f94dc1db02a252b5b4814ad',
'fork_version': 'v3'
},
'v2': {
'aave_version_address': '0x4f01aed16d97e3ab5ab2b501154dc9bb0f1a5a2c'
'aave_version_address': '0x4f01aed16d97e3ab5ab2b501154dc9bb0f1a5a2c',
'fork_version': 'v2'
}
},
'euler': {

View File

@ -34,6 +34,7 @@
'CURATED_DEFI_DEX_SWAPS_RECENCY_EXCLUSION_LIST': ['woofi-v3','woofi-v1','voodoo-v1'],
'CURATED_DEFI_DEX_LP_ACTIONS_RECENCY_EXCLUSION_LIST': ['balancer-v1'],
'CURATED_DEFI_BRIDGE_RECENCY_EXCLUSION_LIST': ['symbiosis-v1','hop-v1','across-v2'],
'CURATED_DEFI_TVL_UNI_V2_POOL_USD_THRESHOLD': 60000,
'CURATED_DEFI_DEX_SWAPS_CONTRACT_MAPPING': {
'uniswap': {
'v2': {
@ -260,12 +261,14 @@
},
'aave': {
'v3': {
'aave_version_address': '0xa238dd80c259a72e81d7e4664a9801593f98d1c5'
'aave_version_address': '0xa238dd80c259a72e81d7e4664a9801593f98d1c5',
'fork_version': 'v3'
},
},
'radiant': {
'v2': {
'aave_version_address': '0x30798cfe2cca822321ceed7e6085e633aabc492f'
'aave_version_address': '0x30798cfe2cca822321ceed7e6085e633aabc492f',
'fork_version': 'v2'
},
},
'euler': {
@ -275,12 +278,14 @@
},
'granary': {
'v1': {
'aave_version_address': '0xb702ce183b4e1faa574834715e5d4a6378d0eed3'
'aave_version_address': '0xb702ce183b4e1faa574834715e5d4a6378d0eed3',
'fork_version': 'v2'
},
},
'seamless': {
'v1': {
'aave_version_address': '0x8f44fd754285aa6a2b8b9b97739b79746e0475a7'
'aave_version_address': '0x8f44fd754285aa6a2b8b9b97739b79746e0475a7',
'fork_version': 'v3'
},
},
'morpho': {

View File

@ -24,6 +24,7 @@
'CURATED_DEFI_DEX_SWAPS_RECENCY_EXCLUSION_LIST': ['level_finance-v1','hashflow-v1','woofi-v1'],
'CURATED_DEFI_DEX_LP_ACTIONS_RECENCY_EXCLUSION_LIST': ['fraxswap-v1','trader_joe-v1','trader_joe-v2','kyberswap-v1','kyberswap-v2'],
'CURATED_DEFI_BRIDGE_RECENCY_EXCLUSION_LIST': ['symbiosis-v1'],
'CURATED_DEFI_TVL_UNI_V2_POOL_USD_THRESHOLD': 500000,
'CURATED_DEFI_DEX_SWAPS_CONTRACT_MAPPING': {
'uniswap': {
'v2': {
@ -242,17 +243,20 @@
},
'radiant': {
'v2': {
'aave_version_address': '0xd50cf00b6e600dd036ba8ef475677d816d6c4281'
'aave_version_address': '0xd50cf00b6e600dd036ba8ef475677d816d6c4281',
'fork_version': 'v2'
}
},
'aave': {
'v3': {
'aave_version_address': '0x6807dc923806fe8fd134338eabca509979a7e0cb'
'aave_version_address': '0x6807dc923806fe8fd134338eabca509979a7e0cb',
'fork_version': 'v3'
}
},
'kinza': {
'v1': {
'aave_version_address': '0xcb0620b181140e57d1c0d8b724cde623ca963c8c'
'aave_version_address': '0xcb0620b181140e57d1c0d8b724cde623ca963c8c',
'fork_version': 'v3'
}
},
'euler': {

View File

@ -324,25 +324,29 @@
'radiant': {
'v2': {
'aave_treasury': '0x28e395a54a64284dba39652921cd99924f4e3797',
'aave_version_address': '0xa950974f64aa33f27f6c5e017eee93bf7588ed07'
'aave_version_address': '0xa950974f64aa33f27f6c5e017eee93bf7588ed07',
'fork_version': 'v2'
}
},
'spark': {
'v1': {
'aave_treasury': '0xb137e7d16564c81ae2b0c8ee6b55de81dd46ece5',
'aave_version_address': '0xc13e21b648a5ee794902342038ff3adab66be987'
'aave_version_address': '0xc13e21b648a5ee794902342038ff3adab66be987',
'fork_version': 'v3'
}
},
'sturdy': {
'v1': {
'aave_treasury': '0xfd1d36995d76c0f75bbe4637c84c06e4a68bbb3a',
'aave_version_address': ['0xa422ca380bd70eef876292839222159e41aaee17','0x9f72dc67cec672bb99e3d02cbea0a21536a2b657']
'aave_version_address': ['0xa422ca380bd70eef876292839222159e41aaee17','0x9f72dc67cec672bb99e3d02cbea0a21536a2b657'],
'fork_version': 'v2'
}
},
'aave': {
'v3': {
'aave_treasury': '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
'aave_version_address': '0x87870bca3f3fd6335c3f4ce8392d69350b4fa4e2'
'aave_version_address': '0x87870bca3f3fd6335c3f4ce8392d69350b4fa4e2',
'fork_version': 'v3'
},
'v2': {
'aave_pool_addresses': ['0x311bb771e4f8952e6da169b425e7e92d6ac45756',

View File

@ -81,18 +81,21 @@
'CURATED_DEFI_LENDING_CONTRACT_MAPPING': {
'aave': {
'v3': {
'aave_version_address': '0xb50201558b00496a145fe76f7424749556e326d8'
'aave_version_address': '0xb50201558b00496a145fe76f7424749556e326d8',
'fork_version': 'v3'
},
},
'spark': {
'v1': {
'aave_version_address': '0x2dae5307c5e3fd1cf5a72cb6f698f915860607e0'
'aave_version_address': '0x2dae5307c5e3fd1cf5a72cb6f698f915860607e0',
'fork_version': 'v3'
},
},
'realt': {
'v3': {
'aave_version_address': ['0x5b8d36de471880ee21936f328aab2383a280cb2a',
'0xfb9b496519fca8473fba1af0850b6b8f476bfdb3']
'0xfb9b496519fca8473fba1af0850b6b8f476bfdb3'],
'fork_version': 'v3'
},
}
}

View File

@ -90,12 +90,14 @@
'CURATED_DEFI_LENDING_CONTRACT_MAPPING': {
'shroomy': {
'v1': {
'aave_version_address': '0x70c88e98578bc521a799de0b1c65a2b12d6f99e4'
'aave_version_address': '0x70c88e98578bc521a799de0b1c65a2b12d6f99e4',
'fork_version': 'v3'
}
},
'tydro': {
'v1': {
'aave_version_address': '0x2816cf15f6d2a220e789aa011d5ee4eb6c47feba'
'aave_version_address': '0x2816cf15f6d2a220e789aa011d5ee4eb6c47feba',
'fork_version': 'v3'
}
},
'morpho': {

View File

@ -243,12 +243,14 @@
},
'granary': {
'v1': {
'aave_version_address': '0x8fd4af47e4e63d1d2d45582c3286b4bd9bb95dfe'
'aave_version_address': '0x8fd4af47e4e63d1d2d45582c3286b4bd9bb95dfe',
'fork_version': 'v2'
}
},
'aave': {
'v3': {
'aave_version_address': '0x794a61358d6845594f94dc1db02a252b5b4814ad'
'aave_version_address': '0x794a61358d6845594f94dc1db02a252b5b4814ad',
'fork_version': 'v3'
}
},
'morpho': {

View File

@ -246,11 +246,13 @@
'aave': {
'v3': {
'aave_treasury': '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
'aave_version_address': '0x794a61358d6845594f94dc1db02a252b5b4814ad'
'aave_version_address': '0x794a61358d6845594f94dc1db02a252b5b4814ad',
'fork_version': 'v3'
},
'v2': {
'aave_treasury': '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
'aave_version_address': '0x8dff5e27ea6b7ac08ebfdf9eb090f32ee9a30fcf'
'aave_version_address': '0x8dff5e27ea6b7ac08ebfdf9eb090f32ee9a30fcf',
'fork_version': 'v2'
}
},
'morpho': {

View File

@ -312,6 +312,9 @@
{# Curated Lending Variables #}
{% set ns.CURATED_DEFI_LENDING_CONTRACT_MAPPING = get_var('CURATED_DEFI_LENDING_CONTRACT_MAPPING', {}) %}
{# Curated TVL Variables #}
{% set ns.CURATED_DEFI_TVL_UNI_V2_POOL_USD_THRESHOLD = get_var('CURATED_DEFI_TVL_UNI_V2_POOL_USD_THRESHOLD', 20000) %}
{# Return the entire namespace as a dictionary #}
{{ return(ns) }}

View File

@ -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 (
@ -25,7 +25,7 @@ WITH all_tokens AS (
FROM
{{ ref('silver_lending__aave_tokens') }}
WHERE
version = 'v1'
fork_version = 'v1'
{% if is_incremental() %}
AND modified_timestamp > (
@ -94,7 +94,7 @@ SELECT
'balanceOf' AS function_name,
'0x70a08231' AS function_sig,
CONCAT(
'0x70a08231',
function_sig,
LPAD(SUBSTR(address, 3), 64, '0')
) AS input,
NULL :: VARIANT AS metadata,

View File

@ -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 (
@ -26,7 +26,7 @@ WITH all_tokens AS (
FROM
{{ ref('silver_lending__aave_tokens') }}
WHERE
version = 'v2'
fork_version = 'v2'
{% if is_incremental() %}
AND modified_timestamp > (
@ -82,7 +82,7 @@ SELECT
'balanceOf' AS function_name,
'0x70a08231' AS function_sig,
CONCAT(
'0x70a08231',
function_sig,
LPAD(SUBSTR(address, 3), 64, '0')
) AS input,
NULL :: variant AS metadata,

View File

@ -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 (
@ -24,7 +24,7 @@ WITH all_tokens AS (
FROM
{{ ref('silver_lending__aave_tokens') }}
WHERE
version = 'v3'
fork_version = 'v3'
{% if is_incremental() %}
AND modified_timestamp > (

View File

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

View File

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

View File

@ -0,0 +1,56 @@
{# Get variables #}
{% set vars = return_vars() %}
{# Log configuration details #}
{{ log_model_details() }}
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'compound_v1_reads_id',
tags = ['streamline','contract_reads','records']
) }}
-- Compound V1 TVL: balanceOf(MoneyMarket) for each collateral token
-- MoneyMarket contract holds all tokens directly
WITH all_tokens AS (
SELECT
token_address AS contract_address,
money_market_address AS address,
protocol,
version,
platform
FROM
{{ ref('silver_lending__comp_v1_asset_details') }}
{% if is_incremental() %}
WHERE modified_timestamp > (
SELECT
MAX(modified_timestamp)
FROM
{{ this }}
)
{% endif %}
)
SELECT
contract_address,
address,
'balanceOf' AS function_name,
'0x70a08231' AS function_sig,
CONCAT(
function_sig,
LPAD(SUBSTR(address, 3), 64, '0')
) AS input,
NULL :: variant AS metadata,
protocol,
version,
platform,
{{ dbt_utils.generate_surrogate_key(
['contract_address','address','input','platform']
) }} AS compound_v1_reads_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
all_tokens

View File

@ -0,0 +1,58 @@
{# Get variables #}
{% set vars = return_vars() %}
{# Log configuration details #}
{{ log_model_details() }}
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'compound_v2_reads_id',
tags = ['streamline','contract_reads','records']
) }}
WITH all_tokens AS (
SELECT
underlying_asset_address AS contract_address,
token_address AS address,
protocol,
version,
CONCAT(
protocol,
'-',
version
) AS platform
FROM
{{ ref('silver_lending__comp_v2_asset_details') }}
{% if is_incremental() %}
WHERE modified_timestamp > (
SELECT
MAX(modified_timestamp)
FROM
{{ this }}
)
{% endif %}
)
SELECT
contract_address,
address,
'balanceOf' AS function_name,
'0x70a08231' AS function_sig,
CONCAT(
function_sig,
LPAD(SUBSTR(address, 3), 64, '0')
) AS input,
NULL :: variant AS metadata,
protocol,
version,
platform,
{{ dbt_utils.generate_surrogate_key(
['contract_address','address','input','platform']
) }} AS compound_v2_reads_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
all_tokens

View File

@ -0,0 +1,86 @@
{# Get variables #}
{% set vars = return_vars() %}
{# Log configuration details #}
{{ log_model_details() }}
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'compound_v3_reads_id',
tags = ['streamline','contract_reads','records']
) }}
WITH base_tokens AS (
-- Base token (e.g., USDC, WETH) for each Comet market
SELECT
underlying_asset_address AS contract_address,
compound_market_address AS address,
protocol,
version,
CONCAT(
protocol,
'-',
version
) AS platform
FROM
{{ ref('silver_lending__comp_v3_asset_details') }}
{% if is_incremental() %}
WHERE modified_timestamp > (
SELECT
MAX(modified_timestamp)
FROM
{{ this }}
)
{% endif %}
),
collateral_tokens AS (
-- All collateral assets for each Comet market
SELECT
collateral_asset_address AS contract_address,
compound_market_address AS address,
protocol,
version,
platform
FROM
{{ ref('silver_lending__comp_v3_collateral_assets') }}
{% if is_incremental() %}
WHERE modified_timestamp > (
SELECT
MAX(modified_timestamp)
FROM
{{ this }}
)
{% endif %}
),
all_tokens AS (
SELECT * FROM base_tokens
UNION
SELECT * FROM collateral_tokens
)
SELECT
contract_address,
address,
'balanceOf' AS function_name,
'0x70a08231' AS function_sig,
CONCAT(
function_sig,
LPAD(SUBSTR(address, 3), 64, '0')
) AS input,
NULL :: variant AS metadata,
protocol,
version,
platform,
{{ dbt_utils.generate_surrogate_key(
['contract_address','address','input','platform']
) }} AS compound_v3_reads_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
all_tokens

View File

@ -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 (
@ -38,7 +38,7 @@ SELECT
'balanceOf' AS function_name,
'0x70a08231' AS function_sig,
CONCAT(
'0x70a08231',
function_sig,
LPAD(SUBSTR(address, 3), 64, '0')
) AS input,
NULL :: variant AS metadata,

View File

@ -0,0 +1,83 @@
{# Get variables #}
{% set vars = return_vars() %}
{# Log configuration details #}
{{ log_model_details() }}
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'eigenlayer_v1_reads_id',
tags = ['streamline','contract_reads','records']
) }}
WITH strategy_events AS (
SELECT
DISTINCT LOWER(
decoded_log :strategy :: STRING
) AS strategy_address
FROM
{{ ref('core__ez_decoded_event_logs') }}
WHERE
contract_address = LOWER('0x858646372cc42e1a627fce94aa7a7033e7cf075a') -- StrategyManager
AND event_name = 'StrategyAddedToDepositWhitelist'
AND block_number >= 17445564 -- Contract deployment block
AND strategy_address <> LOWER('0xaCB55C530Acdb2849e6d4f36992Cd8c9D50ED8F7') -- Exclude bEIGEN strategy as per adapter (staking, not TVL)
{% if is_incremental() %}
AND modified_timestamp > (
SELECT
MAX(modified_timestamp)
FROM
{{ this }}
)
{% endif %}
),
strategies AS (
-- totalShares() reads
SELECT
strategy_address AS contract_address,
'totalShares' AS function_name,
'0x3a98ef39' AS function_sig,
RPAD(
'0x3a98ef39',
64,
'0'
) AS input
FROM
strategy_events
UNION ALL
-- underlyingToken() reads
SELECT
strategy_address AS contract_address,
'underlyingToken' AS function_name,
'0x2495a599' AS function_sig,
RPAD(
'0x2495a599',
64,
'0'
) AS input
FROM
strategy_events
)
SELECT
contract_address,
NULL AS address,
function_name,
function_sig,
input,
NULL :: variant AS metadata,
'eigenlayer' AS protocol,
'v1' AS version,
CONCAT(
protocol,
'-',
version
) AS platform,
{{ dbt_utils.generate_surrogate_key(
['contract_address','input','platform']
) }} AS eigenlayer_v1_reads_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
strategies

View File

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

View File

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

View File

@ -0,0 +1,97 @@
{# Get variables #}
{% set vars = return_vars() %}
{# Log configuration details #}
{{ log_model_details() }}
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'morpho_blue_v1_reads_id',
tags = ['streamline','contract_reads','records']
) }}
WITH morpho_blue_addresses AS (
{{ curated_contract_mapping(
vars.CURATED_DEFI_LENDING_CONTRACT_MAPPING
) }}
WHERE
type = 'morpho_blue_address'
),
market_tokens AS (
-- Get unique tokens from CreateMarket events
SELECT
DISTINCT token_address,
morpho_blue_address
FROM
(
-- Collateral tokens (2nd address in marketParams tuple, bytes 32-64 of data)
SELECT
LOWER(CONCAT('0x', SUBSTR(data, 91, 40))) AS token_address,
m.contract_address AS morpho_blue_address
FROM
{{ ref('core__fact_event_logs') }} l
INNER JOIN morpho_blue_addresses m USING(contract_address)
WHERE
topic_0 = '0xac4b2400f169220b0c0afdde7a0b32e775ba727ea1cb30b35f935cdaab8683ac'
{% if is_incremental() %}
AND modified_timestamp > (
SELECT
MAX(modified_timestamp)
FROM
{{ this }}
)
{% endif %}
UNION
-- Loan tokens (1st address in marketParams tuple, bytes 0-32 of data)
SELECT
LOWER(CONCAT('0x', SUBSTR(data, 27, 40))) AS token_address,
m.contract_address AS morpho_blue_address
FROM
{{ ref('core__fact_event_logs') }} l
INNER JOIN morpho_blue_addresses m USING(contract_address)
WHERE
topic_0 = '0xac4b2400f169220b0c0afdde7a0b32e775ba727ea1cb30b35f935cdaab8683ac'
{% if is_incremental() %}
AND modified_timestamp > (
SELECT
MAX(modified_timestamp)
FROM
{{ this }}
)
{% endif %}
)
WHERE
token_address <> '0x0000000000000000000000000000000000000000'
AND token_address IS NOT NULL
)
SELECT
token_address AS contract_address,
morpho_blue_address AS address,
'balanceOf' AS function_name,
'0x70a08231' AS function_sig,
CONCAT(
function_sig,
LPAD(
SUBSTR(
morpho_blue_address,
3
),
64,
'0'
)
) AS input,
NULL::VARIANT AS metadata,
'morpho' AS protocol,
'v1' AS version,
CONCAT(
protocol,
'-',
version
) AS platform,
{{ dbt_utils.generate_surrogate_key(['contract_address','address','input','platform']) }} AS morpho_blue_v1_reads_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
market_tokens

View File

@ -0,0 +1,57 @@
{# Get variables #}
{% set vars = return_vars() %}
{# Log configuration details #}
{{ log_model_details() }}
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'nado_reads_id',
tags = ['streamline','contract_reads','records']
) }}
WITH contracts AS (
SELECT
LOWER(s.token_address) AS contract_address,
LOWER(s.contract_address) AS address
FROM
{{ ref('silver_reads__nado_seed') }} s
WHERE
chain = '{{ vars.GLOBAL_PROJECT_NAME }}'
{% if is_incremental() %}
AND CONCAT(COALESCE(token_address, 'null'), '-', contract_address) NOT IN (
SELECT
CONCAT(COALESCE(contract_address, 'null'), '-', address)
FROM
{{ this }}
)
{% endif %}
)
SELECT
contract_address,
address,
'balanceOf' AS function_name,
'0x70a08231' AS function_sig,
CONCAT(
function_sig,
LPAD(SUBSTR(address, 3), 64, '0')
) AS input,
NULL :: variant AS metadata,
'nado' AS protocol,
'v1' AS version,
CONCAT(
protocol,
'-',
version
) AS platform,
{{ dbt_utils.generate_surrogate_key(
['contract_address','address','input','platform']
) }} AS nado_reads_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
contracts

View File

@ -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 (
@ -25,7 +25,7 @@ SELECT
'balanceOf' AS function_name,
'0x70a08231' AS function_sig,
CONCAT(
'0x70a08231',
function_sig,
LPAD(SUBSTR(address, 3), 64, '0')
) AS input,
NULL :: VARIANT AS metadata,

View File

@ -0,0 +1,41 @@
{# Get variables #}
{% set vars = return_vars() %}
{# Log configuration details #}
{{ log_model_details() }}
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'rocketpool_v1_reads_id',
tags = ['streamline','contract_reads','records']
) }}
SELECT
'0xae78736cd615f374d3085123a210448e74fc6393' AS contract_address, --rETH
NULL AS address,
'totalSupply' AS function_name,
'0x18160ddd' AS function_sig,
RPAD(
function_sig,
64,
'0'
) AS input,
NULL :: VARIANT AS metadata,
'rocketpool' AS protocol,
'v1' AS version,
CONCAT(protocol, '-', version) AS platform,
{{ dbt_utils.generate_surrogate_key(
['contract_address','input','platform']
) }} AS rocketpool_v1_reads_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
{% if is_incremental() %}
WHERE contract_address NOT IN (
SELECT
contract_address
FROM
{{ this }}
)
{% endif %}

View File

@ -0,0 +1,63 @@
{# Get variables #}
{% set vars = return_vars() %}
{# Log configuration details #}
{{ log_model_details() }}
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'sky_v1_collateral_joins_id',
tags = ['streamline','contract_reads','records','sky']
) }}
-- Sky Protocol (MakerDAO) collateral join discovery
-- Discovers join contracts from MCD_VAT rely events via gem() calls
WITH rely_events AS (
SELECT
DISTINCT
LOWER(CONCAT('0x', SUBSTR(topic_1, -40))) AS join_address,
block_number
FROM
{{ ref('core__fact_event_logs') }}
WHERE
contract_address = '0x35d1b3f3d7966a1dfe207aa4514c12a259a0492b'
AND topic_0 = '0x65fae35e00000000000000000000000000000000000000000000000000000000'
AND block_number >= 8928152 -- Contract deployment block
{% if is_incremental() %}
AND modified_timestamp > (SELECT MAX(modified_timestamp) FROM {{ this }})
{% endif %}
)
SELECT
join_address,
OBJECT_CONSTRUCT(
'id', CONCAT(join_address, '-gem'),
'jsonrpc', '2.0',
'method', 'eth_call',
'params', ARRAY_CONSTRUCT(
OBJECT_CONSTRUCT(
'to', join_address,
'data', '0x7bd2bea7'
),
utils.udf_int_to_hex(block_number)
)
) AS rpc_request,
live.udf_api(
'POST',
'{{ vars.GLOBAL_NODE_URL }}',
OBJECT_CONSTRUCT(
'Content-Type', 'application/json',
'fsc-quantum-state', 'livequery'
),
rpc_request,
'{{ vars.GLOBAL_NODE_VAULT_PATH }}'
) AS response,
response:data:result::STRING AS result_hex,
{{ dbt_utils.generate_surrogate_key(['join_address']) }} AS sky_v1_collateral_joins_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
rely_events

View File

@ -0,0 +1,56 @@
{# Get variables #}
{% set vars = return_vars() %}
{# Log configuration details #}
{{ log_model_details() }}
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'sky_v1_reads_id',
tags = ['streamline','contract_reads','records']
) }}
WITH collateral_joins AS (
SELECT
join_address,
LOWER(CONCAT('0x', SUBSTR(result_hex, -40))) AS token_address
FROM
{{ ref('silver_reads__sky_v1_collateral_joins') }}
WHERE
result_hex IS NOT NULL
AND LENGTH(result_hex) >= 42
AND result_hex NOT IN ('0x', '0x0000000000000000000000000000000000000000000000000000000000000000')
{% if is_incremental() %}
AND modified_timestamp > (SELECT MAX(modified_timestamp) FROM {{ this }})
{% endif %}
UNION ALL
SELECT
'0x37305b1cd40574e4c5ce33f8e8306be057fd7341' AS join_address, -- Sky: PSM
'0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' AS token_address -- USDC
)
SELECT
token_address AS contract_address,
join_address AS address,
'balanceOf' AS function_name,
'0x70a08231' AS function_sig,
CONCAT(
function_sig,
LPAD(SUBSTR(join_address, 3), 64, '0')
) AS input,
NULL::VARIANT AS metadata,
'sky' AS protocol,
'v1' AS version,
CONCAT(protocol, '-', version) AS platform,
{{ dbt_utils.generate_surrogate_key(
['contract_address','address','input','platform']
) }} AS sky_v1_reads_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
collateral_joins
WHERE
token_address IS NOT NULL
AND token_address != '0x0000000000000000000000000000000000000000'

View File

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

View File

@ -7,6 +7,9 @@
-- depends_on: {{ ref('price__ez_asset_metadata') }}
-- depends_on: {{ ref('silver_reads__lido_v1_reads') }}
-- depends_on: {{ ref('silver_reads__binance_v1_reads') }}
-- depends_on: {{ ref('silver_reads__eigenlayer_v1_reads') }}
-- depends_on: {{ ref('silver_reads__rocketpool_v1_reads') }}
-- depends_on: {{ ref('silver_reads__sky_v1_reads') }}
-- depends_on: {{ ref('silver_reads__polymarket_v1_reads') }}
-- depends_on: {{ ref('silver_reads__monad_delegator_reads') }}
{{ config (
@ -23,6 +26,9 @@
{% if vars.GLOBAL_PROJECT_NAME == 'ethereum' %}
{% set _ = models.append((ref('silver_reads__lido_v1_reads'), 'daily')) %}
{% set _ = models.append((ref('silver_reads__binance_v1_reads'), 'daily')) %}
{% set _ = models.append((ref('silver_reads__eigenlayer_v1_reads'), 'daily')) %}
{% set _ = models.append((ref('silver_reads__rocketpool_v1_reads'), 'daily')) %}
{% set _ = models.append((ref('silver_reads__sky_v1_reads'), 'daily')) %}
{% endif %}
{% if vars.GLOBAL_PROJECT_NAME == 'polygon' %}
{% set _ = models.append((ref('silver_reads__polymarket_v1_reads'), 'daily')) %}
@ -42,6 +48,11 @@
{% set _ = models.append((ref('silver_reads__curve_v1_reads'), 'daily')) %}
{% set _ = models.append((ref('silver_reads__tornado_cash_v1_reads'), 'daily')) %}
{% set _ = models.append((ref('silver_reads__etherfi_v1_reads'), 'daily')) %}
{% set _ = models.append((ref('silver_reads__morpho_blue_v1_reads'), 'daily')) %}
{% set _ = models.append((ref('silver_reads__nado_v1_reads'), 'daily')) %}
{% set _ = models.append((ref('silver_reads__compound_v1_reads'), 'daily')) %}
{% set _ = models.append((ref('silver_reads__compound_v2_reads'), 'daily')) %}
{% set _ = models.append((ref('silver_reads__compound_v3_reads'), 'daily')) %}
WITH all_records AS (

View File

@ -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 (
@ -61,7 +61,7 @@ SELECT
'balanceOf' AS function_name,
'0x70a08231' AS function_sig,
CONCAT(
'0x70a08231',
function_sig,
LPAD(SUBSTR(address, 3), 64, '0')
) AS input,
OBJECT_CONSTRUCT(

View File

@ -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 (
@ -37,7 +37,7 @@ SELECT
'balanceOf' AS function_name,
'0x70a08231' AS function_sig,
CONCAT(
'0x70a08231',
function_sig,
LPAD(SUBSTR(address, 3), 64, '0')
) AS input,
NULL :: variant AS metadata,

View File

@ -1,18 +1,17 @@
{# Get variables #}
{% set vars = return_vars() %}
{# Log configuration details #}
{{ log_model_details() }}
{{ config(
materialized = 'incremental',
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 (
SELECT
DISTINCT token_address
FROM
@ -21,25 +20,101 @@ WITH verified_contracts AS (
is_verified
AND token_address IS NOT NULL
),
high_value_pools AS (
SELECT
DISTINCT pool_address
FROM
{{ ref('defi__ez_dex_liquidity_pool_actions') }}
WHERE
event_name IN (
'Mint',
'AddLiquidity',
'Deposit'
)
AND amount_usd IS NOT NULL
AND amount_usd > 0
AND amount_usd < 1e9 -- filter bad pricing
AND platform IN (
SELECT
DISTINCT platform
FROM
{{ ref('silver_dex__paircreated_evt_v2_pools') }}
)
{% if is_incremental() %}
AND pool_address NOT IN (
SELECT
contract_address
FROM
{{ this }}
)
{% endif %}
GROUP BY
pool_address
HAVING
SUM(amount_usd) >= '{{ vars.CURATED_DEFI_TVL_UNI_V2_POOL_USD_THRESHOLD }}' :: STRING :: INT
--chain dependent thresholds
),
liquidity_pools AS (
SELECT
DISTINCT
pool_address AS contract_address,
DISTINCT pool_address AS contract_address,
token0,
token1,
protocol,
version,
platform
FROM {{ ref('silver_dex__paircreated_evt_v2_pools') }}
WHERE token0 IN (SELECT token_address FROM verified_contracts)
AND token1 IN (SELECT token_address FROM verified_contracts)
{% if is_incremental() %}
AND (
modified_timestamp > (SELECT MAX(modified_timestamp) FROM {{ this }})
OR pool_address NOT IN (SELECT contract_address FROM {{ this }})
-- pull in pools with newly verified tokens
platform,
-- Track qualification path for unverify logic
-- If both tokens are verified, subject to unverify. Otherwise protected (high-value pool with unverified tokens)
CASE
WHEN token0 IN (SELECT token_address FROM verified_contracts)
AND token1 IN (SELECT token_address FROM verified_contracts)
THEN 'true'
ELSE 'false'
END AS verified_check_enabled
FROM
{{ ref('silver_dex__paircreated_evt_v2_pools') }}
WHERE
(
-- High value pools
pool_address IN (
SELECT
pool_address
FROM
high_value_pools
)
OR (
-- Both tokens verified
token0 IN (
SELECT
token_address
FROM
verified_contracts
)
AND token1 IN (
SELECT
token_address
FROM
verified_contracts
)
)
)
{% if is_incremental() %}
AND (
modified_timestamp > (
SELECT
MAX(modified_timestamp)
FROM
{{ this }}
)
{% endif %}
OR pool_address NOT IN (
SELECT
contract_address
FROM
{{ this }}
)
)
{% endif %}
)
SELECT
contract_address,
@ -52,17 +127,19 @@ SELECT
'0'
) AS input,
OBJECT_CONSTRUCT(
'token0', token0,
'token1', token1,
'verified_check_enabled','true'
) :: VARIANT AS metadata,
'token0',
token0,
'token1',
token1,
'verified_check_enabled',
verified_check_enabled
) :: variant AS metadata,
protocol,
version,
platform,
{{ dbt_utils.generate_surrogate_key(
['contract_address','input','platform']
) }} AS uniswap_v2_reads_id,
{{ dbt_utils.generate_surrogate_key(['contract_address', 'input', 'platform']) }} AS uniswap_v2_reads_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM liquidity_pools
FROM
liquidity_pools

View File

@ -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 (
@ -69,7 +69,7 @@ SELECT
'balanceOf' AS function_name,
'0x70a08231' AS function_sig,
CONCAT(
'0x70a08231',
function_sig,
LPAD(SUBSTR(address, 3), 64, '0')
) AS input,
OBJECT_CONSTRUCT(

View File

@ -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
p.token0,
p.token1,
p.pool_address AS factory_address,
p.hook_address,
p.protocol,
p.version,
p.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') }} p
{% if is_incremental() %}
LEFT JOIN existing_pairs e
ON p.token0 = e.token0
AND p.token1 = e.token1
{% endif %}
WHERE p.token0 IN (SELECT token_address FROM verified_contracts)
AND p.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
p.modified_timestamp > (SELECT MAX(modified_timestamp) FROM {{ this }})
OR e.token0 IS NULL -- pull in pools with newly verified tokens
)
{% endif %}
),
@ -121,7 +130,7 @@ SELECT
'balanceOf' AS function_name,
'0x70a08231' AS function_sig,
CONCAT(
'0x70a08231',
function_sig,
LPAD(SUBSTR(address, 3), 64, '0')
) AS input,
object_construct_keep_null(

View File

@ -17,6 +17,13 @@ WITH aave_version_addresses AS (
WHERE
type = 'aave_version_address'
),
aave_fork_version AS (
{{ curated_contract_mapping(
vars.CURATED_DEFI_LENDING_CONTRACT_MAPPING
) }}
WHERE
type = 'fork_version'
),
DECODE AS (
SELECT
@ -128,6 +135,7 @@ SELECT
A.underlying_asset AS underlying_address,
t.protocol,
t.version,
f.contract_address AS fork_version,
A.modified_timestamp,
A._log_id
FROM
@ -136,6 +144,8 @@ FROM
ON A.a_token_address = b.token_address
LEFT JOIN aave_version_addresses t
ON A.version_pool = t.contract_address
LEFT JOIN aave_fork_version f
ON t.protocol = f.protocol AND t.version = f.version
qualify(ROW_NUMBER() over(PARTITION BY A.underlying_asset,A.version_pool
ORDER BY
A.atoken_created_block DESC)) = 1

View File

@ -0,0 +1,101 @@
{# Get variables #}
{% set vars = return_vars() %}
{# Log configuration details #}
{{ log_model_details() }}
{{ config(
materialized = 'incremental',
unique_key = "comp_v1_asset_details_id",
tags = ['silver','defi','lending','curated','compound','comp_v1']
) }}
-- Compound V1 is Ethereum-only with a single MoneyMarket contract
-- This model discovers collateral markets via collateralMarkets(uint256) calls
-- Generate indices 0-19 for collateral markets (max expected)
WITH indices AS (
SELECT column1 AS idx FROM (VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11), (12), (13), (14), (15), (16), (17), (18), (19))
),
market_indices AS (
SELECT idx
FROM indices
{% if is_incremental() %}
WHERE NOT EXISTS (
SELECT 1 FROM {{ this }} t
WHERE t.market_index = indices.idx
)
{% endif %}
),
-- Call collateralMarkets(i) for each index
collateral_market_calls AS (
SELECT
'0x3fda67f7583380e67ef93072294a7fac882fd7e7' AS money_market_address,
idx,
live.udf_api(
'POST',
'{URL}',
OBJECT_CONSTRUCT(
'Content-Type', 'application/json',
'fsc-quantum-state', 'livequery'
),
utils.udf_json_rpc_call(
'eth_call',
[
{
'to': money_market_address,
'from': null,
'data': CONCAT('0xbeb54615', LPAD(REPLACE(utils.udf_int_to_hex(idx), '0x', ''), 64, '0'))
},
'latest'
],
concat_ws('-', money_market_address, 'collateralMarkets', idx)
),
'{{ vars.GLOBAL_NODE_VAULT_PATH }}'
) AS api_response
FROM
market_indices
),
parsed_markets AS (
SELECT
money_market_address,
idx AS market_index,
api_response:data:result::STRING AS result_hex,
CASE
WHEN result_hex IS NOT NULL
AND LENGTH(result_hex) >= 42
AND result_hex != '0x'
AND result_hex != '0x0000000000000000000000000000000000000000000000000000000000000000'
THEN LOWER(CONCAT('0x', SUBSTR(result_hex, -40)))
ELSE NULL
END AS token_address
FROM
collateral_market_calls
WHERE
api_response:data:result IS NOT NULL
AND api_response:data:result::STRING != '0x'
)
SELECT
p.money_market_address,
p.token_address,
c.name AS token_name,
c.symbol AS token_symbol,
c.decimals AS token_decimals,
p.market_index,
'compound' AS protocol,
'v1' AS version,
CONCAT(protocol, '-', version) AS platform,
{{ dbt_utils.generate_surrogate_key(['token_address']) }} AS comp_v1_asset_details_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
parsed_markets p
LEFT JOIN {{ ref('core__dim_contracts') }} c ON p.token_address = c.address
WHERE
p.token_address IS NOT NULL
AND p.token_address != '0x0000000000000000000000000000000000000000'

View File

@ -0,0 +1,111 @@
{# Get variables #}
{% set vars = return_vars() %}
{# Log configuration details #}
{{ log_model_details() }}
{{ config(
materialized = 'incremental',
unique_key = "collateral_asset_id",
tags = ['silver','defi','lending','curated','compound','comp_v3']
) }}
WITH
-- Generate indices 0-14 for each market (max expected collateral assets)
indices AS (
SELECT column1 AS idx FROM (VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11), (12), (13), (14))
),
market_indices AS (
SELECT
m.compound_market_address,
m.protocol,
m.version,
m.platform,
i.idx
FROM
{{ ref('silver_lending__comp_v3_asset_details') }} m
CROSS JOIN
indices i
{% if is_incremental() %}
WHERE NOT EXISTS (
SELECT 1 FROM {{ this }} t
WHERE t.compound_market_address = m.compound_market_address
AND t.asset_index = i.idx
)
{% endif %}
),
-- Call getAssetInfo(i) for each market/index combination
asset_info_calls AS (
SELECT
compound_market_address,
protocol,
version,
platform,
idx,
live.udf_api(
'POST',
'{URL}',
OBJECT_CONSTRUCT(
'Content-Type', 'application/json',
'fsc-quantum-state', 'livequery'
),
utils.udf_json_rpc_call(
'eth_call',
[
{
'to': compound_market_address,
'from': null,
'data': CONCAT('0xc8c7fe6b', LPAD(REPLACE(utils.udf_int_to_hex(idx), '0x', ''), 64, '0'))
},
'latest'
],
concat_ws('-', compound_market_address, 'getAssetInfo', idx)
),
'{{ vars.GLOBAL_NODE_VAULT_PATH }}'
) AS api_response
FROM
market_indices
),
-- getAssetInfo returns tuple: (uint8 offset, address asset, address priceFeed, ...)
parsed_assets AS (
SELECT
compound_market_address,
protocol,
version,
platform,
idx AS asset_index,
api_response:data:result::STRING AS result_hex,
CASE
WHEN result_hex IS NOT NULL
AND LENGTH(result_hex) >= 130
AND result_hex != '0x'
THEN LOWER(CONCAT('0x', SUBSTR(result_hex, 91, 40)))
ELSE NULL
END AS collateral_asset_address
FROM
asset_info_calls
WHERE
api_response:data:result IS NOT NULL
AND api_response:data:result::STRING != '0x'
AND LENGTH(api_response:data:result::STRING) >= 130
)
SELECT
compound_market_address,
collateral_asset_address,
asset_index,
protocol,
version,
platform,
{{ dbt_utils.generate_surrogate_key(['compound_market_address', 'collateral_asset_address']) }} AS collateral_asset_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
parsed_assets
WHERE
collateral_asset_address IS NOT NULL
AND collateral_asset_address != '0x0000000000000000000000000000000000000000'

View File

@ -58,7 +58,7 @@ SELECT
version,
platform,
{{ dbt_utils.generate_surrogate_key(
['block_date','contract_address','platform']
['block_date','contract_address','address','platform']
) }} AS binance_v1_tvl_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,

View File

@ -0,0 +1,74 @@
{# Get variables #}
{% set vars = return_vars() %}
{# Log configuration details #}
{{ log_model_details() }}
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'compound_v1_tvl_id',
tags = ['silver','defi','tvl','curated_daily']
) }}
WITH reads AS (
SELECT
block_number,
block_date,
contract_address,
address,
result_hex AS amount_hex,
IFNULL(
CASE
WHEN LENGTH(amount_hex) <= 4300
AND amount_hex IS NOT NULL THEN TRY_CAST(utils.udf_hex_to_int(amount_hex) AS bigint)END,
CASE
WHEN amount_hex IS NOT NULL THEN TRY_CAST(utils.udf_hex_to_int(RTRIM(amount_hex, '0')) AS bigint)
END
) AS amount_raw,
protocol,
version,
platform,
modified_timestamp
FROM
{{ ref('silver__contract_reads') }}
WHERE
amount_raw IS NOT NULL
AND platform IN (
SELECT
DISTINCT platform
FROM
{{ ref('silver_reads__compound_v1_reads') }}
)
{% if is_incremental() %}
AND modified_timestamp > (
SELECT
MAX(modified_timestamp)
FROM
{{ this }}
)
{% endif %}
)
SELECT
block_number,
block_date,
contract_address,
address,
contract_address AS token_address,
amount_hex,
amount_raw,
protocol,
version,
platform,
{{ dbt_utils.generate_surrogate_key(
['block_date','contract_address','address','platform']
) }} AS compound_v1_tvl_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
reads qualify(ROW_NUMBER() over(PARTITION BY compound_v1_tvl_id
ORDER BY
modified_timestamp DESC)) = 1

View File

@ -0,0 +1,4 @@
version: 2
models:
- name: silver_tvl__compound_v1_tvl
description: '{{ doc("compound_v1_tvl_table_doc") }}'

View File

@ -0,0 +1,74 @@
{# Get variables #}
{% set vars = return_vars() %}
{# Log configuration details #}
{{ log_model_details() }}
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'compound_v2_tvl_id',
tags = ['silver','defi','tvl','curated_daily']
) }}
WITH reads AS (
SELECT
block_number,
block_date,
contract_address,
address,
result_hex AS amount_hex,
IFNULL(
CASE
WHEN LENGTH(amount_hex) <= 4300
AND amount_hex IS NOT NULL THEN TRY_CAST(utils.udf_hex_to_int(amount_hex) AS bigint)END,
CASE
WHEN amount_hex IS NOT NULL THEN TRY_CAST(utils.udf_hex_to_int(RTRIM(amount_hex, '0')) AS bigint)
END
) AS amount_raw,
protocol,
version,
platform,
modified_timestamp
FROM
{{ ref('silver__contract_reads') }}
WHERE
amount_raw IS NOT NULL
AND platform IN (
SELECT
DISTINCT platform
FROM
{{ ref('silver_reads__compound_v2_reads') }}
)
{% if is_incremental() %}
AND modified_timestamp > (
SELECT
MAX(modified_timestamp)
FROM
{{ this }}
)
{% endif %}
)
SELECT
block_number,
block_date,
contract_address,
address,
contract_address AS token_address,
amount_hex,
amount_raw,
protocol,
version,
platform,
{{ dbt_utils.generate_surrogate_key(
['block_date','contract_address','address','platform']
) }} AS compound_v2_tvl_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
reads qualify(ROW_NUMBER() over(PARTITION BY compound_v2_tvl_id
ORDER BY
modified_timestamp DESC)) = 1

View File

@ -0,0 +1,4 @@
version: 2
models:
- name: silver_tvl__compound_v2_tvl
description: '{{ doc("compound_v2_tvl_table_doc") }}'

View File

@ -0,0 +1,74 @@
{# Get variables #}
{% set vars = return_vars() %}
{# Log configuration details #}
{{ log_model_details() }}
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'compound_v3_tvl_id',
tags = ['silver','defi','tvl','curated_daily']
) }}
WITH reads AS (
SELECT
block_number,
block_date,
contract_address,
address,
result_hex AS amount_hex,
IFNULL(
CASE
WHEN LENGTH(amount_hex) <= 4300
AND amount_hex IS NOT NULL THEN TRY_CAST(utils.udf_hex_to_int(amount_hex) AS bigint)END,
CASE
WHEN amount_hex IS NOT NULL THEN TRY_CAST(utils.udf_hex_to_int(RTRIM(amount_hex, '0')) AS bigint)
END
) AS amount_raw,
protocol,
version,
platform,
modified_timestamp
FROM
{{ ref('silver__contract_reads') }}
WHERE
amount_raw IS NOT NULL
AND platform IN (
SELECT
DISTINCT platform
FROM
{{ ref('silver_reads__compound_v3_reads') }}
)
{% if is_incremental() %}
AND modified_timestamp > (
SELECT
MAX(modified_timestamp)
FROM
{{ this }}
)
{% endif %}
)
SELECT
block_number,
block_date,
contract_address,
address,
contract_address AS token_address,
amount_hex,
amount_raw,
protocol,
version,
platform,
{{ dbt_utils.generate_surrogate_key(
['block_date','contract_address','address','platform']
) }} AS compound_v3_tvl_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
reads qualify(ROW_NUMBER() over(PARTITION BY compound_v3_tvl_id
ORDER BY
modified_timestamp DESC)) = 1

View File

@ -0,0 +1,4 @@
version: 2
models:
- name: silver_tvl__compound_v3_tvl
description: '{{ doc("compound_v3_tvl_table_doc") }}'

View File

@ -0,0 +1,40 @@
{# Get variables #}
{% set vars = return_vars() %}
{# Log configuration details #}
{{ log_model_details() }}
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'eigenlayer_v1_eigenpods_id',
tags = ['silver','defi','tvl','curated_daily']
) }}
SELECT
DISTINCT LOWER(
decoded_log :eigenPod :: STRING
) AS eigenpod_address,
SYSDATE() AS modified_timestamp,
SYSDATE() AS inserted_timestamp,
'{{ invocation_id }}' AS _invocation_id,
{{ dbt_utils.generate_surrogate_key(['eigenpod_address']) }} AS eigenlayer_v1_eigenpods_id
FROM
{{ ref('core__ez_decoded_event_logs') }}
WHERE
contract_address = LOWER('0x91e677b07f7af907ec9a428aafa9fc14a0d3a338')
AND event_name = 'PodDeployed'
AND block_number >= 17445564 -- Contract deployment block
{% if is_incremental() %}
AND modified_timestamp > (
SELECT
MAX(modified_timestamp)
FROM
{{ this }}
)
{% endif %}
qualify ROW_NUMBER() over (
PARTITION BY eigenlayer_v1_eigenpods_id
ORDER BY
modified_timestamp DESC
) = 1

View File

@ -0,0 +1,125 @@
{# Get variables #}
{% set vars = return_vars() %}
{# Log configuration details #}
{{ log_model_details() }}
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'eigenlayer_v1_tvl_id',
tags = ['silver','defi','tvl','curated_daily']
) }}
WITH beacon_blocks AS (
SELECT
slot_number,
slot_timestamp::DATE AS block_date,
execution_payload:block_number::INT AS block_number,
modified_timestamp
FROM {{ source('ethereum_beacon_chain', 'fact_blocks') }}
WHERE block_included = TRUE
AND block_date >= ('{{ vars.CURATED_SL_CONTRACT_READS_START_DATE }}' :: TIMESTAMP) :: DATE
AND block_number IS NOT NULL
{% if is_incremental() %}
AND modified_timestamp >= (SELECT MAX(modified_timestamp) - INTERVAL '24 hours' FROM {{ this }} WHERE component = 'eigenpod')
{% endif %}
),
eigenpod_validators AS (
SELECT
slot_number,
LOWER('0x' || RIGHT(withdrawal_credentials, 40)) AS eigenpod_address,
balance
FROM {{ source('ethereum_beacon_chain', 'fact_validators') }}
WHERE LEFT(withdrawal_credentials, 4) = '0x01' -- Execution layer withdrawal credentials (funds go to an Ethereum address)
AND validator_status IN ('active_ongoing', 'pending_queued', 'pending_initialized', 'withdrawal_possible')
AND slot_number >= (SELECT MIN(slot_number) FROM beacon_blocks)
AND slot_number IS NOT NULL
{% if is_incremental() %}
AND modified_timestamp >= (SELECT MAX(modified_timestamp) - INTERVAL '24 hours' FROM {{ this }} WHERE component = 'eigenpod')
{% endif %}
),
eigenpod_tvl AS (
-- Native ETH Restaking via Beacon Chain Validators
SELECT
b.block_date,
b.block_number,
ep.eigenpod_address AS contract_address,
NULL AS address,
'0x0000000000000000000000000000000000000000' AS token_address, -- represents native ETH, for pricing purposes
NULL AS amount_hex,
SUM(ev.balance) * POW(10, 18) AS amount_raw,
'eigenpod' AS component,
MAX(b.modified_timestamp) AS _modified_timestamp
FROM {{ ref('silver_tvl__eigenlayer_v1_eigenpods') }} ep
INNER JOIN eigenpod_validators ev
ON ep.eigenpod_address = ev.eigenpod_address
INNER JOIN beacon_blocks b
ON ev.slot_number = b.slot_number
GROUP BY 1, 2, 3
-- Take latest slot per day per eigenpod
QUALIFY ROW_NUMBER() OVER (PARTITION BY block_date, contract_address ORDER BY _modified_timestamp DESC) = 1
),
strategy_tvl AS (
-- LST/ERC20 Token Restaking
SELECT
s.block_date,
s.block_number,
s.contract_address,
NULL AS address,
LOWER('0x' || RIGHT(LTRIM(t.result_hex, '0x'), 40)) AS token_address,
s.result_hex AS amount_hex,
IFNULL(
CASE WHEN LENGTH(s.result_hex) <= 4300 AND s.result_hex IS NOT NULL
THEN TRY_CAST(utils.udf_hex_to_int(s.result_hex) AS BIGINT) END,
CASE WHEN s.result_hex IS NOT NULL
THEN TRY_CAST(utils.udf_hex_to_int(RTRIM(s.result_hex, '0')) AS BIGINT) END
) AS amount_raw,
'strategy' AS component,
s._inserted_timestamp
FROM {{ ref('silver__contract_reads') }} s
LEFT JOIN {{ ref('silver__contract_reads') }} t
ON s.contract_address = t.contract_address
AND s.block_date = t.block_date
AND t.platform = 'eigenlayer-v1'
AND t.function_name = 'underlyingToken'
AND t.result_hex IS NOT NULL
AND LENGTH(t.result_hex) >= 42
WHERE s.platform = 'eigenlayer-v1'
AND s.function_name = 'totalShares'
AND s.result_hex IS NOT NULL
{% if is_incremental() %}
AND s.modified_timestamp > (SELECT MAX(modified_timestamp) FROM {{ this }} WHERE component = 'strategy')
{% endif %}
),
combined_tvl AS (
SELECT block_date, block_number, contract_address, address, token_address, amount_hex, amount_raw, component
FROM eigenpod_tvl
UNION ALL
SELECT block_date, block_number, contract_address, address, token_address, amount_hex, amount_raw, component
FROM strategy_tvl
)
SELECT
ct.block_number,
ct.block_date,
ct.contract_address,
ct.address,
ct.token_address,
ct.amount_hex,
ct.amount_raw,
'eigenlayer' AS protocol,
'v1' AS version,
'eigenlayer-v1' AS platform,
ct.component,
{{ dbt_utils.generate_surrogate_key(['ct.block_date','ct.contract_address','ct.token_address']) }} AS eigenlayer_v1_tvl_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM combined_tvl ct
WHERE ct.amount_raw IS NOT NULL AND ct.amount_raw > 0
QUALIFY ROW_NUMBER() OVER (PARTITION BY eigenlayer_v1_tvl_id ORDER BY ct.block_date DESC) = 1

View File

@ -0,0 +1,4 @@
version: 2
models:
- name: silver_tvl__eigenlayer_v1_tvl
description: '{{ doc("eigenlayer_v1_tvl_table_doc") }}'

View File

@ -0,0 +1,73 @@
{# Get variables #}
{% set vars = return_vars() %}
{# Log configuration details #}
{{ log_model_details() }}
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'ethena_v1_tvl_id',
tags = ['silver','defi','tvl','curated_daily']
) }}
-- Ethena TVL: totalSupply of USDe (sourced from stablecoins reads)
-- USDe: 0x4c9edd5852cd905f086c759e8383e09bff1e68b3
WITH reads AS (
SELECT
block_number,
block_date,
contract_address,
result_hex AS amount_hex,
IFNULL(
CASE
WHEN LENGTH(result_hex) <= 4300
AND result_hex IS NOT NULL THEN TRY_CAST(utils.udf_hex_to_int(result_hex) AS bigint)END,
CASE
WHEN result_hex IS NOT NULL THEN TRY_CAST(utils.udf_hex_to_int(RTRIM(result_hex, '0')) AS bigint)
END
) AS amount_raw,
_inserted_timestamp
FROM
{{ ref('silver__contract_reads') }}
WHERE
platform = 'stablecoins-v1'
AND function_name = 'totalSupply'
AND LOWER(contract_address) = LOWER('0x4c9edd5852cd905f086c759e8383e09bff1e68b3') -- USDe
AND result_hex IS NOT NULL
{% if is_incremental() %}
AND modified_timestamp > (
SELECT
MAX(modified_timestamp)
FROM
{{ this }}
)
{% endif %}
)
SELECT
block_number,
block_date,
contract_address,
NULL AS address,
contract_address AS token_address,
amount_hex,
amount_raw,
'ethena' AS protocol,
'v1' AS version,
CONCAT(
protocol,
'-',
version
) AS platform,
{{ dbt_utils.generate_surrogate_key(['block_date','contract_address','address','platform']) }} AS ethena_v1_tvl_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
reads
WHERE
amount_raw IS NOT NULL
AND amount_raw > 0 qualify ROW_NUMBER() over (
PARTITION BY ethena_v1_tvl_id
ORDER BY
modified_timestamp DESC
) = 1

View File

@ -0,0 +1,4 @@
version: 2
models:
- name: silver_tvl__ethena_v1_tvl
description: '{{ doc("ethena_v1_tvl_table_doc") }}'

View File

@ -58,7 +58,7 @@ SELECT
version,
platform,
{{ dbt_utils.generate_surrogate_key(
['block_date','contract_address','platform']
['block_date','contract_address','address','platform']
) }} AS lido_tvl_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,

View File

@ -0,0 +1,71 @@
{# Get variables #}
{% set vars = return_vars() %}
{# Log configuration details #}
{{ log_model_details() }}
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'morpho_blue_v1_tvl_id',
tags = ['silver','defi','tvl','curated_daily']
) }}
WITH reads AS (
SELECT
block_number,
block_date,
contract_address,
address,
result_hex AS amount_hex,
IFNULL(
CASE
WHEN LENGTH(result_hex) <= 4300
AND result_hex IS NOT NULL THEN TRY_CAST(utils.udf_hex_to_int(result_hex) AS bigint)END,
CASE
WHEN result_hex IS NOT NULL THEN TRY_CAST(utils.udf_hex_to_int(RTRIM(result_hex, '0')) AS bigint)
END
) AS amount_raw,
protocol,
version,
platform,
_inserted_timestamp
FROM
{{ ref('silver__contract_reads') }}
WHERE
platform = 'morpho-v1'
AND function_name = 'balanceOf'
AND result_hex IS NOT NULL
{% if is_incremental() %}
AND modified_timestamp > (
SELECT
MAX(modified_timestamp)
FROM
{{ this }}
)
{% endif %}
)
SELECT
block_number,
block_date,
contract_address,
address,
contract_address AS token_address,
amount_hex,
amount_raw,
protocol,
version,
platform,
{{ dbt_utils.generate_surrogate_key(['block_date','contract_address','address','platform']) }} AS morpho_blue_v1_tvl_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
reads
WHERE
amount_raw IS NOT NULL
AND amount_raw > 0 qualify ROW_NUMBER() over (
PARTITION BY morpho_blue_v1_tvl_id
ORDER BY
modified_timestamp DESC
) = 1

View File

@ -0,0 +1,4 @@
version: 2
models:
- name: silver_tvl__morpho_blue_v1_tvl
description: '{{ doc("morpho_blue_v1_tvl_table_doc") }}'

View File

@ -0,0 +1,69 @@
{# Get variables #}
{% set vars = return_vars() %}
{# Log configuration details #}
{{ log_model_details() }}
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'nado_v1_tvl_id',
tags = ['silver','defi','tvl','curated_daily']
) }}
WITH reads AS (
SELECT
block_number,
block_date,
contract_address,
address,
result_hex AS amount_hex,
IFNULL(
CASE
WHEN LENGTH(amount_hex) <= 4300
AND amount_hex IS NOT NULL THEN TRY_CAST(utils.udf_hex_to_int(amount_hex) AS bigint)END,
CASE
WHEN amount_hex IS NOT NULL THEN TRY_CAST(utils.udf_hex_to_int(RTRIM(amount_hex, '0')) AS bigint)
END
) AS amount_raw,
protocol,
version,
platform,
_inserted_timestamp
FROM
{{ ref('silver__contract_reads') }}
WHERE
platform = 'nado-v1'
AND amount_raw IS NOT NULL
{% if is_incremental() %}
AND modified_timestamp > (
SELECT
MAX(modified_timestamp)
FROM
{{ this }}
)
{% endif %}
)
SELECT
block_number,
block_date,
contract_address,
address,
contract_address AS token_address,
amount_hex,
amount_raw,
protocol,
version,
platform,
{{ dbt_utils.generate_surrogate_key(
['block_date','contract_address','address','platform']
) }} AS nado_v1_tvl_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
reads qualify(ROW_NUMBER() over(PARTITION BY nado_v1_tvl_id
ORDER BY
_inserted_timestamp DESC)) = 1

View File

@ -0,0 +1,4 @@
version: 2
models:
- name: silver_tvl__nado_v1_tvl
description: '{{ doc("nado_v1_tvl_table_doc") }}'

View File

@ -0,0 +1,69 @@
{# Get variables #}
{% set vars = return_vars() %}
{# Log configuration details #}
{{ log_model_details() }}
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'rocketpool_tvl_id',
tags = ['silver','defi','tvl','curated_daily']
) }}
WITH reads AS (
SELECT
block_number,
block_date,
contract_address,
address,
result_hex AS amount_hex,
IFNULL(
CASE
WHEN LENGTH(amount_hex) <= 4300
AND amount_hex IS NOT NULL THEN TRY_CAST(utils.udf_hex_to_int(amount_hex) AS bigint)END,
CASE
WHEN amount_hex IS NOT NULL THEN TRY_CAST(utils.udf_hex_to_int(RTRIM(amount_hex, '0')) AS bigint)
END
) AS amount_raw,
protocol,
version,
platform,
modified_timestamp
FROM
{{ ref('silver__contract_reads') }}
WHERE
platform = 'rocketpool-v1'
AND amount_raw IS NOT NULL
{% if is_incremental() %}
AND modified_timestamp > (
SELECT
MAX(modified_timestamp)
FROM
{{ this }}
)
{% endif %}
)
SELECT
block_number,
block_date,
contract_address,
address,
contract_address AS token_address,
amount_hex,
amount_raw,
protocol,
version,
platform,
{{ dbt_utils.generate_surrogate_key(
['block_date','contract_address','address','platform']
) }} AS rocketpool_tvl_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
reads qualify(ROW_NUMBER() over(PARTITION BY rocketpool_tvl_id
ORDER BY
modified_timestamp DESC)) = 1

View File

@ -0,0 +1,4 @@
version: 2
models:
- name: silver_tvl__rocketpool_v1_tvl
description: '{{ doc("rocketpool_v1_tvl_table_doc") }}'

View File

@ -21,13 +21,23 @@
(ref('silver_tvl__superchain_slipstream_v1_tvl'), 12, 'superchain-slipstream-v1'),
(ref('silver_tvl__binance_v1_tvl'), 12, 'binance-v1'),
(ref('silver_tvl__curve_v1_tvl'), 10, 'curve-v1'),
(ref('silver_tvl__eigenlayer_v1_tvl'), 12, 'eigenlayer-v1'),
(ref('silver_tvl__ethena_v1_tvl'), 12, 'ethena-v1'),
(ref('silver_tvl__etherfi_v1_tvl_agg'), 12, 'etherfi-v1'),
(ref('silver_tvl__lido_v1_tvl'), 12, 'lido-v1'),
(ref('silver_tvl__rocketpool_v1_tvl'), 12, 'rocketpool-v1'),
(ref('silver_tvl__sky_v1_tvl'), 12, 'sky-v1'),
(ref('silver_tvl__tornado_cash_v1_tvl'), 9, 'tornado_cash-v1'),
(ref('silver_tvl__uniswap_v1_tvl'), 9, 'uniswap-v1'),
(ref('silver_tvl__uniswap_v2_tvl'), 9, 'uniswap-v2'),
(ref('silver_tvl__uniswap_v3_tvl'), 9, 'uniswap-v3'),
(ref('silver_tvl__uniswap_v4_tvl'), 9, 'uniswap-v4')
(ref('silver_tvl__uniswap_v4_tvl'), 9, 'uniswap-v4'),
(ref('silver_tvl__morpho_blue_v1_tvl'), 12, 'morpho-v1'),
(ref('silver_tvl__compound_v1_tvl'), 12, 'compound-v1'),
(ref('silver_tvl__compound_v2_tvl'), 12, 'compound-v2'),
(ref('silver_tvl__compound_v3_tvl'), 12, 'compound-v3'),
(ref('silver_tvl__nado_v1_tvl'), 12, 'nado-v1'),
(ref('silver_tvl__polymarket_v1_tvl'), 12, 'polymarket-v1')
] %}
WITH all_tvl AS (

View File

@ -0,0 +1,73 @@
{# Get variables #}
{% set vars = return_vars() %}
{# Log configuration details #}
{{ log_model_details() }}
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'sky_v1_tvl_id',
tags = ['silver','defi','tvl','curated_daily']
) }}
WITH reads AS (
SELECT
block_number,
block_date,
contract_address,
address,
result_hex AS amount_hex,
IFNULL(
CASE
WHEN LENGTH(result_hex) <= 4300
AND result_hex IS NOT NULL THEN TRY_CAST(utils.udf_hex_to_int(result_hex) AS BIGINT)
END,
CASE
WHEN result_hex IS NOT NULL THEN TRY_CAST(utils.udf_hex_to_int(RTRIM(result_hex, '0')) AS BIGINT)
END
) AS amount_raw,
protocol,
version,
platform,
modified_timestamp
FROM
{{ ref('silver__contract_reads') }}
WHERE
platform = 'sky-v1'
AND result_hex IS NOT NULL
{% if is_incremental() %}
AND modified_timestamp > (
SELECT
MAX(modified_timestamp)
FROM
{{ this }}
)
{% endif %}
)
SELECT
block_number,
block_date,
contract_address,
address,
contract_address AS token_address,
amount_hex,
amount_raw,
protocol,
version,
platform,
{{ dbt_utils.generate_surrogate_key(['block_date','contract_address','address','platform']) }} AS sky_v1_tvl_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
reads
WHERE
amount_raw IS NOT NULL
AND amount_raw > 0
QUALIFY ROW_NUMBER() OVER (
PARTITION BY sky_v1_tvl_id
ORDER BY modified_timestamp DESC
) = 1

View File

@ -0,0 +1,4 @@
version: 2
models:
- name: silver_tvl__sky_v1_tvl
description: '{{ doc("sky_v1_tvl_table_doc") }}'

View File

@ -113,7 +113,7 @@ SELECT
version,
platform,
{{ dbt_utils.generate_surrogate_key(
['block_date','contract_address','platform']
['block_date','contract_address','address','platform']
) }} AS uniswap_v2_tvl_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,

View File

@ -92,7 +92,7 @@ FINAL AS (
ELSE 'spot'
END AS product_type,
CASE
WHEN p.product_id = 0 THEN 'USDC'
WHEN p.product_id = 0 THEN 'USDT0'
ELSE p.ticker_id :: STRING
END AS ticker_id,
p.symbol :: STRING AS symbol,

View File

@ -101,4 +101,69 @@ Sums getReserves() values for token0 and token1 across all AMM pools
Methodology:
Sums token0 and token1 balances held by each Slipstream (CL) pool contract via balanceOf()
{% enddocs %}
{% docs eigenlayer_v1_tvl_table_doc %}
Methodology:
Sums (1) native ETH restaked via EigenPods by matching PodDeployed events with beacon chain validator balances and (2) LST/ERC20 tokens deposited in strategy contracts via totalShares()
{% enddocs %}
{% docs ethena_v1_tvl_table_doc %}
Methodology:
Total supply of USDe (synthetic dollar)
{% enddocs %}
{% docs morpho_blue_v1_tvl_table_doc %}
Methodology:
Sums balanceOf each unique token (collateralToken + loanToken from CreateMarket events) held by the MorphoBlue singleton contract
{% enddocs %}
{% docs rocketpool_v1_tvl_table_doc %}
Methodology:
Total supply of rETH (Rocket Pool's liquid staking token representing staked ETH)
Note: This represents the liquid staking portion only. Other methodologies may report additional TVL (operator-staked funds) by including node operator collateral (nodeEthProvided), matched ETH from the deposit pool, and pending deposits.
{% enddocs %}
{% docs compound_v1_tvl_table_doc %}
Methodology:
Sums all token balances held by the MoneyMarket contract (0x3FDA67f7583380E67ef93072294a7fAc882FD7E7) via balanceOf(). Collateral markets are discovered dynamically via collateralMarkets() calls.
{% enddocs %}
{% docs compound_v2_tvl_table_doc %}
Methodology:
Sums all underlying token balances held by each cToken contract via balanceOf()
{% enddocs %}
{% docs compound_v3_tvl_table_doc %}
Methodology:
Sums balanceOf() for base tokens + all collateral assets held by each Comet market contract. Collateral assets are discovered dynamically via getAssetInfo() calls.
{% enddocs %}
{% docs sky_v1_tvl_table_doc %}
Methodology:
Sums balanceOf() for collateral tokens held by each collateral join contract (discovered via MCD_VAT rely events and gem() calls) plus USDC held by the PSM wallet.
{% enddocs %}
{% docs nado_v1_tvl_table_doc %}
Methodology:
Sums ERC20 token balances across clearinghouse and endpoint contracts
{% enddocs %}

View File

@ -7,7 +7,7 @@ All available Nado products, these are automatically added as they are released
{% docs nado_money_markets %}
Nado integrates a decentralized money market directly into its DEX, enabling borrowing and lending of crypto assets using overcollateralized lending rules. Interest rates are dynamically adjusted based on supply and demand, incentivizing liquidity provision and balancing borrowing costs. The money market operates on-chain (e.g., on Arbitrum) and is managed through Nados risk engine and clearinghouse, offering users automated borrowing via portfolio margin and passive yield opportunities on idle assets. This table tracks the money market products available on Nado on an hourly basis.
Nado integrates a decentralized money market directly into its DEX, enabling borrowing and lending of crypto assets using overcollateralized lending rules. Interest rates are dynamically adjusted based on supply and demand, incentivizing liquidity provision and balancing borrowing costs. The money market operates on-chain (e.g., on Ink) and is managed through Nados risk engine and clearinghouse, offering users automated borrowing via portfolio margin and passive yield opportunities on idle assets. This table tracks the money market products available on Nado on an hourly basis.
{% enddocs %}
@ -21,7 +21,7 @@ All Nado liquidations. Once an accounts maintenance margin reaches $0, the ac
{% docs nado_perp_trades %}
Nado perpetuals are derivative contracts on an underlying spot asset. On Nado, all perpetual contracts trade against USDC.
Nado perpetuals are derivative contracts on an underlying spot asset. On Nado, all perpetual contracts trade against USDT0.
**Important: Volume Calculation**
Each trade match emits **two** FillOrder events on-chain: one for the maker and one for the taker (each with their own order digest). To calculate accurate volume or trade counts that match Nado's official API metrics, filter to `is_taker = TRUE` to avoid double-counting.
@ -193,25 +193,25 @@ The fees on the trade, decimal adjusted. All amounts and prices are adjusted 18
{% docs nado_base_delta_amount_unadj %}
Represents the net change in the total quantity of orders at a particular price level, the sum of these across the same digest is equal to the amount. This is the first currency listed in the pair and acts as the reference point for the exchange rate, in this case the crypto asset trading against USDC.
Represents the net change in the total quantity of orders at a particular price level, the sum of these across the same digest is equal to the amount. This is the first currency listed in the pair and acts as the reference point for the exchange rate, in this case the crypto asset trading against USDT0.
{% enddocs %}
{% docs nado_base_delta_amount %}
Represents the net change in the total quantity of orders at a particular price level, decimal adjusted. All amounts and prices are adjusted 18 decimals points regardless of underlying asset contract. The sum of these across the same digest is equal to the amount. This is the first currency listed in the pair and acts as the reference point for the exchange rate, in this case the crypto asset trading against USDC.
Represents the net change in the total quantity of orders at a particular price level, decimal adjusted. All amounts and prices are adjusted 18 decimals points regardless of underlying asset contract. The sum of these across the same digest is equal to the amount. This is the first currency listed in the pair and acts as the reference point for the exchange rate, in this case the crypto asset trading against USDT0.
{% enddocs %}
{% docs nado_quote_delta_amount_unadj %}
A positive value is an increase in spread and a negative value is a decrease in spread. Quote is currency used to express the value of the base currency. It's often the more well-known or stable currency in the pair. In this case, USDC.
A positive value is an increase in spread and a negative value is a decrease in spread. Quote is currency used to express the value of the base currency. It's often the more well-known or stable currency in the pair. In this case, USDT0.
{% enddocs %}
{% docs nado_quote_delta_amount %}
The net change in the best bid and best ask prices in the order book, decimal adjusted. All amounts and prices are adjusted 18 decimals points regardless of underlying asset contract. A positive value is an increase in spread and a negative value is a decrease in spread. Quote is currency used to express the value of the base currency. It's often the more well-known or stable currency in the pair. In this case, USDC.
The net change in the best bid and best ask prices in the order book, decimal adjusted. All amounts and prices are adjusted 18 decimals points regardless of underlying asset contract. A positive value is an increase in spread and a negative value is a decrease in spread. Quote is currency used to express the value of the base currency. It's often the more well-known or stable currency in the pair. In this case, USDT0.
{% enddocs %}
@ -237,19 +237,19 @@ The token symbol represented by the specific health group. For example WBTC and
{% docs nado_amount_quote_unadj %}
To liquidate a position, there must be a payment (transfer) between the liquidator and the position holder. This done in the quote currency, USDC. Payments are signed as positive, meaning you received the USDC, or negative, meaning you paid. For perpetual liquidations, users should expect to see a (+) USDC payment. They will see a (-) USDC payment for borrowers since they need to pay the user for buying their borrow.
To liquidate a position, there must be a payment (transfer) between the liquidator and the position holder. This done in the quote currency, USDT0. Payments are signed as positive, meaning you received the USDT0, or negative, meaning you paid. For perpetual liquidations, users should expect to see a (+) USDT0 payment. They will see a (-) USDT0 payment for borrowers since they need to pay the user for buying their borrow.
{% enddocs %}
{% docs nado_amount_quote %}
To liquidate a position, there must be a payment (transfer) between the liquidator and the position holder. This done in the quote currency, USDC. Payments are signed as positive, meaning you received the USDC, or negative, meaning you paid. For perpetual liquidations, users should expect to see a (+) USDC payment. They will see a (-) USDC payment for borrowers since they need to pay the user for buying their borrow. All amounts and prices are adjusted 18 decimals points regardless of underlying asset contract.
To liquidate a position, there must be a payment (transfer) between the liquidator and the position holder. This done in the quote currency, USDT0. Payments are signed as positive, meaning you received the USDT0, or negative, meaning you paid. For perpetual liquidations, users should expect to see a (+) USDT0 payment. They will see a (-) USDT0 payment for borrowers since they need to pay the user for buying their borrow. All amounts and prices are adjusted 18 decimals points regardless of underlying asset contract.
{% enddocs %}
{% docs nado_insurance_cover_unadj %}
USDC from the insurance fund pulled into the insolvent account and used to pay liquidators to take on the underwater positions.
USDT0 from the insurance fund pulled into the insolvent account and used to pay liquidators to take on the underwater positions.
Only available in Nado V1, live until March 8th 2024.
@ -257,7 +257,7 @@ Only available in Nado V1, live until March 8th 2024.
{% docs nado_insurance_cover %}
USDC from the insurance fund pulled into the insolvent account and used to pay liquidators to take on the underwater positions, decimal adjusted. All amounts and prices are adjusted 18 decimals points regardless of underlying asset contract.
USDT0 from the insurance fund pulled into the insolvent account and used to pay liquidators to take on the underwater positions, decimal adjusted. All amounts and prices are adjusted 18 decimals points regardless of underlying asset contract.
Only available in Nado V1, live until March 8th 2024.

View File

@ -159,4 +159,11 @@ sources:
database: monad
schema: gov
tables:
- name: gov__ez_staking_balances_daily
- name: gov__ez_staking_balances_daily
- name: ethereum_beacon_chain
database: >-
{{ 'ETHEREUM_DEV' if '_DEV' in target.database.upper() else 'ETHEREUM' }}
schema: beacon_chain
tables:
- name: fact_validators
- name: fact_blocks