Query editor
-- This query used incompatible data types from Dune SQL alpha and may need to be updated.-- More details can be found on https://dune.com/docs/query/dunesql-changes/with dates as (with day_seq as( select (sequence(cast('2022-01-01' as date), cast(now() as date),interval '1' day)) day )select days.dayfrom day_seqcross join unnest(day) as days(day)), submitted as (selectdate_trunc('day',evt_block_time) as time,lead(date_trunc('day',evt_block_time), 1, date_trunc('day',now() + interval '1' day)) over (order by date_trunc('day',evt_block_time)) as next_time,sum(cast(amount as double))/1e18 as amountfrom lido_ethereum.steth_evt_Submittedgroup by 1), deposits as (select date_trunc('day', block_time) as time,sum(amount_staked)*pow(10,18) as amountfrom staking_ethereum.depositswhere depositor_entity = 'Lido'group by 1), labeled_swaps as (selectDATE_TRUNC('day', evt_block_time) as time,buyer,sum(cast(tokens_bought as double))/1e18 as steth_removed_ex,sum(cast(tokens_sold as double))/1e18 as eth_added_ex,count(*) as txncnt,l.name as contract,m.name as mevfrom curvefi_ethereum.steth_swap_evt_TokenExchange sleft join labels.contracts l on lower(cast(s.buyer as varchar)) = lower(cast(l.address as varchar))left join labels.mev_ethereum m on lower(cast(s.buyer as varchar)) = lower(cast(m.address as varchar))where cast(sold_id as double) = 0group by 1,2,6,7), arbitrageurs as (select distinct buyerfrom labeled_swapswhere contract like '%swap%'or mev = 'MEV'or (txncnt >=20 and lower(contract) not like '%bridge%'))--Purchases of stETH in Curve main pool, purchase_steth_removals_curve_main as (selectDATE_TRUNC('day', evt_block_time) as time,sum(cast(tokens_bought as double))/1e18 as steth_removed_ex,sum(cast(tokens_sold as double))/1e18 as eth_added_exfrom curvefi_ethereum.steth_swap_evt_TokenExchange swhere buyer not in (select buyer from arbitrageurs)and cast(sold_id as double) = 0