Query editor
WITH deposits AS (SELECTtoAccountIndex,baseAmountFROM lighter_v2_ethereum.zklighter_evt_depositWHERE contract_address = 0x3b4d794a66304f130a4db8f2551b0070dfcf5ca7AND assetIndex = 3),withdrawals AS (SELECTaccountIndex,baseAmountFROM lighter_v2_ethereum.zklighter_evt_withdrawWHERE contract_address = 0x3b4d794a66304f130a4db8f2551b0070dfcf5ca7AND assetIndex = 3),net_calculations AS (SELECT toAccountIndex as accountIndex, baseAmount/1e6 as amount FROM depositsUNION ALLSELECT accountIndex, -baseAmount/1e6 as amount FROM withdrawals -- Negate withdrawals for subtraction)SELECTaccountIndex,SUM(amount) AS net_amountFROM net_calculationsGROUP BY 1ORDER BY net_amount DESClimit 1000