Query editor
WITHlp_flows_pre AS (SELECT DATE(evt_block_time) as "block_date", amount0/10e5 as "usdc", amount1/10e17 as "crispc", shares/10e17 as "lp", shares/10e17 as "lp_change", 'DEPOSIT' as "transaction_type"FROM gamma_polygon.Hypervisor_XUSDC_CRISPC3_Polygon_evt_DepositUNION ALL (SELECT DATE(evt_block_time) as "block_date", amount0/10e5 as "usdc", amount1/10e17 as "crispc", shares/10e17 as "lp", -1*(shares/10e17) as "lp_change", 'WITHDRAW' as "transaction_type"FROM gamma_polygon.Hypervisor_XUSDC_CRISPC3_Polygon_evt_Withdraw)),lp_flows AS (SELECT *, crispc/lp AS "crispc_per_lp", usdc/lp AS "usdc_per_lp"FROM lp_flows_preORDER BY block_date)SELECT *, SUM(lp_change) OVER(ORDER BY block_date) as "lp_balance"FROM lp_flows