Query editor
WITH-- Find the latest epochlatest AS (SELECT CAST(FLOOR(MAX(epoch)) AS BIGINT) AS latest_epochFROM staking_solana.validator_stake_account_epochs),-- (stake_account, epoch) pairs staked to Bitwise during the last 6 epochswallet_set AS (SELECT DISTINCTstake_account,CAST(FLOOR(epoch) AS BIGINT) AS epochFROM staking_solana.validator_stake_account_epochs-- WHERE vote_account = 'he1iusunGwqrNtafDtLdhsUQDFvo13z9sUa36PauBtk'WHERE vote_account = '8GbwASqdpw4dVcwbWUxbHXMrjyQx2aKkoBR5H1GJF8iD'AND CAST(FLOOR(epoch) AS BIGINT) BETWEEN(SELECT latest_epoch - 30 FROM latest) AND (SELECT latest_epoch FROM latest)AND sol_balance > 0),-- Epoch timestamps (one row per epoch)epoch_times AS (SELECT DISTINCTCAST(FLOOR(epoch) AS BIGINT) AS epoch,MIN(epoch_time) AS epoch_start_timeFROM staking_solana.validator_stake_account_epochsGROUP BY 1)-- Sum staking rewards for Helius-delegated accounts by epochSELECTws.epoch,et.epoch_start_time,SUM(r.lamports) / 1e9 AS staking_rewards_sol-- (SUM(r.lamports) / 1e9) * 0.03 AS commissions,-- (SUM(r.lamports) / 1e9) * 0.97 AS staking_rewards_sol_after_commissionsFROM solana.rewards rJOIN wallet_set wsON r.recipient = ws.stake_accountAND FLOOR(r.block_slot / 432000) - 1 = ws.epochLEFT JOIN epoch_times etON ws.epoch = et.epochWHERE r.reward_type = 'Staking'AND r.lamports > 0GROUP BY ws.epoch, et.epoch_start_timeORDER BY ws.epoch DESC;