Query editor
WITH params AS (SELECT0x936facdf10c8c36294e7b9d28345255539d81bc7 AS receipt_token),-- inflows (receipt token minted or received)inflows AS (SELECT"to" AS addr,SUM(value)/1e18 AS inflowFROM erc20_ethereum.evt_TransferWHERE contract_address = (SELECT receipt_token FROM params)GROUP BY 1),-- outflows (receipt token burned or sent away)outflows AS (SELECT"from" AS addr,SUM(value)/1e18 AS outflowFROM erc20_ethereum.evt_TransferWHERE contract_address = (SELECT receipt_token FROM params)GROUP BY 1),-- net balances = current vault share holdingsbalances AS (SELECTCOALESCE(i.addr, o.addr) AS holder,COALESCE(i.inflow,0) - COALESCE(o.outflow,0) AS balanceFROM inflows iFULL OUTER JOIN outflows o ON i.addr = o.addr)SELECTholder,balance AS shares_held,RANK() OVER (ORDER BY balance DESC) AS rankFROM balancesWHERE balance > 0ORDER BY balance DESCLIMIT 50;