flyingfish2023-02-15 04:45 PM
    Updated 2023-02-18

    WITH pool_detais AS (
    SELECT
    lower('0xc0F05732D1cDa6f59487ceeef4390aBcaD86Ea3E') AS pool_address
    , lower('0x7f465507f058e17ad21623927a120ac05ca32741') AS token0_address
    , (SELECT symbol FROM arbitrum.core.dim_contracts WHERE address = lower('0x7f465507f058e17ad21623927a120ac05ca32741')) AS token0_symbol
    , (SELECT decimals FROM arbitrum.core.dim_contracts WHERE address = lower('0x7f465507f058e17ad21623927a120ac05ca32741')) AS token0_decimals
    , '0x82af49447d8a07e3bd95bd0d56f35241523fbab1' AS token1_address
    , (SELECT symbol FROM arbitrum.core.dim_contracts WHERE address = lower('0x82af49447d8a07e3bd95bd0d56f35241523fbab1')) AS token1_symbol
    , (SELECT decimals FROM arbitrum.core.dim_contracts WHERE address = lower('0x82af49447d8a07e3bd95bd0d56f35241523fbab1')) AS token1_decimals
    , token0_symbol || '-' || token1_symbol AS pool_name
    ),
    swap_events AS (
    SELECT
    block_number,
    origin_function_signature,
    origin_from_address,
    origin_to_address,
    block_timestamp,
    tx_hash,
    contract_address,
    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
    -- ) :: INTEGER
    -- ) AS amount0In,
    -- TRY_TO_NUMBER(
    -- ethereum.public.udf_hex_to_int(
    -- segmented_data [1] :: STRING
    -- ) :: INTEGER
    -- ) AS amount1In,
    -- TRY_TO_NUMBER(
    -- ethereum.public.udf_hex_to_int(
    -- segmented_data [2] :: STRING
    Run a query to Download Data