Query editor
with b as (select date as day,avg(difficulty) as diff,sum(total_reward) as btc_out,count(*) as n_blocksfrom bitcoin.blockswhere date >= date '2024-01-01'group by 1having count(*) >= 100),p as (select cast(day as date) as day, pricefrom prices.usd_dailywhere symbol = 'BTC' and blockchain is null and day >= timestamp '2024-01-01'),h as (select b.day, p.price, b.btc_out,-- network hashrate in TH/s, rescaled to a full day of blocksb.diff * power(2, 32) / 600 / 1e12 as hashrate_ths,-- fleet efficiency assumption, J/TH32 - 11 * cast(date_diff('day', date '2024-01-01', b.day) as double) / cast(date_diff('day', date '2024-01-01', date '2026-12-05') as double) as efffrom b join p on p.day = b.day)select day,price as btc_price,hashrate_ths * eff * 0.024 * 0.04 / (btc_out * 144.0 / 144) as cost_4ct,hashrate_ths * eff * 0.024 * 0.06 / (btc_out * 144.0 / 144) as cost_6ct,hashrate_ths * eff * 0.024 * 0.08 / (btc_out * 144.0 / 144) as cost_8ctfrom horder by day