SajjadiiiTotal Numbers
    Updated 2025-03-17
    with uniswap_pools_tab AS (
    SELECT
    PAIR AS pool_name
    ,Pool_contract AS pool_address
    ,SYMBOL0 AS symbol0
    ,SYMBOL1 AS symbol1
    ,TOKEN_CONTRACT0 AS token0_address
    ,TOKEN_CONTRACT1 AS token1_address
    ,DECIMAL0 AS decimal0
    ,DECIMAL1 AS decimal1
    FROM $query('6b11ca05-f0b9-4c2f-8534-0205284bc906')

    ),


    dim_pool_label AS (
    SELECT DISTINCT token0_address AS token_address , symbol0 AS symbol, decimal0 AS decimal FROM uniswap_pools_tab
    UNION all
    SELECT DISTINCT token1_address AS token_address , symbol1 AS symbol, decimal1 AS decimal FROM uniswap_pools_tab

    ),
    swap_events AS (
    SELECT
    block_number,
    origin_function_signature,
    origin_from_address,
    origin_to_address,
    block_timestamp,
    tx_hash,
    contract_address,
    'Swap' AS event_name,
    regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data,
    TRY_TO_NUMBER(ethereum.public.udf_hex_to_int(segmented_data [0] :: STRING)) AS amount0In,
    TRY_TO_NUMBER(ethereum.public.udf_hex_to_int(segmented_data [1] :: STRING)) AS amount1In,
    TRY_TO_NUMBER(ethereum.public.udf_hex_to_int(segmented_data [2] :: STRING)) AS amount0Out,
    TRY_TO_NUMBER(ethereum.public.udf_hex_to_int(segmented_data [3] :: STRING)) AS amount1Out,
    QueryRunArchived: QueryRun has been archived