jackguy2023-04-16 07:41 PM
    Updated 2023-04-17
    WITH tab1 AS (
    SELECT
    date_trunc('month', block_timestamp) as month,
    tx_receiver as stake_pool,
    AVG(try_to_numeric(TRIM(REGEXP_REPLACE(regexp_substr(tx:receipt[0]:outcome:logs, 'Contract total staked balance is\\W+\\w+'), '[a-z/-/A-z/./#/*"]', ''))))/pow(10,24) as pool_size
    FROM near.core.fact_transactions
    WHERE tx_hash IN ( SELECT tx_hash
    FROM near.core.fact_actions_events_function_call
    WHERE method_name IN ('deposit_and_stake'))
    GROUP BY 1,2
    ), tab2 AS (
    SELECT
    date_trunc('month',block_timestamp) as mon,
    MAX(total_supply*1e-24) as total_supply
    FROM near.core.fact_blocks
    GROUP BY 1
    ), circu_supply AS (
    SELECT * FROM (VALUES
    ('2021-07-01'::datetime, 396757000),
    ('2021-08-01', 422907000),
    ('2021-09-01', 446336000),
    ('2021-10-01', 472542000),
    ('2021-11-01', 531339000),
    ('2021-12-01', 568848000),
    ('2022-01-01', 602419000),
    ('2022-02-01', 630769000),
    ('2022-03-01', 643424000),
    ('2022-04-01', 660441000),
    ('2022-05-01', 676076000),
    ('2022-06-01', 703648000),
    ('2022-07-01', 725911000),
    ('2022-08-01', 751801000),
    ('2022-09-01', 775580000),
    ('2022-10-01', 799891000),
    ('2022-11-01', 818414000),
    ('2022-12-01', 833208000),
    Run a query to Download Data