elvis22/6 Metamask Q1: Metamask wallets: User stats
    Updated 2022-06-25
    -- Q1. How many total Metamask wallet holders are there?
    WITH METAMASK_WALLETS AS(
    SELECT distinct origin_from_address AS wallet_address
    FROM ethereum.core.fact_event_logs
    WHERE contract_address = lower('0x881D40237659C251811CEC9c364ef91dC08D300C')
    ),
    /* Get general stats: Total number of wallets(x), number of wallets with more than 2 tx (x), Number of wallets active in the last month(x), number of wallets created in the last month(x),
    t-series of new wallets/active wallets cumulative total wallets, tx_count distro single graph normed to total, in percentage w (all_time/last month)
    Number of transactions total(x), Number of transactions last month(x), Number of ETH transfer transactions_total(x), average ETH_TFR_TX_average(x), tx_fees(x)
    total/average ETH_balance (all_time/ active this month) (x)
    t-series of total/average ETH balance of (all users/(users active in the past month)
    * tokens: total_current_value (ETH/USD) of tokens held in wallets, t-series of the same, distro of the same, breakdown by token (Top10)
    * NFTS: Number of wallets holding NFTS, NFT mints total(x), NFTS sales count/value/average/distro t-series; NFT sales count/value breakdown by project (Top10) (all time/last month)
    * Total current value of NFTS held based on (project floor price/ last sale/mint price), breakdown by NFT (Top10), breakdown by project (Top10), distro of current value; Top10 in stacked distro
    Swaps: count/volume ETH:(total/average)/distro t-series fees total/avg (all_time/last_month)
    programs total number interacted with, count breakdown by program (Top10) (all time/lst month)
    * will be left for toolkit implementation
    */
    wallet_times AS (
    SELECT wallet_address, min(block_timestamp) as creation_time, max(block_timestamp) as last_active_time
    FROM METAMASK_WALLETS AS M LEFT JOIN ethereum.core.fact_event_logs AS E ON M.wallet_address = E.origin_from_address
    GROUP BY 1
    ),
    Table_new_wallets AS (
    (
    SELECT 'All_time' AS aggregate, count(distinct wallet_address) as New_wallets
    FROM wallet_times
    ) UNION
    (
    SELECT 'Last_month' AS aggregate, count(distinct wallet_address) as New_wallets
    FROM wallet_times
    WHERE creation_time > CURRENT_DATE-30
    )
    ),
    Table_active_wallets AS (
    Run a query to Download Data