Query editor
/*-- @title: Surplus - Monthly-- @author: Steakhouse Financial-- @description: Retrieves Sky's surplus buffer-- @notes: N/A-- @version:- 1.0 - 2023-06-23 - Initial version- 2.0 - 2024-10-03 - Using accounting v2*/withequity as (selectdate_format(ts, '%Y-%m') as month,sum(dai_value) as dai_value,sum(case when code not in (31810, -- Direct MKR Token Expenses33110, -- Treasury Assets33110, -- Vested MKR Token Expenses34110, -- MKR Contra Equity39999 -- Currency Translation to Presentation Token) then dai_value end) as protocol_surplus,sum(case when code in (33110, -- Treasury Assets39999 -- Currency Translation to Presentation Token) then dai_value end) as treasury_assetsfrom dune.steakhouse.result_sky_accountingwhere code / 10000 = 3group by 1),equity_agg as (selectmonth,sum(dai_value) over (order by month) as total_equity,sum(protocol_surplus) over (order by month) AS protocol_surplus,sum(treasury_assets) over (order by month) as treasury_assetsfrom equity)select * from equity_agg order by 1 desc