Query editor
-- with dates as (-- SELECT DISTINCT date_trunc('day', block_time) as date-- FROM ethereum.transactions-- WHERE block_time > timestamp '2023-01-01'-- )With steth_price as (select minute,price from prices.usdwhere blockchain = 'ethereum'and symbol = 'stETH'),withdraw as (select evt_tx_hash, evt_index, date_trunc('day',evt_block_time) as day_ts, amount as withdraw_amount, NULL as deposit_amount from lybra_finance_ethereum.Lybra_depositor_evt_WithdrawEther),deposit as (select evt_tx_hash, evt_index, date_trunc('day',evt_block_time) as day_ts, NULL as withdraw_amount, amount as deposit_amount from lybra_finance_ethereum.Lybra_depositor_evt_DepositEther),liquidated as (select evt_tx_hash, evt_index, date_trunc('day',evt_block_time) as day_ts, LiquidateEtherAmount as withdraw_amount, NULL as deposit_amount from lybra_finance_ethereum.Lybra_depositor_evt_LiquidationRecord),rigid_redemption as (select evt_tx_hash, evt_index, date_trunc('day',evt_block_time) as day_ts, etherAmount as withdraw_amount, NULL as deposit_amount from lybra_finance_ethereum.Lybra_depositor_evt_RigidRedemption),compiled as (select * from withdrawUNION ALLselect * from depositUNION ALLselect * from rigid_redemptionUNION ALLselect * from liquidated)-- select * from compiled-- limit 1,daily_aggregate as (select day_ts, sum(deposit_amount/1e18) as daily_deposit_amount,sum(withdraw_amount/1e18) as daily_withdraw_amount,sum(deposit_amount/1e18) - sum(withdraw_amount/1e18) as net_daily_amountfrom compiledgroup by 1),rolling_sum as (select day_ts,sum(net_daily_amount) over (order by day_ts) as total_daily_steth_amount,net_daily_amount as net_daily_steth_amount-- ,lead(day_ts, 1, date(NOW() + interval '1' day)) OVER (ORDER BY day_ts) AS next_day_tsFROM daily_aggregate)select rolling_sum.*,total_daily_stETHAdded,total_daily_payoutEUSD,daily_stETHAdded,daily_payoutEUSD,total_daily_eusd_amount,net_daily_eusd_amount,total_daily_servicefeeEUSD,daily_servicefeeEUSD,daily_payoutEUSD*100/total_daily_eusd_amount as eusd_daily_yield,