Sandeshnekodex swaps
    Updated 2024-08-23
    with trades_decodes_table as (
    with optimism_trades as (
    select
    tx_hash,
    block_timestamp,
    regexp_substr_all(SUBSTR(input, 11), '.{64}') AS segmented,
    concat('0x', substr(segmented [4], -40)) as user,
    utils.udf_hex_to_int(substr(segmented [6], -40)) as from_chainID,
    utils.udf_hex_to_int(substr(segmented [18], -40)) as to_chainID,
    concat('0x', substr(segmented [12], -40)) as from_token,
    concat('0x', substr(segmented [13], -40)) as from_token_value,
    utils.udf_hex_to_int(from_token_value) as from_token_value_int,
    concat('0x', substr(segmented [14], -40)) as to_token,
    concat('0x', substr(segmented [15], -40)) as to_token_value,
    utils.udf_hex_to_int(to_token_value) as to_token_value_int
    from
    optimism.core.fact_traces
    where
    1 = 1
    and block_number >= '121593991' -- jun 19 2024
    and identifier = 'CALL_ORIGIN'
    and to_address = '0x6cca65f0bc3140019a81a1619aa75a6925c2601e'
    and TX_STATUS = 'SUCCESS'
    ),
    ethereum_trades as (
    select
    tx_hash,
    block_timestamp,
    regexp_substr_all(SUBSTR(input, 11), '.{64}') AS segmented,
    concat('0x', substr(segmented [4], -40)) as user,
    utils.udf_hex_to_int(substr(segmented [6], -40)) as from_chainID,
    utils.udf_hex_to_int(substr(segmented [18], -40)) as to_chainID,
    concat('0x', substr(segmented [12], -40)) as from_token,
    concat('0x', substr(segmented [13], -40)) as from_token_value,
    utils.udf_hex_to_int(from_token_value) as from_token_value_int,
    concat('0x', substr(segmented [14], -40)) as to_token,
    QueryRunArchived: QueryRun has been archived