ngxuan885New User Onboarding - swapping
    Updated 2022-06-29
    with a as (
    SELECT TO_ADDRESS as wallet, min(BLOCK_TIMESTAMP) as first_, 'transfer' as type
    from flipside_prod_db.thorchain.transfers GROUP by 1,3

    UNION
    SELECT NATIVE_TO_ADDRESS as wallet, min(BLOCK_TIMESTAMP) as first_, 'swap' as type
    from flipside_prod_db.thorchain.swaps where TO_ASSET = 'THOR.RUNE' and NATIVE_TO_ADDRESS ilike '%thor%' GROUP by 1,3

    UNION
    SELECT TO_ADDRESS as wallet, min(BLOCK_TIMESTAMP) as first_, 'upgrade' as type
    from flipside_prod_db.thorchain.upgrades GROUP by 1,3),
    ------------------------------------------------------------------------------------
    b as (SELECT wallet, min(first_) as first_tx from a GROUP by 1),
    c as ( SELECT a.wallet, first_tx, type
    from a join b on a.wallet = b.wallet and a.first_ = b.first_tx)
    --------------------------------------------------------------------------------------------------------
    SELECT FROM_ASSET,BLOCKCHAIN, count(*) as new_Wallets
    from flipside_prod_db.thorchain.swaps s
    join c on c.wallet = s.NATIVE_TO_ADDRESS and c.first_tx = s.BLOCK_TIMESTAMP

    where type = 'swap'
    and first_tx >= '2022-01-01'
    GROUP by 1,2 order by 3 DESC

    Run a query to Download Data