Sbhn_NPNew Users From Escaped FTX Users
    Updated 2022-11-16
    --credit : misaghlb
    with alamedaftx as (
    select address
    from ethereum.core.dim_labels
    where label ilike any ('%alameda%', 'ftx')
    ),
    ftx_user as (
    SELECT DISTINCT to_address as ftx_user_wallet
    FROM ethereum.core.ez_token_transfers
    where date(block_timestamp) >= '2022-11-01'
    and from_address in (select address from alamedaftx)
    )

    SELECT 'GMX' as platform,
    date_trunc ('day', min_date) as date,
    count(distinct origin_from_address) as Users_Count from (
    SELECT origin_from_address, min(block_timestamp) as min_date
    from arbitrum.core.fact_token_transfers
    where origin_to_address in ('0x3d6ba331e3d9702c5e8a8d254e5d8a285f223aba','0xb87a436b93ffe9d75c5cfa7bacfff96430b09868')
    and origin_from_address in (select ftx_user_wallet from ftx_user)
    and RAW_AMOUNT is not null
    GROUP by origin_from_address
    )
    where date(min_date) >= '2022-11-01'
    GROUP by date

    union ALL

    SELECT 'GNS' as platform,
    date_trunc ('day', min_date) as date,
    count(distinct origin_from_address) as Users_Count from (
    SELECT origin_from_address, min(block_timestamp) as min_date
    from polygon.core.fact_token_transfers
    where origin_to_address in ('0xd8d177efc926a18ee455da6f5f6a6cfcee5f8f58','0x65187fec6ecc4774c1f632c7503466d5b4353db1','0xf8a140db8b05bec52c7e86d0d40d72f8e54fe559')
    and origin_function_signature in ('0x9aa7c0e5')
    and FROM_ADDRESS = Origin_From_Address
    Run a query to Download Data