Query editor
WITH reward_payouts AS (SELECTtx.to_owner AS wallet, -- Wallet addressCOUNT(*) AS total_reward_payouts, -- Total number of reward payoutsSUM(CASEWHEN tp.price IS NULL OR tp.price <= 0 OR tp.price > 1e12 THEN 0 -- Handle invalid pricesELSE (tx.amount / POWER(10, tf.decimals)) * tp.priceEND) AS total_reward_usd -- Total USD value of reward payoutsFROMtokens_solana.transfers AS txJOINtokens_solana.fungible AS tf -- Join to fetch token detailsONtx.token_mint_address = tf.token_mint_addressLEFT JOINdex_solana.price_hour AS tp -- Join to fetch token priceONtf.symbol = tp.symbol AND DATE_TRUNC('hour', tx.block_time) = tp.hourWHEREtx.tx_signer = '1orFCnFfgwPzSgUaoK6Wr3MjgXZ7mtk8NGz9Hh4iWWL' -- Authority walletAND tx.outer_executing_account = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' -- Token ProgramAND tx.block_date >= CURRENT_TIMESTAMP - INTERVAL '30' DAY -- Limit to the last 30 daysAND tx.to_owner <> 'cPUtmyb7RZhCaTusCb4qnPJjVTbwpJ6SpXUCvnBDU4a' -- Exclude Treasury wallet transfersAND tx.to_owner IS NOT NULL -- Ensure valid destination walletAND tx.from_owner IS NOT NULL -- Ensure valid source walletGROUP BYtx.to_owner),swaps_data AS (WITH swap_instructions AS (SELECTic.tx_id,ic.block_time,DATE_TRUNC('day', ic.block_time) AS dayFROMsolana.instruction_calls AS icWHEREic.executing_account = 'MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr' -- Memo ProgramAND from_utf8(ic.data) LIKE '{"ref"%'AND ic.block_time >= CURRENT_TIMESTAMP - INTERVAL '30' DAY -- Last 30 days),pondex_sol AS (SELECTa.tx_id AS transaction_id, -- Unique transaction IDa.block_time, -- Block timestamp of the transactionDATE_TRUNC('day', a.block_time) AS transaction_day,a.tx_signer AS wallet, -- Wallet address (transaction signer)a.input_amount / POWER(10, COALESCE(a.input_decimals, 9)) AS token_sent_amount,a.input_symbol AS token_sent_symbol,a.output_amount / POWER(10, COALESCE(a.output_decimals, 9)) AS token_received_amount,a.output_symbol AS token_received_symbol,COALESCE(a.input_usd, a.output_usd) AS amount_usd -- USD value of the transactionFROMswap_instructions AS siJOINjupiter_solana.aggregator_swaps AS aONsi.tx_id = a.tx_id AND si.block_time = a.block_timeWHERECOALESCE(a.input_usd, a.output_usd) > 9 -- Filter for transactions > $9 USD