gigiokobapleased-aquamarine
    Updated 2025-02-08
    WITH target_swaps AS (
    SELECT
    TX_HASH,
    BLOCK_TIMESTAMP,
    CASE
    WHEN LOWER(ORIGIN_FROM_ADDRESS) = LOWER('0xEa34479f7d95341E5fd49b89936366D6da710824')
    THEN 'Sold'
    WHEN LOWER(ORIGIN_TO_ADDRESS) = LOWER('0xEa34479f7d95341E5fd49b89936366D6da710824')
    THEN 'Bought'
    END AS direction,
    TO_NUMBER(decoded_log:"value") AS target_value
    FROM swell.core.ez_decoded_event_logs
    WHERE EVENT_NAME = 'swap'
    AND (
    LOWER(ORIGIN_FROM_ADDRESS) = LOWER('0xEa34479f7d95341E5fd49b89936366D6da710824')
    OR LOWER(ORIGIN_TO_ADDRESS) = LOWER('0xEa34479f7d95341E5fd49b89936366D6da710824')
    )
    ),
    other_swaps AS (
    SELECT
    TX_HASH,
    CONTRACT_ADDRESS,
    TO_NUMBER(decoded_log:"value") AS other_value
    FROM swell.core.ez_decoded_event_logs
    WHERE EVENT_NAME = 'swap'
    AND LOWER(CONTRACT_ADDRESS) <> LOWER('0xEa34479f7d95341E5fd49b89936366D6da710824')
    )
    SELECT
    s.direction,
    o.CONTRACT_ADDRESS AS swapped_for_token,
    COUNT(DISTINCT s.TX_HASH) AS swap_occurrences,
    SUM(s.target_value) AS total_target_volume,
    SUM(o.other_value) AS total_counter_volume,
    MIN(s.BLOCK_TIMESTAMP) AS first_swap,
    MAX(s.BLOCK_TIMESTAMP) AS last_swap
    FROM target_swaps s
    Last run: about 1 month ago
    No Data to Display
    0
    2B
    2s