Query editor
-- h/t https://dune.com/rp_community-- Original query: https://dune.com/queries/1286351/*TODO - get dots on the zero line for RP periodsTODO - programmatically get time/block ranges*/-- The Rocket Pool oDAO reports the protocol balances every ~24 hours which forms the rETH peg price.-- This table has one row per peg price update, which includes:-- - rETH peg price as reported by Rocket Pool oDAO-- - Market price of rETH for the reporting period immediately preceeding the rETH peg price update. This is a volume-weighted average price (VWAP) over the period.-- - Market price of stETH for the same period.WITH/*rpl_inflation_periods AS (SELECTDATE_TRUNC('day', to_timestamp("inflationCalcTime")) AS day,'RP Period' AS Project,0 AS token_amountFROM rocketpool."RocketTokenRPL_evt_RPLInflationLog"ORDER BY evt_block_time DESCLIMIT 4),*/reth_trades AS (SELECTblock_time AS time,CASE WHEN token_a_symbol = 'rETH' THEN token_a_amount ELSE token_b_amount END AS reth_amount,usd_amountFROM dex.tradesWHERE token_a_symbol = 'rETH' OR token_b_symbol = 'rETH'AND category = 'DEX'AND block_time >= '2022-01-01'),reth_trades_eth_amount AS (SELECTt.time,t.reth_amount,t.usd_amount / p.price AS eth_amount -- Trade size in USD divided by USD/ETH is amount of USD.FROM reth_trades tJOIN prices.usd pON p.minute = DATE_TRUNC('minute', t.time)AND p.symbol = 'WETH'-- We need to drop trades if the ETH amount will be unknown. This drops the rETH/RPL pair since USD amount is not reported.AND t.usd_amount IS NOT NULLAND p.price IS NOT NULLAND p.price > 0),steth_trades AS (SELECTblock_time AS time,CASE WHEN token_a_symbol = 'stETH' THEN token_a_amount ELSE token_b_amount END AS steth_amount,usd_amount