Inspiration

What it does

Ladder Hedge is a web app for someone holding SOL, BTC, ETH or XRP who wants a hard cap on their loss by a set time. It reads Gemini's live crypto price ladders ("SOL above $72 at 5pm ET", "above $73", ...), and computes the lowest-cost basket of those contracts that keeps the holder's loss above a floor they choose, at expiry, in every price interval the ladder defines. Prices are the asks you would actually pay, plus Gemini's taker fee, capped at the size the order book shows. The app shows the payoff before and after, the worst case before and after, the net expected cost with the up-front cost and the market-implied expected payout beneath it, the largest position the quotes can protect, and any inconsistent quotes on the ladder. A "paper fill" saves the plan and writes its SHA-256 hash to Solana devnet as a memo signed by the user's wallet.

What problem it solves

Prediction-market ladders are, in effect, a strip of digital options on one settlement price, which makes them a natural hedge for a spot holder. But nobody holding SOL wants to work out by hand which of twenty contracts to buy, in what size, after a fee that depends on price, with one-sided books and thin depth. Picking contracts by eye either overpays or leaves gaps. Ladder Hedge turns "I can stomach losing $10 by 5pm" into a specific, executable basket and tells you plainly what it costs, where the protection ends (below the lowest strike, and only at expiry), and whether the book is deep enough. It never claims profit: it shows the expected payout at market-implied probabilities next to the cost, so the price of protection is visible.

How it works

  • Data: Next.js route handlers call Gemini's public Prediction Markets API (/v1/prediction-markets/events and /events/{ticker}) for ladders and best bid and ask, read the size at the best price from Gemini's market-data WebSocket ({instrumentSymbol}@bookTicker), and take spot from Gemini's public ticker. If Gemini is unreachable, captured snapshots are served and labelled "Snapshot", and the page says that live data failed and why, with a retry; a refresh that fails keeps the last live quotes on screen rather than swapping in a snapshot. Month-end snapshots (expiring November 30) keep the fallback usable after the daily ladders expire.
  • Engine (pure TypeScript, runs in the browser): a ladder with n strikes splits the expiry price into n + 1 intervals. Every contract pays a fixed amount inside each interval, and a long holder's loss is worst at an interval's lower edge, so the floor only needs checking at n + 1 points. Stage 1 is a linear program (yalps) that minimises cost subject to the floor in every interval and the size caps. If the floor is out of reach, stage 2 finds the best reachable worst case and returns the cheapest plan that comes within a small slack of it (the smaller of 0.1% of position value and 5% of the achievable improvement), labelled "Floor out of reach"; the page shows that best reachable figure, the worst case of the basket, and why the basket stops short (the last part of the protection costs disproportionately more). A cash limit (default 10% of the position) caps what the plan may pay up front, fees included, as a hard constraint in both programs; when it is what stands in the way, the page says how much the floor would need. Quantities are rounded to Gemini's 0.01-contract steps, fees are rounded up to the cent, and if rounding breaches the floor the engine re-solves with a tighter floor until it holds.
  • Solana: a Wallet Standard wallet supplies the SOL balance as the exposure and signs a one-instruction SPL Memo transaction (MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr, devnet) carrying the plan's hash. Receipts are read back with getSignaturesForAddress and marked "Hash verified" only when a plan saved in the browser recorded that very transaction signature and the memo's ladder ticker and plan-hash prefix match it; a copied memo in someone else's transaction is shown as not verified. One signed receipt from a browser wallet on the deployed site is finalized on devnet and was read back as "Hash verified" (signature 3xDCJ7zKM9Wk83NCuFq9NKa7y2gdpJY5kiPL3FRR6ze5xrJE84KYXTnbGURDa9BFd9TXZt1LePm6vsrxnUrzctz9).

Built With

Share this project:

Updates

Submission history