Query editor
-- Top Fee Sources — Optimized-- Purpose:-- Identifies the addresses/contracts sending the most fees to Trustless Work.WITH candidate_operations AS (SELECTo.closed_at,o.closed_at_date,o.transaction_id,o.asset_balance_changesFROM stellar.history_operations oWHERE o.closed_at_date >= CURRENT_DATE - INTERVAL '90' DAYAND cardinality(o.asset_balance_changes) > 0AND any_match(o.asset_balance_changes,x -> x."to" = 'GBWWSOATPLIC72ZBOIM7WJCT7VCAHNWW4QUBZ2H4FORMCCIUM5ZVKSZN')),fee_inflows AS (SELECTo.closed_at AS block_time,to_hex(t.transaction_hash) AS transaction_hash,u.bc_from AS sender_address,COALESCE(u.bc_asset_code, 'XLM') AS token_symbol,u.bc_asset_issuer AS asset_issuer,u.bc_asset_type AS asset_type,u.bc_amount AS fee_amountFROM candidate_operations oLEFT JOIN stellar.history_transactions tON o.transaction_id = t.idCROSS JOIN UNNEST(filter(o.asset_balance_changes,x -> x."to" = 'GBWWSOATPLIC72ZBOIM7WJCT7VCAHNWW4QUBZ2H4FORMCCIUM5ZVKSZN'AND x.amount > 0AND x.type = 'transfer')) AS u(bc_amount,bc_asset_code,bc_asset_issuer,bc_asset_type,bc_from,bc_to,bc_type))SELECTsender_address,token_symbol,asset_issuer,asset_type,COUNT(*) AS transfer_rows,COUNT(DISTINCT transaction_hash) AS fee_generating_transactions,SUM(fee_amount) AS total_fee_amount,