Query editor
WITH ore_price_lookup AS (-- Attempt to get the real-time price from the DEX tablesSELECT COALESCE((SELECT price FROM prices.latestWHERE blockchain = 'solana'AND contract_address = from_base58('oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp')LIMIT 1),123.00 -- <--- MANUAL FALLBACK: Change this to the current ORE price) as current_price),miner_stats AS (SELECTtx_signer as wallet,-- Total Fees Paid in USD (Handles missing SOL prices with a $165 fallback)SUM(CASEWHEN to_owner = 'HMAYjHeogmdm5J1EuBhhbbSvMrWARsEt38SsGZTrB7Mm'THEN amount_display * COALESCE(amount_usd / NULLIF(amount_display, 0), 165)ELSE 0END) as total_fees_paid_usd,-- Total ORE Amount (Standardized to 11 decimals via amount_display)SUM(CASEWHEN symbol = 'ORE'AND to_owner != 'HMAYjHeogmdm5J1EuBhhbbSvMrWARsEt38SsGZTrB7Mm'THEN amount_displayELSE 0END) as total_ore_amountFROM tokens_solana.transfersWHERE block_date >= current_date - interval '7' dayGROUP BY 1)SELECTwallet,total_ore_amount as "ORE Mined",-- Calculation: Amount * (DEX Price OR Fallback Price)total_ore_amount * (SELECT current_price FROM ore_price_lookup) as "ORE Value ($)",total_fees_paid_usd as "Fees Paid ($)",-- Actual Tax Rate: (Fees / Mined Value) * 100(total_fees_paid_usd / NULLIF(total_ore_amount * (SELECT current_price FROM ore_price_lookup), 0)) * 100 as "Effective Tax %",(total_ore_amount * (SELECT current_price FROM ore_price_lookup) - total_fees_paid_usd) as "Net Profit ($)"FROM miner_statsWHERE total_fees_paid_usd > 0ORDER BY total_ore_amount DESCLIMIT 50