Inspiration

Lending markets set loan-to-value limits by governance vote and rarely change them. When volatility arrives, limits are still the calm-week numbers, so the protection arrives after the move. Forward-looking volatility usually comes from options markets, which most long-tail assets do not have. Gemini's prediction markets already price where these assets will be at expiry, including ZEC, so Brace uses those odds to tighten limits before the move instead of after it.

What it does

Brace is a live risk oracle and a small lending pool on Solana devnet. Every minute it reads Gemini's "price X or above" prediction market ladders for SOL, BTC, ETH, XRP and ZEC, works out the implied volatility onchain, and turns it into a loan-to-value limit. The pool enforces that limit on every borrow: over the limit, the program rejects the transaction; under it, the borrow goes through. A public risk board, a borrow page that works in Phantom on a phone, and a history page show it live.

How we built it

A Cloudflare Worker reads Gemini's public prediction market API once a minute and posts the raw bid and ask quotes to an Anchor program on Solana devnet. The program does the math with integers only: it turns each probability into a z-score, fits a line across the strikes, reads off implied volatility and the implied median, checks spot against that median, and sets limit = 80% x (1 - 3 x the 24-hour move), capped at 75%. Borrow and withdraw check that limit. A QuickNode Stream on the Block dataset, filtered to the program, sends every transaction, including rejected borrows, to the Worker, which stores it in D1 and serves the history the app charts.

What makes it different

Prediction markets used as risk infrastructure, not another betting app. The volatility number is computed onchain from raw quotes, so the relayer cannot post a made-up value. It is fail safe: thin, stale or inconsistent data never loosens a limit, it holds, steps down, and pauses borrowing after an hour. Odds never liquidate anyone; liquidation stays at a fixed 80%. And it covers assets with no options market, like ZEC, because Gemini lists them.

Proof

  • Program (devnet): Frv6CVJKADmkM2cnBSMKgBWPvtHsfYkfye5d4vB84WyC on Solana Explorer
  • Rejected over-limit borrow, log brace blocked ltv=7208 limit=6954
  • Accepted borrow, log ltv=2303 limit=6952
  • 52 Rust tests (including a 3,000-action fuzz run), 76 Worker tests, 72 app tests; five separate security review passes, every finding fixed with a test

Challenges

Gemini's ladders are thin: quotes exist but trades are rare. That is why every post gets a confidence check and stale data only ever lowers a limit. Fitting a probit curve with integer math inside Solana's compute budget took a lookup table and a careful least-squares fit; a SOL post uses about 40,700 compute units.

What's next

A check_borrow instruction other Solana lending programs can call by CPI, so any market can use the limit. Signed or multi-source quotes so the relayer is no longer trusted. Measured accuracy: Alchin's tracker scores each limit against the moves that actually happened. Then more assets as Gemini lists them, and a mainnet pilot with a real lending market.

Built with AI

Code, tests and docs were written with AI coding assistants (Claude and Grok), directed by Oh-Jay, who made the product decisions and handled every wallet and account step. Every change passed its tests before merge.

Built With

  • anchor
  • cloudflare-d1
  • cloudflare-workers
  • gemini-prediction-markets
  • litesvm
  • next.js
  • phantom
  • quicknode-streams
  • react
  • rust
  • solana
  • spl-token
  • typescript
  • vercel
  • vitest
Share this project:

Updates

Submission history