Pine Analytics3time.fun copy3
    Updated 2025-02-14
    -- forked from time.fun @ https://flipsidecrypto.xyz/studio/queries/221bff0b-5071-4b43-a305-0ab2724c3e87

    with tab1 as (
    SELECT
    tx_hash as tx,
    case when ORIGIN_FUNCTION_SIGNATURE like '0x6945b123' then 'Buy'
    when ORIGIN_FUNCTION_SIGNATURE like '0xb51d0534' then 'Sell'
    end AS tx_type
    from base.core.fact_event_logs
    WHERE ORIGIN_TO_ADDRESS like lower('0x428aeF7fB31E4E86162D62d4530a4dd7232D953D')
    and ORIGIN_FUNCTION_SIGNATURE in ('0x6945b123', '0xb51d0534')
    )


    SELECT
    week,
    count(*) as new_trading_wallets,
    sum(new_trading_wallets) over (order by week) as total_trading_wallets

    FROM (
    SELECT
    user,
    min(date_trunc('week', block_timestamp)) as week

    FROM (
    select
    tx_hash,
    'Buy' as tx_type,
    block_timestamp,
    ORIGIN_FROM_ADDRESS as user,
    amount_usd

    from base.core.ez_native_transfers as a
    left outer join tab1
    on tx = tx_hash