messariAD - Total Supply (Atlas)
    Updated 2024-01-04
    WITH

    lockup_receipts AS (
    SELECT fr.tx_hash
    , fr.block_timestamp
    , fr.actions:predecessor_id::string AS predecessor_id
    , fr.receiver_id
    , fr.actions
    , OBJECT_KEYS(fr.status_value)[0]::string AS status
    , fr.logs
    FROM near.core.fact_receipts AS fr
    WHERE fr.receiver_id LIKE '%.lockup.near'
    AND status != 'Failure'
    ),


    daily_lockup_locked_balances AS (
    WITH

    -- new lockup contract created
    new_lockup_txs AS (
    SELECT lr.tx_hash
    , lr.block_timestamp
    , lr.receiver_id AS lockup_account_id
    FROM lockup_receipts AS lr,
    LATERAL FLATTEN( input => lr.actions:receipt:Action:actions )
    WHERE value:FunctionCall:method_name::string = 'new'
    ),
    -- vesting is stopped by the Foundation
    terminate_vesting_txs AS (
    SELECT lr.tx_hash
    , lr.block_timestamp
    , lr.receiver_id AS lockup_account_id
    QueryRunArchived: QueryRun has been archived