Query editor
with price_data as (select date_trunc('week', "minute") as mkt_date, symbol, avg(price) as avg_pricefrom prices.usdwhere (blockchain = 'solana' and symbol = 'MSOL')or (blockchain is null and symbol = 'SOL')and date_trunc('day', "minute") < current_dategroup by date_trunc('week', "minute"), symbol), aligned_data as (select p.mkt_date, p.symbol, p.avg_pricefrom price_data pjoin (select max(first_date) as first_common_datefrom (select symbol, min(date_trunc('week', "minute")) as first_datefrom prices.usdwhere (blockchain = 'solana' and symbol = 'MSOL')or (blockchain is null and symbol = 'SOL')and date_trunc('day', "minute") < current_dategroup by symbol) first_dates) common_dateson p.mkt_date >= common_dates.first_common_date), lagged_prices as (select mkt_date, symbol, avg_price, lag(avg_price) over (partition by symbol order by mkt_date) as prev_avg_pricefrom aligned_data), returns_calculated as (select mkt_date, symbol, avg_price, casewhen prev_avg_price is not null then ln(avg_price / prev_avg_price)else nullend as returnfrom lagged_prices), formatted_price_data as (select mkt_date, max(case when symbol = 'SOL' then avg_price end) as sol_price, max(case when symbol = 'MSOL' then avg_price end) as msol_price, max(case when symbol = 'SOL' then return end) as sol_return, max(case when symbol = 'MSOL' then return end) as msol_returnfrom returns_calculatedgroup by mkt_date), daily_events as (select date_trunc('week', call_block_date) as txn_date, casewhen event_type = 'mint' then amount / 1e9else 0