Query editor
-- jared final #1WITH rev AS (SELECTSUM(IF("to" = 0x6b75d8af000000e20b7a7ddf000ba900b4009a80, CAST(value AS DOUBLE), 0) -IF("from" = 0x6b75d8af000000e20b7a7ddf000ba900b4009a80, CAST(value AS DOUBLE), 0)) / 1e18 AS total_revenue_wethFROM erc20_ethereum.evt_TransferWHERE contract_address = 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2AND ("to" = 0x6b75d8af000000e20b7a7ddf000ba900b4009a80 OR"from" = 0x6b75d8af000000e20b7a7ddf000ba900b4009a80)),cost AS (SELECTSUM(CAST(gas_price AS DOUBLE) * CAST(gas_used AS DOUBLE) / 1e18) AS total_gas_eth,COUNT(*) AS active_txs,COUNT(DISTINCT block_number) AS active_blocksFROM ethereum.transactionsWHERE "to" = 0x6b75d8af000000e20b7a7ddf000ba900b4009a80)SELECTr.total_revenue_weth,c.total_gas_eth,r.total_revenue_weth - c.total_gas_eth AS net_profit_eth,ROUND((r.total_revenue_weth - c.total_gas_eth) / NULLIF(r.total_revenue_weth, 0) * 100, 2) AS profit_margin_pct,ROUND(c.total_gas_eth / NULLIF(r.total_revenue_weth, 0) * 100, 2) AS gas_pct_of_revenue,c.active_txs,c.active_blocksFROM rev rLEFT JOIN cost c ON TRUE;