Query editor
-- =============================================================================-- FIGMENT STAKING DASHBOARD - NET CUMULATIVE STAKE OVER TIME-- =============================================================================---- METHODOLOGY:---- 1. TRACKING DEPOSITS:-- - Figment uses TWO batch deposit contracts:-- * 0x8b0d88b8be3c15d746feb0b1f18c883c03b6aa62 - For 0x02 withdrawal credential validators-- * 0xF0075B3Cf8953d3E23b0eF65960913Fd97eb5227 - For 0x01 withdrawal credential validators-- - These contracts send ETH to the Beacon Deposit Contract-- (0x00000000219ab540356cbb839cbe05303d7705fa)-- - We track deposits by filtering ethereum.traces for transactions where:-- * FROM = Either Figment 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 Figment---- 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 Figment---- 5. WHY THIS APPROACH WORKS:-- - Even though exits go to different withdrawal addresses (controlled by stakers),-- we can still attribute them to Figment because we tracked the original deposit-- and know which validator pubkeys/indices were created through their batch contracts---- 6. NOTE ON WITHDRAWAL CREDENTIALS:-- - 0x01 credentials: Original format, withdrawal address is embedded in credentials-- - 0x02 credentials: New format post-Pectra upgrade, enhanced functionality-- - Figment maintains separate batch contracts for each type---- =============================================================================-- STEP 1: Get all validator pubkeys deposited through Figment's batch contractsWITH figment_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 either Figment batch contractSELECT t.tx_hashFROM ethereum.traces AS tWHERE t."from" IN (0x8b0d88b8be3c15d746feb0b1f18c883c03b6aa62, -- Figment 0x02 validators batch contract0xF0075B3Cf8953d3E23b0eF65960913Fd97eb5227 -- Figment 0x01 validators batch contract)AND t.to = 0x00000000219ab540356cbb839cbe05303d7705fa -- Beacon Deposit Contract