tkvresearchupset-harlequin
    Updated 14 hours ago

    with delegate_data as
    (select
    BLOCK_TIMESTAMP,
    TX_HASH,
    '0x' || SUBSTR(PARSE_JSON(TOPICS)[1]::string, -40) AS user_wallet,
    -- '0x' || SUBSTR(PARSE_JSON(TOPICS)[2]::string, -40) AS validator_address,
    TOPICS,
    utils.udf_hex_to_int(DATA)/power(10,18) as data_raw
    FROM berachain.testnet.fact_event_logs
    where ORIGIN_TO_ADDRESS = '0xbda130737bdd9618301681329bf2e46a016ff9ad'
    and
    contract_address = '0xbda130737bdd9618301681329bf2e46a016ff9ad'
    and
    TX_SUCCEEDED = 'TRUE'
    and
    ORIGIN_FUNCTION_SIGNATURE = '0x95c0e232'),

    undelegate_data as (
    select
    BLOCK_TIMESTAMP,
    TX_HASH,
    '0x' || SUBSTR(PARSE_JSON(TOPICS)[1]::string, -40) AS user_wallet,
    -- '0x' || SUBSTR(PARSE_JSON(TOPICS)[2]::string, -40) AS validator_address,
    TOPICS,
    utils.udf_hex_to_int(DATA)/power(10,18) as data_raw
    FROM berachain.testnet.fact_event_logs
    where
    ORIGIN_TO_ADDRESS = '0xbda130737bdd9618301681329bf2e46a016ff9ad'
    and
    contract_address = '0xbda130737bdd9618301681329bf2e46a016ff9ad'
    and
    TX_SUCCEEDED = 'TRUE'
    and
    ORIGIN_FUNCTION_SIGNATURE = '0xe1f63d2e'
    ),