Inspiration
On systems like Uniswap v3, liquidity providers only earn fees while the price stays inside the range they pick. Pick too narrow, and the price walks out; pick too wide, and you earn almost nothing. Most range tools make that choice by looking backward at historical volatility, which is blind to the things that actually move markets: a Fed decision tomorrow, a big announcement this afternoon.
Prediction markets do the opposite: traders put real money on what will happen. When we noticed that Gemini lists a daily Bitcoin "ladder" of about 20 contracts ("BTC ≥ \$61,000 at 4 PM", "BTC ≥ \$61,500", …), we realized that read together, it's the crowd's entire forecast of where BTC will close. We wanted to see what happens if liquidity providers set their ranges from that forward-looking signal instead of the past.
What it does
Rangefinder turns Gemini's live ladder into a probability curve, recommends the range BTC is most likely to stay in at the confidence you choose, records every decision in a smart contract, rebalances automatically when the crowd moves (with guardrails), hedges through Gemini's trading API, and checks how trustworthy the crowd has been using Gemini's own settlement data.
How we built it
Forecast from prices. Each contract's YES price is the crowd's probability that BTC finishes above its strike $K$: $$p(K) \approx P(S > K), \quad p(K) = \frac{\text{bestBid} + \text{bestAsk}}{2}$$ We sort by strike, force the curve to be non-increasing (a higher strike can't be more likely), and interpolate linearly between strikes.
Choosing the range. Starting at the median $m$, where $p(m) = 0.5$, we widen both sides until the range holds the target confidence $c$: $$P(L \le S \le H) = p(L) - p(H) \ge c$$
Onchain record. Our Solidity contract, RangeVault, on Base Sepolia stores each range and emits RangeSet, Rebalanced and ProtectionRecorded events, sent from a backend wallet with viem.
Watch mode. Every 60 seconds the app re-reads Gemini and rebalances when the crowd's median moves far enough: $$|m_{\text{live}} - m_{\text{recorded}}| \ge \tau \cdot (H - L)$$ with guardrails: at least 5 minutes between moves, at most 3 per hour, and a \$1/hour hedge budget. After each automatic rebalance, it re-hedges on Gemini's sandbox and records the order onchain.
Proving the crowd. From Gemini's trade history, we rebuild what the crowd predicted hours before each past settlement and score it against Gemini's official settlement price, as a 5-day report card and an hour-by-hour replay.
Stack: Next.js 16 (TypeScript), Tailwind, Recharts, viem, Solidity, Base Sepolia, Gemini Prediction Markets API (public and sandbox), Vercel.
Challenges we ran into
- Testing a live product. Everything runs on real Gemini data, so at first we had to wait for data to show up. The live timeline only fills in minute by minute, and the daily ladder resets at 4 PM.
- Sandbox ≠ production. Gemini's sandbox lists different contracts than production, so our hedge route finds the nearest sandbox contract to the strike we want.
- Numbers too big for JavaScript. Gemini order IDs overflow JavaScript's number type, so we parse them as strings to avoid losing digits.
- Thin markets lie. A few failed trade-history requests once produced a "\$300-wide range with 86% probability." We added a data-quality guard that refuses to score jumpy curves.
- Curves that become cliffs. Near the 4 PM expiry, prices collapse toward \$0 or \$1, so we skip ladders that expire within 3 hours.
- Designing the interface. We debated the layout and logo a lot, and ended up with one page per feature, each with a "what it does" and "how to use it" section, plus a logo whose glint changes color with how much traders agree.
Accomplishments that we're proud of
- Five Gemini integrations working end to end: live odds, settlements, trade history, sandbox orders and order history.
- A bot that actually acts (rebalancing onchain and hedging on Gemini) with visible guardrails.
- A report card showing the crowd's range held on most recent days, and that on the day it missed, the hedge would have paid out.
What we learned
- A prediction-market ladder is a probability distribution. One contract says little; together they describe the crowd's whole forecast.
- Data quality beats clever math. Thin trading, stale prices and partial API failures broke our results faster than any formula did.
- Guardrails are part of the product. An autonomous bot needs cooldowns, caps, budgets and logs before anyone should trust it.
- Practical engineering: signing Gemini's private REST requests with HMAC-SHA384, sending transactions with viem, keeping secrets server-side, and splitting server and client components in Next.js 16.
- Shipping under pressure: agree on the API contract first, build against mocks, merge small and often, and cut scope before cutting honesty.
What's next for Rangefinder
- Uniswap integration: turn the recommended range into Uniswap v3 ticks against a live pool, then open and manage real positions automatically, widening before scheduled events.
- Hold deposits in a vault so liquidity providers can opt in without managing anything themselves.
- Forecast oracle: publish the crowd's forecast onchain so lending protocols, AMMs and other vaults can use it too.
Built With
- base-sepholia
- claude
- github
- next.js
- node.js
- recharts
- solidity
- tailwindcss
- typescript