check for testing

This commit is contained in:
Eric Laurello 2026-01-21 16:20:23 -05:00
parent 6478eaa3ce
commit 56b20fbf23
2 changed files with 93 additions and 0 deletions

View File

@ -0,0 +1,89 @@
{# Get variables #}
{% set vars = return_vars() %}
{# Log configuration details #}
{{ log_model_details() }}
{{ config(
materialized = 'table',
unique_key = 'monad_delegator_rewards_reads_id',
tags = ['silver', 'contract_reads', 'gov']
) }}
/*
Generates contract read specifications for getDelegator calls.
Pulls unclaimed rewards for all active delegator/validator ID combos.
Function: getDelegator(uint64 validatorId, address delegator)
Selector: 0x573c1ce0
Contract: 0x0000000000000000000000000000000000001000 (Monad staking precompile)
Returns:
- stake (uint256): Current active stake
- accRewardPerToken (uint256): Last checked accumulator
- unclaimedRewards (uint256): Unclaimed delegator rewards
- deltaStake (uint256): Stake to be activated next epoch
- nextDeltaStake (uint256): Stake to be activated in 2 epochs
- deltaEpoch (uint64): Epoch when deltaStake becomes active
- nextDeltaEpoch (uint64): Epoch when nextDeltaStake becomes active
*/
WITH active_delegators AS (
SELECT DISTINCT
validator_id,
delegator_address
FROM
{{ ref('gov__ez_staking_balances_daily') }}
WHERE
active_balance > 0
AND balance_date => (
SELECT MAX(balance_date)
FROM {{ ref('gov__ez_staking_balances_daily') }}
)-2
),
delegator_reads AS (
SELECT
validator_id,
delegator_address,
-- getDelegator(uint64 validatorId, address delegator)
-- Selector: 0x573c1ce0
-- validatorId: uint64 padded to 32 bytes
-- delegator: address padded to 32 bytes
CONCAT(
'0x573c1ce0',
LPAD(LTRIM(utils.udf_int_to_hex(validator_id), '0x'), 64, '0'),
LPAD(LTRIM(delegator_address, '0x'), 64, '0')
) AS input
FROM
active_delegators
limit 100
)
SELECT
'0x0000000000000000000000000000000000001000' AS contract_address,
NULL AS address,
'getDelegator' AS function_name,
'0x573c1ce0' AS function_sig,
input,
OBJECT_CONSTRUCT(
'validator_id', validator_id,
'delegator_address', delegator_address
) :: VARIANT AS metadata,
'monad_staking' AS protocol,
'v1' AS version,
CONCAT(protocol, '-', version) AS platform,
{{ dbt_utils.generate_surrogate_key(
['contract_address', 'input', 'platform']
) }} AS monad_delegator_rewards_reads_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
delegator_reads
{# {% if is_incremental() %}
WHERE input NOT IN (
SELECT input
FROM {{ this }}
)
{% endif %} #}

View File

@ -26,6 +26,9 @@
{% if vars.GLOBAL_PROJECT_NAME == 'polygon' %}
{% set _ = models.append((ref('silver_reads__polymarket_v1_reads'), 'daily')) %}
{% endif %}
{% if vars.GLOBAL_PROJECT_NAME == 'monad' %}
{% set _ = models.append((ref('silver_reads__monad_delegator_reads'), 'daily')) %}
{% endif %}
{% set _ = models.append((ref('silver_reads__aerodrome_v1_reads'), 'daily')) %}
{% set _ = models.append((ref('silver_reads__superchain_slipstream_v1_reads'), 'daily')) %}
{% set _ = models.append((ref('silver_reads__stablecoins_reads'), 'daily')) %}
@ -39,6 +42,7 @@
{% set _ = models.append((ref('silver_reads__tornado_cash_v1_reads'), 'daily')) %}
{% set _ = models.append((ref('silver_reads__etherfi_v1_reads'), 'daily')) %}
WITH all_records AS (
{% for model, type in models %}
SELECT