Updated 2024-10-01
    WITH relevant_txs AS (
    SELECT
    DISTINCT tx_hash,
    left(input, 10) as function_sig
    FROM
    berachain.testnet.fact_traces
    WHERE
    to_address = LOWER('{{lp_address}}')
    AND tx_succeeded = true
    AND block_timestamp BETWEEN '2024-09-19 4:59:59.000' AND '2024-09-19 5:59:59.000'
    AND function_sig NOT IN ('0x095ea7b3')
    AND tx_hash = '0x7f6dc98be8101633c9b91fe63a537463f4eda9fe9b6d35b5e829891d972ee260'
    LIMIT
    1000
    )
    SELECT
    block_timestamp,
    tx_hash,
    from_address,
    to_address,
    left(input, 10) as function_sig,
    utils.udf_hex_to_int(
    CASE
    WHEN to_address = LOWER('{{lp_address}}') THEN regexp_substr_all(SUBSTR(input, 11), '.{64}') [4]
    ELSE COALESCE(
    NULLIF(
    regexp_substr_all(SUBSTR(input, 11), '.{64}') [2],
    ''
    ),
    regexp_substr_all(SUBSTR(input, 11), '.{64}') [1]
    )
    END :: string
    ) as token_value,
    token_value / POW(10,18) as raw_value
    FROM
    berachain.testnet.fact_traces
    QueryRunArchived: QueryRun has been archived