Query editor
WITH daily_net AS (SELECTCAST(date_trunc('day', block_time) AS date) AS day,SUM(CASEWHEN "to" IN (0xd2400706889d650dc12B8912E3913b1b27f0b7be)THEN amount_raw / 1e18WHEN "from" IN (0xd2400706889d650dc12B8912E3913b1b27f0b7be)THEN -(amount_raw / 1e18)ELSE 0END) AS net_amountFROM tokens.transfersWHERE contract_address = 0x0fc2a55d5BD13033f1ee0cdd11f60F7eFe66f467AND ("to" IN (0xd2400706889d650dc12B8912E3913b1b27f0b7be)OR "from" IN (0xd2400706889d650dc12B8912E3913b1b27f0b7be))GROUP BY 1),calendar AS (SELECT dayFROM UNNEST(sequence((SELECT min(day) FROM daily_net),current_date,interval '1' day)) AS t(day)),cumulative_balance AS (SELECTc.day,SUM(COALESCE(d.net_amount, 0)) OVER (ORDER BY c.day) AS cumulative_la_balanceFROM calendar cLEFT JOIN daily_net dON c.day = d.day)SELECTday,cumulative_la_balanceFROM cumulative_balanceORDER BY 1;