Inspiration
Prediction markets have been shown to show leading odds with political and world events, however these odds live in the exchange and make it difficult for agents and DeFi protocols to access those probabilities. For example “30% chance Bitcoin ends the month below $60,000.”, That percentage is some of the best real-time risk data there is, but it stays on the exchange. Meanwhile, a lending protocol only finds out Bitcoin dropped when the liquidations start. We wanted those odds where the money is: on chain, where any contract or agent can use them.
What it does
Gemini Probability Oracle reads about 100 of Gemini’s prediction markets every minute. It turns each market’s midpoint price into a chance and posts it to a contract on Arc. Two things act on that number automatically:
Lending pools (DeFi): a protocol opts in once. As the chance of a Bitcoin drop rises, its loan limit steps down from 75% to 60% to 40%, then to no new borrowing. A QuickNode Stream delivers each update in 1–2 seconds and triggers the change on chain. For real protocols (Aave and Morpho), we show the same rule as read-only advice.
AI agent insurance: an agent pays $0.001 per read with x402 through Circle Gateway, checks its risk, and buys its own cover in USDC. Any agent can connect with one line over MCP. Each purchase also produces the exact Gemini order, sent to Gemini’s sandbox.
How we built it
Contracts: Solidity with Foundry on Arc testnet. OddsFeed stores the chances, RiskSwitch sets a pool’s tier, ProtectionBook takes premiums, and there’s a demo lending pool. Gas is paid in USDC, about $0.001 per post.
Oracle and server: TypeScript, Node, Express and viem. The server reads Gemini’s Prediction Markets API for order books and hourly candles, skips thin books, and posts when a market moves half a point or once an hour.
Payments: x402 with Circle Gateway nanopayments ($0.001 per read, settled in batches on Arc).
Events: a QuickNode Stream on Arc logs. A filter at QuickNode decodes our events, and they arrive at a webhook that checks QuickNode’s signature on every delivery.
Agents: an insurance desk with six MCP tools, served over HTTP so outside agents like Claude Code can connect.
Front end and hosting: plain HTML, CSS and JS with Chart.js, hosted on Railway.
Challenges we ran into
Thin markets: Some books have a huge spread or no bids at all. We had to decide when a price is trustworthy enough to post, and we skip a market if a side is missing or the spread is over 10 points.
Rate limits: Polling Arc’s public RPC hit rate limits, which is why we moved to QuickNode Streams for anything that has to react quickly.
Getting insurance right: Our first version bought cover on prices Bitcoin had already fallen below, which meant paying almost $1 for $1 of protection. An outside agent connected over MCP refused to buy and explained why. We fixed it so cover only protects against a real drop from today’s price and is sized to the actual loss.
Every protocol works differently: Aave V4 uses one collateral factor, Aave V3 separates loan-to-value from the liquidation threshold, and Morpho’s liquidation threshold can’t be changed. So the advice has to differ for each.
Real trading: Production Gemini trading needs a verified, funded account, so purchases produce the exact order and send it to the sandbox.
Accomplishments that we're proud of
What we learned
A market price isn’t automatically a clean probability: Spreads, empty books and missing trades are normal, especially for less popular markets. Most of the work in an oracle is deciding when not to post, and telling a value that hasn’t changed apart from one that’s out of date.
Read the real API before designing around it: Gemini’s response was far bigger than we expected (1.3 MB for three events, with nested sub-events and long rules text) and had no price history. Filtering early and using the candles endpoint changed our design.
USDC gas changes what’s practical: One transaction per market only makes sense at about a tenth of a cent. Posting on half-point moves plus an hourly update is a good balance between freshness and cost.
React to events instead of polling: Polling a public RPC hits rate limits and is still slower. Filtering at QuickNode meant our server only receives the events it acts on, already decoded. Because a webhook can trigger transactions, checking every signature isn’t optional.
AI agents make good critics: When Claude Code connected over MCP, it compared the odds with the prices, refused the bad cover and explained why. With agents as customers, clear tool descriptions and honest pricing matter as much as the code.
Every DeFi protocol needs its own advice: Aave V4 has one collateral factor that applies only to new positions, Aave V3 separates loan-to-value from the liquidation threshold, and Morpho’s liquidation threshold can’t change. The same odds lead to a different suggestion for each.
What's next for Gemini Probability Oracle
Batch many market updates into one transaction.
Add agent guardrails: budgets, maximum prices and owner approval for large purchases.
Real Gemini orders once the account is verified, so cover is backed by an actual hedge.
More market types (Fed decisions, inflation, events) for stablecoin and real-world-asset protocols.
Let real lending protocols opt in on mainnet.
Built With
- arc
- chart.js
- circle
- circle-gateway
- claude-code
- docker
- express.js
- foundry
- gemini
- gemini-prediction-markets-api
- javascript
- model-context-protocol
- node.js
- quicknode
- quicknode-streams
- railway
- solidity
- typescript
- usdc
- viem
- x402