datavortexNew vs existing Wallets (Bridge to new )
    Updated 2024-11-18

    WITH first_bridge AS (
    SELECT
    destination_address,
    MIN(block_timestamp) AS "First Bridge Timestamp"
    FROM
    near.defi.ez_bridge_activity
    WHERE
    LOWER(destination_chain) = 'near'
    GROUP BY
    destination_address
    ),
    last_year_bridges AS (
    SELECT
    tx_hash,
    destination_address,
    amount_usd,
    block_timestamp
    FROM
    near.defi.ez_bridge_activity
    WHERE
    LOWER(destination_chain) = 'near'
    AND block_timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 year' AND CURRENT_TIMESTAMP
    )
    SELECT
    'New Wallets' AS "Category",
    COUNT(DISTINCT lb.destination_address) AS "Wallet Count",
    SUM(COALESCE(lb.amount_usd, 0)) AS "Volume"
    FROM
    last_year_bridges lb
    LEFT JOIN
    first_bridge fb
    ON
    lb.destination_address = fb.destination_address
    QueryRunArchived: QueryRun has been archived