Query editor
WITH titan_blocks AS (SELECT number as block_number, time as block_timeFROM ethereum.blocksWHERE date >= current_date - interval '60' dayAND miner = 0x4838b106fce9647bdf1e7877bf73ce8b0bad5f97),eth_transfers AS (SELECT block_number, "from", "to", value FROM ethereum.tracesWHERE block_date >= current_date - interval '60' dayAND value > 0 AND call_type != 'delegatecall' AND success AND tx_success),paid_to_titan AS (SELECT et."from" as counterparty, sum(et.value)/1e18 as gross_paid_to_titan_eth, count(*) as n_paymentsFROM titan_blocks tb JOIN eth_transfers et ON et.block_number = tb.block_numberWHERE et.to = 0x4838b106fce9647bdf1e7877bf73ce8b0bad5f97GROUP BY 1),paid_by_titan AS (SELECT et.to as counterparty, sum(et.value)/1e18 as rebate_from_titan_eth, count(*) as n_rebatesFROM titan_blocks tb JOIN eth_transfers et ON et.block_number = tb.block_numberWHERE et."from" = 0x4838b106fce9647bdf1e7877bf73ce8b0bad5f97GROUP BY 1)SELECTcoalesce(p.counterparty, r.counterparty) as counterparty_address,coalesce(p.gross_paid_to_titan_eth, 0) as gross_paid_to_titan_eth,coalesce(p.n_payments, 0) as n_payments,coalesce(r.rebate_from_titan_eth, 0) as rebate_from_titan_eth,coalesce(r.n_rebates, 0) as n_rebates,coalesce(p.gross_paid_to_titan_eth, 0) - coalesce(r.rebate_from_titan_eth, 0) as net_contribution_ethFROM paid_to_titan pFULL OUTER JOIN paid_by_titan r ON r.counterparty = p.counterpartyWHERE coalesce(p.gross_paid_to_titan_eth,0) > 0.05 OR coalesce(r.rebate_from_titan_eth,0) > 0.05ORDER BY net_contribution_eth DESCLIMIT 50