Query editor
-- w_authority: 6WecYymEARvjG5ZyqkrVQ6YkhPfujNzWpSPwNKXHCbV2-- s_authority: 6WecYymEARvjG5ZyqkrVQ6YkhPfujNzWpSPwNKXHCbV2-- reserve: rsrxDvYUXjH1RQj2Ke36LNZEVqGztATxFkqNukERqFT-- address: bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1WITHbase AS (SELECTaccount_arguments[6] AS stake_account_raw, b.sol_balanceFROM solana.instruction_calls cLEFT JOIN solana_utils.latest_balances bON c.account_arguments[6] = b.addressWHEREexecuting_account = 'SPoo1Ku8WFXoNDMHPsrGSTSG1Y47rzgn41SLUNakuHy' -- ID of the Solana Stake Pool ProgramAND contains(account_arguments, '6WecYymEARvjG5ZyqkrVQ6YkhPfujNzWpSPwNKXHCbV2')AND bytearray_substring(data, 1, 1) = 0x01 -- AddValidatorToPool-- AND bytearray_substring(data, 1, 1) = 0x02 -- RemoveValidatorFromPoolAND tx_successUNION ALLSELECTnull -- leave as null since this does not count as validator, sol_balanceFROM solana_utils.latest_balancesWHERE address = 'rsrxDvYUXjH1RQj2Ke36LNZEVqGztATxFkqNukERqFT' -- Solana stake pool reserve account), final AS (SELECTCOUNT(CASE WHEN sol_balance > 1 THEN stake_account_raw ELSE null END) AS num_active_validators,SUM(sol_balance) AS tvl,SUM(rewards) AS fees_earned_solFROM base bLEFT JOIN solana_utils.total_rewards rON b.stake_account_raw = r.recipient)SELECT * FROM final