cloudr3nCapybara DEX Swap Volume
    Updated 2024-10-02
    with
    pools AS (
    -- Get data from target query
    SELECT
    value:POOL_ADDRESS::string AS pool_address
    FROM (
    SELECT
    livequery.live.udf_api('https://flipsidecrypto.xyz/api/v1/queries/15ad3389-f2bc-4806-be2d-c93f507480d1/data/latest') as response
    ), lateral FLATTEN (input => response:data)
    ),

    swap_base as (
    select
    block_number,
    block_timestamp,
    tx_hash,
    origin_function_signature,
    origin_from_address,
    origin_to_address,
    event_index,
    contract_address,
    regexp_substr_all(SUBSTR(data, 3, len(data)), '.{64}') AS l_segmented_data,
    CONCAT('0x', SUBSTR(l.topics [1] :: STRING, 27, 40)) AS sender_address,
    CONCAT('0x', SUBSTR(l.topics [2] :: STRING, 27, 40)) AS to_address,
    CONCAT(
    '0x',
    SUBSTR(
    l_segmented_data [0] :: STRING,
    25,
    40
    )
    ) AS fromToken,
    CONCAT(
    '0x',
    SUBSTR(
    l_segmented_data [1] :: STRING,
    QueryRunArchived: QueryRun has been archived