Query editor
-- Observed additional fee streams. POL uses actual fee collections, not estimated accrual.WITH pol_claims AS (SELECT DISTINCT tx_hash,block_date FROM robinhood.logsWHERE block_date>=date '2026-07-17' AND block_date<current_dateAND contract_address=0x8366a39cc670b4001a1121b8f6a443a643e40951AND topic1=0xd33c8fd38b06e989cdbd4dffdefab71c4bdd415b24964c8d69e38ff35b068f92AND topic2=0x00000000000000000000000058daec3116aae6d93017baaea7749052e8a04fa7AND topic0=keccak(to_utf8('ModifyLiquidity(bytes32,address,int24,int24,int256,bytes32)'))AND varbinary_substring(data,65,32)=0x0000000000000000000000000000000000000000000000000000000000000000AND varbinary_substring(data,97,32)=0x000000000000000000000000000000000000000000000000000000000002ae58), pol AS (SELECT t.block_date day,'Protocol-owned LP' product,'STONK/ETH fees collected' surface,t.contract_address token,sum(cast(t.amount_raw AS double)) fees_raw,sum(cast(t.amount_raw AS double)) treasury_raw,0e0 rewards_rawFROM tokens.transfers t JOIN pol_claims p ON p.tx_hash=t.tx_hash AND p.block_date=t.block_dateWHERE t.blockchain='robinhood' AND t.block_date>=date '2026-07-17' AND t.block_date<current_dateAND t."from"=0x8366a39cc670b4001a1121b8f6a443a643e40951AND t."to"=0xb668382cf44038a3e8140e789060f6a809787cdaAND t.contract_address IN (0x0000000000000000000000000000000000000000,0xe934e36a439c94017b64a3fece66af12099abf50)GROUP BY 1,2,3,4), royalties AS (SELECT block_date day,'Special Projects' product,'Civilization royalties flushed' surface,varbinary_substring(topic1,13,20) token,sum(cast(varbinary_to_uint256(varbinary_substring(data,1,32)) AS double)+cast(varbinary_to_uint256(varbinary_substring(data,33,32)) AS double)) fees_raw,0e0 treasury_raw,0e0 rewards_rawFROM robinhood.logs WHERE block_date>=date '2026-09-01' AND block_date<current_dateAND contract_address=0x0296b9fb0ce78e2f6c95fdde8a4427aaaa325d87 AND topic0=keccak(to_utf8('Flushed(address,uint256,uint256)')) GROUP BY 1,2,3,4), all_rows AS (SELECT * FROM pol UNION ALL SELECT * FROM royalties), p AS (SELECT cast(timestamp AS date) day,contract_address,max(price) price,max(decimals) decimalsFROM prices.day WHERE blockchain='robinhood' AND timestamp>=timestamp '2026-07-17' AND timestamp<current_date GROUP BY 1,2), eth AS (SELECT cast(timestamp AS date) day,price FROM prices.day WHERE blockchain='ethereum'AND contract_address=0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 AND timestamp>=timestamp '2026-07-17' AND timestamp<current_date), valued AS (SELECT a.*,CASE WHEN token IN (0x0000000000000000000000000000000000000000,0x0bd7d308f8e1639fab988df18a8011f41eacad73) THEN e.price/1e18 ELSE p.price/pow(10,p.decimals) END unit_usdFROM all_rows a LEFT JOIN p ON a.day=p.day AND a.token=p.contract_address LEFT JOIN eth e ON a.day=e.day)SELECT day,product,surface,token,fees_raw,fees_raw*unit_usd fees_usd,treasury_raw*unit_usd treasury_revenue_usd,rewards_raw*unit_usd rewards_funding_usd,CASE WHEN unit_usd IS NULL AND fees_raw>0 THEN 1 ELSE 0 END unpriced_legs FROM valued ORDER BY 1,2,3