Query editor
with recursive staking_rewards_txns as (--Staking rewards txns before 2021-04-30select date_trunc('day',t."evt_block_time") as "evt_block_time", sum(t."value"/1e18)*100/5 as amount,max(sbm.amount_cumu ) as total_supply,sum(t."value"/1e18) as amount_treasuryfrom erc20."ERC20_evt_Transfer" tleft join (select evt_block_time as time,lead("evt_block_time", 1, now()) over (order by "evt_block_time") AS next_time,sum(amount/1e18) over (order by evt_block_time) amount_cumufrom lido."steth_evt_Submitted"where evt_block_time < '2021-04-30'order by "evt_block_time" ) sbm on t."evt_block_time" >= sbm.time and t."evt_block_time" < sbm.next_timewhere t."to" = '\x3e40d73eb977dc6a537af587d48316fee66e9c8c' --Lido Treasury, 5%and t."from" = '\x0000000000000000000000000000000000000000'and t."contract_address" = '\xae7ab96520de3a18e5e111b5eaab095312d7fe84'and t."evt_block_time" < '2021-04-30'and not exists (select 1 from lido."steth_call_totalSupply" s where s."call_tx_hash" = t."evt_tx_hash")group by 1union all--Staking rewards txns since 2021-04-30select date_trunc('day',t."evt_block_time") , sum(t."value"/1e18)*100/5 as amount,max(s.output_0/1e18) as total_supply, sum(t."value"/1e18) as amount_treasuryfrom erc20."ERC20_evt_Transfer" tleft join lido."steth_call_totalSupply" s on t."evt_tx_hash" = s."call_tx_hash"where t."to" = '\x3e40d73eb977dc6a537af587d48316fee66e9c8c' --Lido Treasury, 5%and t."from" = '\x0000000000000000000000000000000000000000'and t."contract_address" = '\xae7ab96520de3a18e5e111b5eaab095312d7fe84'and s.call_trace_address[1] = '1'and s.call_trace_address[2] = '0'group by 1order by 1 desc), rewards_without_commission as (select "evt_block_time" as time,lead("evt_block_time", 1, date_trunc('day',now())) over (order by "evt_block_time") AS next_time,(amount*0.9) as rewards,total_supplyfrom staking_rewards_txns), pool_operations as (selecttotal.time,steth_in,steth_out,sum(steth_in) over (order by total.time asc rows between unbounded preceding and current row) + sum(steth_out) over (order by total.time asc rows between unbounded preceding and current row) as steth_pool,sum(eth_in_calc) over (order by total.time asc rows between unbounded preceding and current row) + sum(eth_out_calc) over (order by total.time asc rows between unbounded preceding and current row) as eth_pool,(price_steth_by_eth-1)*100 as price_to_eth,coalesce(r.rewards,0) as rewards,coalesce(r.total_supply,1) as total_supplyfrom(selectCOALESCE(t_price.time,exchange_eth_steth.time, steth_turnover.time, RemoveLiquidity.time, RemoveLiquidityImbalance.time, RemoveLiquidityOne_eth.time, RemoveLiquidityOne_steth.time, AddLiquidity.time) as time,t_price.weight_avg_price as price_steth_by_eth,