Query editor
-- =============================================================================-- KILN STAKING DASHBOARD - NET CUMULATIVE STAKE OVER TIME-- =============================================================================---- METHODOLOGY:---- 1. TRACKING DEPOSITS:-- - Kiln uses a batch deposit contract (0x576834cB068e677db4aFF6ca245c7bde16C3867e)-- to stake ETH on behalf of their clients-- - This contract sends ETH to the Beacon Deposit Contract-- (0x00000000219ab540356cbb839cbe05303d7705fa)-- - We track deposits by filtering ethereum.traces for transactions where:-- * FROM = Kiln batch contract-- * TO = Beacon Deposit Contract-- * Value > 0 (actual ETH transferred)---- 2. LINKING DEPOSITS TO VALIDATORS:-- - Each deposit emits a DepositEvent log (topic0 = 0x649bbc62d0e31342...)-- - The validator's public key (48 bytes) is encoded in the log data at position 193-- - We extract these pubkeys to identify which validators belong to Kiln---- 3. MAPPING PUBKEYS TO VALIDATOR INDICES:-- - The beacon.validators table maps public_key -> index (validator_index)-- - We need the validator_index to track withdrawals/exits---- 4. TRACKING EXITS:-- - When validators exit, ETH is withdrawn to the withdrawal address (not the batch contract)-- - The ethereum.withdrawals table records which validator_index withdrew and how much-- - Full exits are identified by withdrawals >= 32 ETH-- - We filter withdrawals to only include validator_indices that belong to Kiln---- 5. WHY THIS APPROACH WORKS:-- - Even though exits go to different withdrawal addresses (controlled by stakers),-- we can still attribute them to Kiln because we tracked the original deposit-- and know which validator pubkeys/indices were created through their batch contract---- =============================================================================-- STEP 1: Get all validator pubkeys deposited through Kiln's batch contractWITH kiln_pubkeys AS (SELECT DISTINCTBYTEARRAY_SUBSTRING(l.data, 193, 48) AS validator_pubkeyFROM ethereum.logs AS lWHERE l.contract_address = 0x00000000219ab540356cbb839cbe05303d7705fa -- Beacon Deposit ContractAND l.topic0 = 0x649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5 -- DepositEvent signatureAND l.tx_hash IN (-- Filter for transactions originating from Kiln's batch contractSELECT t.tx_hashFROM ethereum.traces AS tWHERE t."from" = 0x576834cB068e677db4aFF6ca245c7bde16C3867e -- Kiln batch contractAND t.to = 0x00000000219ab540356cbb839cbe05303d7705fa -- Beacon Deposit ContractAND t.value > 0AND t.success = TRUE)),-- STEP 2: Map pubkeys to validator indices using beacon.validatorskiln_validator_indices AS (SELECT v.index AS validator_indexFROM beacon.validators AS v