hess4. New Vs. Returning
    Updated 2025-03-08
    with base as (select tx_hash,
    block_timestamp,
    origin_from_address AS swapper,
    DECODED_LOG:"amount0In"::NUMBER AS amount0In,
    DECODED_LOG:"amount0Out"::NUMBER AS amount0Out,
    DECODED_LOG:"amount1In"::NUMBER AS amount1In,
    DECODED_LOG:"amount1Out"::NUMBER AS amount1Out,
    DECODED_LOG:"sender"::STRING AS sender,
    DECODED_LOG:"to"::STRING AS recipient,
    contract_address as pool_address,
    case when decoded_log:amount1Out::NUMBER = 0 then decoded_log:amount1In::NUMBER else decoded_log:amount1Out::NUMBER end AS token_1_amounts,
    case when decoded_log:amount0In::NUMBER = 0 then decoded_log:amount0Out::NUMBER else decoded_log:amount0In::NUMBER end AS token_0_amounts,
    DECODED_LOG:"amount0"::NUMBER as amount0,
    DECODED_LOG:"amount1"::NUMBER as amount1,
    case when amount0 > 0 then amount0 else abs(amount0) end as token0,
    case when amount1 > 0 then amount1 else abs(amount1) end as token1,
    Coalesce(token_1_amounts,token1) as token_1_amount,
    Coalesce(token_0_amounts,token0) as token_0_amount
    FROM ink.core.ez_decoded_event_logs
    WHERE event_name = 'Swap'
    and origin_to_address = lower('0x652e53c6a4fe39b6b30426d9c96376a105c89a95')
    and TX_SUCCEEDED = 'TRUE')
    ,
    pool as (select concat('0x', substr(topics[1], 24 + 3, 32 + 8)) as token_0_address,
    concat('0x', substr(topics[2], 24 + 3, 32 + 8)) as token_1_address,
    regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS pool_data,
    concat('0x', substr(pool_data[0], 25, 40)) as pool_address
    from ink.core.fact_event_logs
    having pool_address is not null)
    ,
    pair as ( select a.*,
    token_0_address,
    token_1_address
    from base a left outer join pool b on a.pool_address = b.pool_address)
    ,
    token_bonk as ( select * from $query('43200306-984d-4255-816a-7685810d5804'))
    Last run: about 1 month ago
    DATE
    TYPE
    VOLUME
    1
    2025-02-19 00:00:00.000New Swapper150508.638093897
    2
    2025-02-15 00:00:00.000Returning Swapper8683.356612641
    3
    2025-02-09 00:00:00.000Returning Swapper93680.757423823
    4
    2025-03-03 00:00:00.000Returning Swapper179681.287815502
    5
    2025-02-25 00:00:00.000New Swapper354711.951671353
    6
    2025-02-14 00:00:00.000New Swapper221944.109531788
    7
    2025-02-10 00:00:00.000New Swapper213541.89842613
    8
    2025-03-07 00:00:00.000Returning Swapper13025.341777023
    9
    2025-02-16 00:00:00.000New Swapper89976.815898491
    10
    2025-02-22 00:00:00.000New Swapper204245.09447778
    11
    2025-02-07 00:00:00.000Returning Swapper27639.503157186
    12
    2025-02-18 00:00:00.000New Swapper222538.599931776
    13
    2025-03-01 00:00:00.000Returning Swapper43622.70911215
    14
    2025-02-17 00:00:00.000New Swapper361123.996587232
    15
    2025-02-06 00:00:00.000Returning Swapper110596.351018532
    16
    2025-02-14 00:00:00.000Returning Swapper23685.987586779
    17
    2025-02-11 00:00:00.000New Swapper220052.006743192
    18
    2025-02-27 00:00:00.000Returning Swapper13552.63146131
    19
    2025-02-21 00:00:00.000New Swapper575607.739591868
    20
    2025-02-20 00:00:00.000New Swapper145392.200958864
    62
    4KB
    7s