Sandeshnekodex swaps markets
    Updated 2024-08-26
    -- forked from nekodex swaps base @ https://flipsidecrypto.xyz/studio/queries/f3621e82-279f-428d-b627-08add604f97a

    with trades_decodes_table
    as
    (
    with optimism_table as (
    with intrachain_swaps AS (
    select
    tx_hash,
    block_timestamp,
    regexp_substr_all(SUBSTR(data, 3), '.{64}') AS segmented,
    concat('0x', substr(topics [1], -40)) as user,
    10 as from_chainID,
    10 as to_chainID,
    concat('0x', substr(segmented [0], -40)) as from_token,
    concat('0x', substr(segmented [2], -40)) as from_token_value,
    utils.udf_hex_to_int(from_token_value) as from_token_value_int,
    concat('0x', substr(segmented [1], -40)) as to_token,
    concat('0x', substr(segmented [3], -40)) as to_token_value,
    utils.udf_hex_to_int(to_token_value) as to_token_value_int
    from
    optimism.core.fact_event_logs
    where
    1 = 1
    and contract_address = '0x6cca65f0bc3140019a81a1619aa75a6925c2601e'
    and topics [0] = '0x900d96b4c36401fe685c5409d45d609db06c639ef658c6cfef098061d05aadc9'
    and origin_from_address = '0xd19454648eedd9bee8d75142d503c5ee9179fc70'
    -- and block_timestamp >= current_date - 30
    ),
    interchain_swaps as (
    select
    tx_hash,
    block_timestamp,
    regexp_substr_all(SUBSTR(data, 3), '.{64}') AS segmented,
    concat('0x', substr(topics [3], -40)) as user,
    QueryRunArchived: QueryRun has been archived