freemartianTotal amAPT
    Updated 2025-01-13

    -- ===== deposit and stake
    WITH
    dep_stk1 AS (
    SELECT
    tx_hash,
    event_data:amapt/pow(10,8) AS amapt_amount_stake,
    event_data:stapt/pow(10,8) AS stapt_amount_stake
    FROM aptos.core.fact_events
    WHERE event_resource = 'StakeEvent'
    AND event_address = '0x111ae3e5bc816a5e63c2da97d0aa3886519e0cd5e4b046659fa35796bd11542a'
    AND block_timestamp::date >= '2023-10-20'
    -- AND tx_hash = '0x1a15a2c4faa1414458fc2426c70701fa26ea8ec3539a2523f19dbbce2ae95274'
    ),
    dep_stk2 AS(
    SELECT
    block_timestamp,
    tx.tx_hash,
    sender,
    SPLIT_PART(payload:function,'::',1) AS contract,
    SPLIT_PART(payload:function,'::',3) AS function,
    payload:arguments[0]/pow(10,8) AS apt_amount_stake,
    amapt_amount_stake,
    stapt_amount_stake

    FROM aptos.core.fact_transactions tx
    INNER JOIN dep_stk1 ds ON ds.tx_hash = tx.tx_hash
    WHERE function IN ('deposit_and_stake_entry','router::stake_entry')
    AND contract = '0x111ae3e5bc816a5e63c2da97d0aa3886519e0cd5e4b046659fa35796bd11542a'
    AND sender <> '0xe8065c9960640b6bea2c1a97260cc714c7237c1e85d79bee569ac5b980b16f2b'
    AND block_timestamp::date >= '2023-10-20'
    ),

    -- ====== unstake
    unstake1 AS (
    SELECT
    Auto-refreshes every 1 hour
    QueryRunArchived: QueryRun has been archived