Query editor
-- Consolidating all transactions from both 'create' and 'close' actions into a single unified viewWITHall_transactions AS (-- Selecting transactions that represent the creation of a positionSELECTcall_block_date,call_tx_signer,call_tx_id,amount,'create' AS actionFROMpyth_solana.staking_call_createPositionUNION ALL-- Selecting transactions that represent the closing of a position-- Note: Closed positions have their amounts negated to indicate a reduction in the positionSELECTcall_block_date,call_tx_signer,call_tx_id,- amount AS amount,'close' AS actionFROMpyth_solana.staking_call_closePosition),excluded_txs AS (SELECTcreate_tx.call_tx_idFROMpyth_solana.staking_call_createPosition create_txINNER JOIN pyth_solana.staking_call_closePosition close_tx ON create_tx.call_tx_id = close_tx.call_tx_id),-- Calculating the cumulative net amount for each signer on each transaction datecumulative_sums AS (SELECTcall_tx_signer,call_block_date,-- Computing a running total (cumulative sum) of amounts for each signer, ordered by dateSUM(amount) OVER (PARTITION BYcall_tx_signerORDER BYcall_block_date) AS cumulative_net_amountFROMall_transactionsWHEREcall_tx_id NOT IN (SELECTcall_tx_idFROMexcluded_txs)),-- Extracting distinct dates from the transaction datadistinct_dates AS (SELECT DISTINCTcall_block_dateFROMall_transactions),