Active accounts or actual people?
In the latest window 748,667 accounts were active, but 668,994 of them showed up on only one or two days, up from 60,870 the month before. The count of active accounts swings on bursts like that. The accounts that pass the test barely move with it: monthly changes correlate at 0.19.
- Active accounts
- Active on 5+ of 14 days
- Passed the sleep test
The query behind this chart
Long lists are shortened here. python -m pipeline.pull_bigquery --print 10 prints any step in full, ready to paste. Steps other than 10 and 15 read the table built by step 00.
sql/00_account_windows.sql
-- Step 0. One row per account per 14-day window, with its daily rhythm features.
-- Everything else reads this table, so the expensive scan of `transactions` happens once.
-- The filter on block_date is literal: only the sampled days are read and billed.
-- Not partitioned by date on purpose: BigQuery's free tier deletes date partitions older than 60 days.
CREATE OR REPLACE TABLE `your-project.proof_of_sleep.account_windows`
CLUSTER BY window_start, class AS
WITH slots AS ( -- one row per account, day and hour with activity
SELECT
signer_account_id AS account,
DATE_TRUNC(block_date, MONTH) AS window_start,
block_date,
EXTRACT(HOUR FROM block_timestamp_utc) AS hour,
COUNT(*) AS n_tx
FROM `bigquery-public-data.crypto_near_mainnet_us.transactions`
WHERE block_date BETWEEN ... -- 70 two-week windows, listed in pipeline/config.py
GROUP BY 1, 2, 3, 4
),
days AS ( -- which hours each active day used
SELECT
account, window_start, block_date,
SUM(n_tx) AS n_tx,
COUNT(*) AS n_slots,
BIT_OR(1 << hour) AS day_mask
FROM slots
GROUP BY 1, 2, 3
),
accounts AS ( -- all the hours of the clock the account ever used
SELECT
account, window_start,
SUM(n_tx) AS n_tx,
COUNT(*) AS n_days,
SUM(n_slots) AS n_slots,
BIT_OR(day_mask) AS hour_mask
FROM days
GROUP BY 1, 2
),
hours AS (
SELECT *, ARRAY(SELECT h FROM UNNEST(GENERATE_ARRAY(0, 23)) AS h WHERE (hour_mask >> h) & 1 = 1) AS hs
FROM accounts
),
gaps AS ( -- the longest stretch of hours never used, wrapping past midnight
SELECT *,
(SELECT AS STRUCT gap, start_h
FROM (
SELECT h AS start_h,
COALESCE((SELECT MIN(h2) FROM UNNEST(hs) AS h2 WHERE h2 > h), hs[OFFSET(0)] + 24) - h - 1 AS gap
FROM UNNEST(hs) AS h
)
ORDER BY gap DESC, start_h
LIMIT 1) AS g
FROM hours
),
classified AS (
SELECT
account, window_start, n_tx, n_days, n_slots, hour_mask,
ARRAY_LENGTH(hs) AS n_hours,
g.gap AS gap,
-- middle of the quiet stretch, as a clock hour (UTC)
(g.start_h + 1 + g.gap / 2) - 24 * FLOOR((g.start_h + 1 + g.gap / 2) / 24) AS mid,
CASE
WHEN n_days < 5 THEN 'too_few'
WHEN g.gap <= 2 AND n_slots / n_days >= 8 THEN 'machine'
WHEN ARRAY_LENGTH(hs) <= 3 THEN 'timer'
WHEN g.gap >= 5 AND g.gap >= [99,99,99,20,17,15,13,12,11,10,9,8,7,7,6,6,5,5,4,4,3,3,99,99,99][OFFSET(ARRAY_LENGTH(hs))] AND g.gap <= 14 AND ARRAY_LENGTH(hs) >= 6 THEN 'sleeper'
WHEN g.gap >= 5 AND g.gap >= [99,99,99,20,17,15,13,12,11,10,9,8,7,7,6,6,5,5,4,4,3,3,99,99,99][OFFSET(ARRAY_LENGTH(hs))] THEN 'routine'
ELSE 'unclear'
END AS class
FROM gaps
)
SELECT -- accounts seen on 1-2 days are kept only as counts
IF(n_days >= 3, account, '_light_') AS account,
window_start,
COUNT(*) AS accounts,
SUM(n_tx) AS n_tx,
n_days,
SUM(n_slots) AS n_slots,
IF(n_days >= 3, ANY_VALUE(hour_mask), NULL) AS hour_mask,
IF(n_days >= 3, ANY_VALUE(n_hours), NULL) AS n_hours,
IF(n_days >= 3, ANY_VALUE(gap), NULL) AS gap,
IF(n_days >= 3, ANY_VALUE(mid), NULL) AS mid,
IF(n_days >= 3, ANY_VALUE(class), 'light') AS class
FROM classified
GROUP BY 1, 2, n_dayssql/01_classes.sql
-- Headline table: how many accounts fall in each class in each 14-day window,
-- and how many transactions each class sent.
SELECT
window_start,
class,
SUM(accounts) AS accounts,
SUM(n_tx) AS txs
FROM `your-project.proof_of_sleep.account_windows`
GROUP BY 1, 2
ORDER BY 1, 2The numbers as a table
| Window (first 14 days of) | Active accounts | Active on 5+ of 14 days | Passed sleep test | Narrow daily routine | Never sleeps | Transactions |
|---|---|---|---|---|---|---|
| 2021-01-01 | 5,776 | 253 | 41 | 11 | 15 | 122,232 |
| 2021-02-01 | 10,024 | 361 | 58 | 21 | 11 | 127,800 |
| 2021-03-01 | 14,616 | 501 | 110 | 15 | 14 | 185,378 |
| 2021-04-01 | 33,101 | 530 | 116 | 35 | 19 | 363,032 |
| 2021-05-01 | 29,411 | 927 | 203 | 47 | 114 | 897,225 |
| 2021-06-01 | 74,647 | 1,678 | 441 | 56 | 220 | 2,045,255 |
| 2021-07-01 | 34,340 | 2,425 | 702 | 62 | 265 | 2,340,662 |
| 2021-08-01 | 118,368 | 3,224 | 929 | 102 | 440 | 3,463,547 |
| 2021-09-01 | 354,523 | 5,522 | 1,485 | 174 | 667 | 4,255,286 |
| 2021-10-01 | 115,297 | 7,237 | 2,171 | 339 | 415 | 3,518,602 |
| 2021-11-01 | 203,660 | 13,277 | 3,321 | 879 | 360 | 4,052,958 |
| 2021-12-01 | 261,768 | 6,782 | 1,627 | 569 | 354 | 4,430,472 |
| 2022-01-01 | 118,513 | 8,433 | 2,337 | 407 | 527 | 8,673,147 |
| 2022-02-01 | 99,802 | 12,195 | 3,819 | 514 | 465 | 7,187,121 |
| 2022-03-01 | 138,331 | 10,736 | 3,267 | 553 | 332 | 5,627,966 |
| 2022-04-01 | 101,855 | 10,347 | 2,907 | 458 | 443 | 9,689,195 |
| 2022-05-01 | 96,433 | 10,586 | 3,059 | 520 | 352 | 14,858,182 |
| 2022-06-01 | 71,943 | 9,893 | 2,685 | 574 | 254 | 8,658,237 |
| 2022-07-01 | 98,401 | 6,702 | 1,690 | 466 | 237 | 4,665,387 |
| 2022-08-01 | 70,688 | 7,829 | 2,037 | 467 | 252 | 4,748,058 |
| 2022-09-01 | 365,222 | 6,784 | 1,777 | 366 | 230 | 5,979,219 |
| 2022-10-01 | 691,419 | 43,851 | 6,432 | 5,499 | 214 | 7,253,392 |
| 2022-11-01 | 632,437 | 26,650 | 4,238 | 3,195 | 284 | 7,985,619 |
| 2022-12-01 | 520,497 | 17,294 | 2,746 | 2,177 | 180 | 5,193,085 |
| 2023-01-01 | 704,275 | 12,925 | 2,117 | 1,448 | 202 | 5,551,618 |
| 2023-02-01 | 578,120 | 31,967 | 3,017 | 3,705 | 252 | 5,795,129 |
| 2023-03-01 | 499,585 | 16,073 | 1,719 | 1,664 | 229 | 5,151,534 |
| 2023-04-01 | 617,433 | 19,794 | 1,821 | 2,005 | 203 | 5,812,206 |
| 2023-05-01 | 471,559 | 10,783 | 1,192 | 1,013 | 162 | 4,580,967 |
| 2023-06-01 | 692,940 | 14,997 | 1,291 | 1,434 | 160 | 5,325,806 |
| 2023-07-01 | 624,613 | 12,152 | 1,275 | 1,111 | 166 | 5,704,618 |
| 2023-08-01 | 636,180 | 13,322 | 1,483 | 1,438 | 154 | 5,776,920 |
| 2023-09-01 | 2,313,745 | 709,641 | 2,700 | 80,171 | 165 | 19,963,441 |
| 2023-10-01 | 2,057,855 | 759,809 | 2,949 | 41,583 | 153 | 18,772,803 |
| 2023-11-01 | 2,494,233 | 873,316 | 9,604 | 225,045 | 177 | 22,517,747 |
| 2023-12-01 | 3,349,732 | 918,186 | 32,613 | 22,176 | 193 | 49,008,837 |
| 2024-01-01 | 5,615,352 | 1,011,908 | 29,938 | 25,359 | 715 | 48,534,431 |
| 2024-02-01 | 7,944,838 | 233,296 | 34,337 | 12,441 | 2,544 | 53,305,841 |
| 2024-03-01 | 7,725,640 | 650,184 | 92,080 | 16,181 | 4,203 | 76,410,828 |
| 2024-04-01 | 8,323,407 | 975,851 | 81,759 | 29,686 | 3,436 | 110,351,391 |
| 2024-05-01 | 8,915,854 | 1,154,354 | 77,101 | 38,911 | 5,007 | 96,481,058 |
| 2024-06-01 | 11,046,701 | 1,235,478 | 111,138 | 56,034 | 7,381 | 110,356,866 |
| 2024-07-01 | 12,471,397 | 1,089,921 | 110,965 | 46,237 | 11,881 | 107,326,305 |
| 2024-08-01 | 8,672,206 | 818,711 | 81,339 | 25,955 | 6,855 | 85,249,283 |
| 2024-09-01 | 4,329,171 | 781,856 | 89,002 | 27,107 | 7,724 | 100,469,324 |
| 2024-10-01 | 5,356,016 | 838,394 | 87,735 | 47,580 | 6,042 | 99,260,270 |
| 2024-11-01 | 5,195,904 | 746,345 | 85,945 | 36,727 | 5,179 | 103,099,476 |
| 2024-12-01 | 4,836,679 | 734,518 | 86,317 | 43,855 | 3,403 | 116,932,645 |
| 2025-01-01 | 5,195,241 | 679,908 | 82,245 | 48,514 | 4,192 | 91,863,420 |
| 2025-02-01 | 5,039,854 | 607,621 | 64,990 | 47,287 | 2,400 | 94,677,590 |
| 2025-03-01 | 946,585 | 573,851 | 51,891 | 48,551 | 2,104 | 90,011,686 |
| 2025-04-01 | 1,056,208 | 528,389 | 50,900 | 43,855 | 1,386 | 93,386,190 |
| 2025-05-01 | 822,311 | 487,528 | 42,471 | 51,277 | 1,057 | 75,855,417 |
| 2025-06-01 | 656,162 | 431,404 | 35,204 | 42,678 | 1,123 | 68,578,879 |
| 2025-07-01 | 583,558 | 385,633 | 31,686 | 43,472 | 570 | 61,874,081 |
| 2025-08-01 | 597,077 | 390,184 | 30,717 | 43,649 | 474 | 71,626,930 |
| 2025-09-01 | 523,074 | 360,130 | 30,175 | 49,154 | 426 | 67,780,040 |
| 2025-10-01 | 493,617 | 326,908 | 28,523 | 40,183 | 347 | 65,108,083 |
| 2025-11-01 | 450,626 | 295,327 | 26,180 | 38,111 | 393 | 59,853,262 |
| 2025-12-01 | 425,592 | 262,236 | 22,803 | 36,912 | 287 | 55,219,350 |
| 2026-01-01 | 411,189 | 222,825 | 18,466 | 27,875 | 466 | 50,017,345 |
| 2026-02-01 | 2,244,069 | 188,982 | 14,526 | 24,987 | 262 | 49,299,409 |
| 2026-03-01 | 298,115 | 171,613 | 11,665 | 23,755 | 263 | 46,863,806 |
| 2026-04-01 | 271,036 | 156,046 | 12,069 | 24,601 | 207 | 16,022,191 |
| 2026-05-01 | 277,674 | 141,335 | 10,239 | 19,499 | 207 | 10,669,214 |
| 2026-06-01 | 243,104 | 134,004 | 10,776 | 18,074 | 249 | 12,164,250 |
| 2026-07-01 | 204,630 | 121,095 | 8,189 | 18,579 | 203 | 10,745,784 |
| 2026-08-01 | 168,718 | 98,470 | 6,902 | 13,895 | 190 | 9,359,512 |
| 2026-09-01 | 165,792 | 86,454 | 6,622 | 12,120 | 228 | 9,990,120 |
| 2026-10-01 | 748,667 | 61,957 | 5,771 | 7,781 | 340 | 12,162,517 |