Query editor
with usdc as (select cast(date_trunc('day', evt_block_time) as date) day, evt_tx_hash tx, "from" f, "to" t, value/1e6 amtfrom erc20_arbitrum.evt_Transferwhere contract_address = 0xaf88d065e77c8cC2239327C5EDb3A432268e5831and evt_block_date >= date '2026-09-01'and ("from" in (0x9cA80193712F372e2ff33A00127292884F6F8598, 0x1410FA3F87F6A6ea221E5D2aB608C23005eC34f3)or "to" in (0x9cA80193712F372e2ff33A00127292884F6F8598, 0x1410FA3F87F6A6ea221E5D2aB608C23005eC34f3))), share as (select cast(date_trunc('day', evt_block_time) as date) day, evt_tx_hash tx, "from" f, "to" t, value/1e6 amtfrom erc20_arbitrum.evt_Transferwhere contract_address = 0x9cA80193712F372e2ff33A00127292884F6F8598 and evt_block_date >= date '2026-09-01'), mint_tx as (select distinct tx from share where f = 0x0000000000000000000000000000000000000000),days as (select day from unnest(sequence(date '2026-09-30', current_date, interval '1' day)) as x(day)), vd as (select day,sum(case when t = 0x9cA80193712F372e2ff33A00127292884F6F8598 then amt when f = 0x9cA80193712F372e2ff33A00127292884F6F8598 then -amt else 0 end) vault_net,sum(case when t = 0x9cA80193712F372e2ff33A00127292884F6F8598 and f <> 0x1410FA3F87F6A6ea221E5D2aB608C23005eC34f3 and tx in (select tx from mint_tx) then amt else 0 end) lp_deposits_usd,sum(case when t = 0x9cA80193712F372e2ff33A00127292884F6F8598 and f <> 0x1410FA3F87F6A6ea221E5D2aB608C23005eC34f3 and tx not in (select tx from mint_tx) then amt else 0 end) injection_usd,sum(case when f = 0x9cA80193712F372e2ff33A00127292884F6F8598 and t <> 0x1410FA3F87F6A6ea221E5D2aB608C23005eC34f3 then amt else 0 end) lp_withdrawals_usd,sum(case when t = 0x9cA80193712F372e2ff33A00127292884F6F8598 and f = 0x1410FA3F87F6A6ea221E5D2aB608C23005eC34f3 then amt else 0 end) from_diamond_usd,sum(case when f = 0x9cA80193712F372e2ff33A00127292884F6F8598 and t = 0x1410FA3F87F6A6ea221E5D2aB608C23005eC34f3 then amt else 0 end) to_diamond_usd,sum(case when t = 0x1410FA3F87F6A6ea221E5D2aB608C23005eC34f3 then amt when f = 0x1410FA3F87F6A6ea221E5D2aB608C23005eC34f3 then -amt else 0 end) diamond_netfrom usdc group by 1), sd as (select day, sum(case when f = 0x0000000000000000000000000000000000000000 then amt when t = 0x0000000000000000000000000000000000000000 then -amt else 0 end) supply_netfrom share group by 1), deltas as (select day, addr, sum(d) d from (select day, t addr, amt d from share where t <> 0x0000000000000000000000000000000000000000union all select day, f addr, -amt d from share where f <> 0x0000000000000000000000000000000000000000) group by 1,2), bal as (select addr, day, sum(d) over (partition by addr order by day) b,lead(day, 1, date '2100-01-01') over (partition by addr order by day) nxtfrom deltas), holders as (select d.day, count(distinct h.addr) lp_holdersfrom days d join bal h on d.day >= h.day and d.day < h.nxt and h.b > 0.001group by 1), first_dep as (select day, count(*) new_lps from (select f addr, min(day) day from usdcwhere t = 0x9cA80193712F372e2ff33A00127292884F6F8598 and f <> 0x1410FA3F87F6A6ea221E5D2aB608C23005eC34f3 and tx in (select tx from mint_tx)group by 1) group by 1)select d.day,sum(coalesce(vd.vault_net,0)) over (order by d.day) as vault_tvl_usd,sum(coalesce(vd.diamond_net,0)) over (order by d.day) as diamond_usdc_usd,sum(coalesce(sd.supply_net,0)) over (order by d.day) as nusdc_supply,sum(coalesce(vd.vault_net,0)) over (order by d.day) / nullif(sum(coalesce(sd.supply_net,0)) over (order by d.day),0) as share_price,coalesce(vd.lp_deposits_usd,0) lp_deposits_usd,coalesce(vd.lp_withdrawals_usd,0) lp_withdrawals_usd,coalesce(vd.injection_usd,0) injection_usd,sum(coalesce(vd.lp_deposits_usd,0) - coalesce(vd.lp_withdrawals_usd,0)) over (order by d.day) as cum_net_lp_deposits_usd,coalesce(vd.from_diamond_usd,0) from_diamond_usd,coalesce(vd.to_diamond_usd,0) to_diamond_usd,sum(coalesce(vd.from_diamond_usd,0) - coalesce(vd.to_diamond_usd,0)) over (order by d.day) as cum_vault_net_from_diamond_usd,coalesce(fd.new_lps,0) new_lps,sum(coalesce(fd.new_lps,0)) over (order by d.day) cum_lps,