Pendletoken_daily_balance
    Updated 2025-05-14
    WITH token_start_date AS (
    SELECT date(min(date_trunc('day', BLOCK_TIMESTAMP))) as first_date
    from {{chain}}.core.ez_token_transfers
    where CONTRACT_ADDRESS = lower('{{token_contract_address}}')
    ),
    in_flows AS (
    SELECT
    BLOCK_TIMESTAMP AS evt_block_time,
    TO_ADDRESS AS user,
    RAW_AMOUNT/1e{{decimals}} as amount
    from {{chain}}.core.ez_token_transfers
    where CONTRACT_ADDRESS = lower('{{token_contract_address}}') and BLOCK_TIMESTAMP >= (select first_date from token_start_date)
    ),
    our_flows AS (
    SELECT
    BLOCK_TIMESTAMP AS evt_block_time,
    FROM_ADDRESS AS user,
    -RAW_AMOUNT/1e{{decimals}} as amount
    from {{chain}}.core.ez_token_transfers
    where CONTRACT_ADDRESS = lower('{{token_contract_address}}') and BLOCK_TIMESTAMP >= (select first_date from token_start_date)
    ),
    date_series AS (
    SELECT DATEADD(DAY, VALUE::INT, first_date::DATE) as "date"
    FROM token_start_date, TABLE(FLATTEN(ARRAY_GENERATE_RANGE(0, DATEDIFF('DAY', first_date, current_date)+1)));
    ),
    user_daily AS (
    SELECT user,
    date_trunc('day', evt_block_time) as ds,
    sum(amount) as daily_amount
    FROM (
    SELECT * FROM in_flows
    UNION ALL
    SELECT * FROM our_flows
    )
    GROUP BY 1, 2
    ),
    Last run: 30 days ago
    DS
    BALANCE
    ACTIVE_HOLDERS
    CUMULATIVE_HOLDERS
    1
    2025-05-14 00:00:00.000103670044.044318233447
    2
    2025-05-13 00:00:00.000103719931.544628232446
    3
    2025-05-12 00:00:00.000103371976.647552232444
    4
    2025-05-11 00:00:00.00083315157.834297234441
    5
    2025-05-10 00:00:00.00083494610.8578889231434
    6
    2025-05-09 00:00:00.00082110525.3943006230426
    7
    2025-05-08 00:00:00.00080874326.5022943228423
    8
    2025-05-07 00:00:00.00078674598.6716096232416
    9
    2025-05-06 00:00:00.00078106422.1093627227405
    10
    2025-05-05 00:00:00.00076847307.382977229401
    11
    2025-05-04 00:00:00.00075990107.5246642231394
    12
    2025-05-03 00:00:00.00075897409.2907187229387
    13
    2025-05-02 00:00:00.00073970700.0154293222376
    14
    2025-05-01 00:00:00.00073009905.9442231216367
    15
    2025-04-30 00:00:00.00073377442.7054303217364
    16
    2025-04-29 00:00:00.00072783176.4903535214359
    17
    2025-04-28 00:00:00.00067423054.1761861215357
    18
    2025-04-27 00:00:00.00069108882.0024514213353
    19
    2025-04-26 00:00:00.00069108829.1532427213352
    20
    2025-04-25 00:00:00.00069244868.0223305213352
    ...
    145
    7KB
    9s