therealestberafailcountandpercentage
    Updated 2024-08-25
    -- forked from 1. TX history with details FINAL LAST VERSION @ https://flipsidecrypto.xyz/studio/queries/98ff20de-90a8-46cb-b6f9-dd8fbdce62ea

    WITH tx_data AS (
    SELECT
    BLOCK_NUMBER,
    POSITION,
    BLOCK_TIMESTAMP,
    TX_HASH,
    FROM_ADDRESS,
    VALUE,
    TX_SUCCEEDED
    FROM berachain.testnet.fact_transactions
    WHERE TO_ADDRESS = LOWER('0x14D65204c710997F595F4663f0451b66d3532f53')
    AND ORIGIN_FUNCTION_SIGNATURE = '0x8bbefe4b'
    ORDER BY BLOCK_NUMBER, POSITION ASC
    ),
    rounds AS (
    SELECT
    BLOCK_NUMBER,
    BLOCK_TIMESTAMP,
    TX_HASH,
    CONCAT('0x', SUBSTR(TOPICS[1], 27, 64)) AS FROM_ADDRESS,
    (utils.udf_hex_to_int(SUBSTR(data, 67, 64))::int) / 1e18 AS pot_before,
    (utils.udf_hex_to_int(SUBSTR(data, 131, 64))::int) / 1e18 AS pot_after,
    utils.udf_hex_to_int(SUBSTR(data, 323, 64))::int AS yeet_count,
    utils.udf_hex_to_int(SUBSTR(data, 387, 64))::int AS yeet_round
    FROM berachain.testnet.fact_event_logs
    WHERE ORIGIN_TO_ADDRESS = LOWER('0x14D65204c710997F595F4663f0451b66d3532f53')
    AND ORIGIN_FUNCTION_SIGNATURE = '0x8bbefe4b'
    AND utils.udf_hex_to_int(SUBSTR(data, 323, 64))::int IS NOT NULL
    ),
    combined_data AS (
    SELECT
    t1.BLOCK_NUMBER,
    t1.POSITION,
    t1.BLOCK_TIMESTAMP,
    QueryRunArchived: QueryRun has been archived