Query editor
/*-- @title: DSR Balance & Rate-- @author: Steakhouse Financial-- @description: Displays the latest 12-month trends in DAI+USDS balances within the DAI Savings Rate (DSR) and Sky Savings Rate (SSR) systemsand their corresponding rates-- @notes: N/A-- @version:- 1.0 - 2023-07-12 - Initial version- 2.0 - 2024-06-04 - Added header + code refactoring- 3.0 - 2024-10-08 - Added USDS and SKY Savings Rate- 4.0 - 2024-10-10 - Correctly identify SSR balance.- 5.0 - 2024-10-15 - Added in surplus buffer in the calculation.*/withdeltas as (-- DAIselectdst as address,date(evt_block_time) as dt,cast(wad as double) as deltafrom maker_ethereum.DAI_evt_Transferunion allselectsrc as address,date(evt_block_time) as dt,-cast(wad as double) as deltafrom maker_ethereum.DAI_evt_Transferunion allselectdst as address,date(call_block_time) as dt,cast(rad as double) / 1e27 as deltafrom maker_ethereum.VAT_call_movewhere call_successand dst IN (0x197e90f9fad81970ba7976f33cbd77088e5d7cf7)union allselectsrc as address,date(call_block_time) as dt,-cast(rad as double) / 1e27 as deltafrom maker_ethereum.VAT_call_movewhere call_successand src IN (0x197e90f9fad81970ba7976f33cbd77088e5d7cf7)union allselectv as address,date(call_block_time) as dt,cast(rad as double) / 1e27 as deltafrom maker_ethereum.VAT_call_suckwhere call_successand v IN (0x197e90f9fad81970ba7976f33cbd77088e5d7cf7)-- USDSunion allselect"to" AS address,date(evt_block_time) AS dt,cast(value as double) AS deltaFROM sky_ethereum.USDS_evt_TransferUNION ALL