SELECT block_id, reftable.block_timestamp,
1e8 * asset_e8 / rune_e8 AS satoshi_per_rune,
asset_e8, rune_e8, synth_e8,
ABS(satoshi_per_rune - 8303) AS target_distance
FROM (thorchain.defi.fact_block_pool_depths AS reftable INNER JOIN thorchain.core.dim_block
ON reftable.dim_block_id = dim_block.dim_block_id)
WHERE pool_name = 'BTC.BTC'
AND target_distance <= 0.1
QUALIFY target_distance = MIN(target_distance) OVER(PARTITION BY DATE(reftable.block_timestamp))
ORDER BY block_id DESC
LIMIT 1000