Query editor
with avg_rates as (selectavg(lnLastImpliedRate) ir,avg(timestamp) timestamp,mkt_address,date_trunc('hour',time) hourfromquery_4024437group by 3,4),markets as ((select *, 'mainnet' as chain from query_4021452)union all(select *, 'arbitrum' as chain from query_4021323)),market_rates as (selecthour,m.mkt_address,mkt_name,underlying,expiry,ir,chain,timestampfrom avg_rates r join markets mon r.mkt_address = m.mkt_addresswhere to_unixtime(current_date) - expiry < 86400 * 1),yt_prices as (selecthour,mkt_name,underlying,1 - 1/(pow(e(),-- (implied_rate * time_to_maturity) / (365.0*86400)((ir/1e18) * (expiry-timestamp)) / (365.0*86400))) as yt_price_underlying,expiry,chain,timestampfrommarket_rates),pre_result as (selecthour,underlying ticker,mkt_name market,(casewhen expiry - timestamp >0 then aprelse 0end) apr,chain,(casewhen expiry - timestamp >0 then YT_leverageelse 0end) YT_leveragefrom