Updated 2024-09-30
    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
    FROM
    berachain.testnet.fact_traces
    WHERE
    tx_hash = '0xfb966e27aa30092348d570f8b71745813294be20469824e2910a35ff40f8f096'
    AND to_address IN (
    LOWER('{{token0}}'),
    LOWER('{{token1}}'),
    LOWER('{{lp_address}}')
    )
    AND tx_succeeded = true
    QueryRunArchived: QueryRun has been archived