permarynew users
    Updated 2025-03-17

    WITH historical_users AS (
    -- Find all wallets that used XSGD on Ethereum or Polygon before September 2024
    SELECT DISTINCT origin_from_address AS wallet_address
    FROM ethereum.core.ez_token_transfers
    WHERE contract_address = LOWER('0x70e8dE73cE538DA2bEEd35d14187F6959a8ecA96')
    AND block_timestamp < '2024-09-01'

    UNION

    SELECT DISTINCT origin_to_address AS wallet_address
    FROM ethereum.core.ez_token_transfers
    WHERE contract_address = LOWER('0x70e8dE73cE538DA2bEEd35d14187F6959a8ecA96')
    AND block_timestamp < '2024-09-01'

    UNION

    SELECT DISTINCT origin_from_address AS wallet_address
    FROM polygon.core.ez_token_transfers
    WHERE contract_address = LOWER('0xDC3326e71D45186F113a2F448984CA0e8D201995')
    AND block_timestamp < '2024-09-01'

    UNION

    SELECT DISTINCT origin_to_address AS wallet_address
    FROM polygon.core.ez_token_transfers
    WHERE contract_address = LOWER('0xDC3326e71D45186F113a2F448984CA0e8D201995')
    AND block_timestamp < '2024-09-01'
    ),

    first_tx_per_chain AS (
    -- Find first transaction per user on each chain (starting from September 2024)
    SELECT
    'Ethereum' AS chain,
    origin_from_address AS wallet_address,
    MIN(DATE_TRUNC('month', block_timestamp)) AS first_tx_month