Inspiration

Anyone who follows the crypto markets has had this thought: "if Bitcoin holds here, it probably runs to there." That's a hunch with two halves, and you are usually more confident in one than the other.

The bets on offer punish that. A parlay takes your whole stake when the first leg fails, even though your real idea was never tested. People lose money on being half right every day.

Sportsbooks solved this with "draw no bet," and with Gemini's prediction markets listed as price ladders, exchanges can solve them too. Every piece of a "money back if the first half fails" bet was sitting there. We found no one-tap version on a regulated exchange, so we built it.

What it does

Stakeback lets you bet on the second half of your hunch, and gives you your stake back if the first half doesn't happen.

Pick a level that has to hold, and a target. Reach the target and you win. If the first level fails, your stake comes back. If it holds and the target is missed, you lose the stake. The payoff is simplified for users, and you can see what a bet pays at every possible finishing price before you place it.

  • Stake Back: the bet with a refund built in, for prices rising or falling.
  • Range: a bet that a price stays between two levels.
  • Breakout: a bet on a big move, either way.
  • Basket: several bets on different assets in one step.
  • Hunch: drag to where you think the price finishes, and Stakeback lists the bets that pay best if you are right.

How we built it

Gemini's API is what makes this possible. Each level on a ladder is its own yes-or-no contract, you can buy and sell both sides, order books stream live over WebSocket, and hourly markets settle within seconds of closing.

A Stake Back buys YES on the target \(B\) and a sized NO on the first level \(A\). Since reaching \(B\) means \(A\) held, the fair price per $1 of payout is

$$\text{fair} = \frac{P(B)}{P(A)}$$

  • Executor (Node, TypeScript): sizes the refund order, checks the book's depth, places both orders over Gemini's WebSocket, and keeps a ledger.
  • Solana program (Anchor): a fingerprint of each call goes on chain when the bet is placed.
  • QuickNode Stream: delivers our program's transactions to a webhook that re-reads each one from Solana before adding a leaderboard row.
  • Web app (React, Vite): draggable levels, the market's odds as a histogram, and a proof page that checks a call from Solana.

Challenges we ran into

  • A sandbox is not a real market. Its books are about 20 cents wide, which is not reflective of reality.
  • Gemini pays out a matched YES and NO early. Our books were off by exactly $1.00 until we caught it on a real run. It now matches properly.
  • Two orders are not one. A market can stop taking orders between them. The executor hedges only what filled and sells back the rest.

What we learned

Every hard bug came from running real orders, never from a test double. This is genuinely something we'd use since so many of the bets, especially during times of volatility, fall under the category of ladder markets.

What's next for Stakeback

  • Real accounts: Gemini sign-in and production review.
  • Cheaper bets: resting orders in the book cuts the cost roughly in half and adds liquidity to Gemini's market.
  • More markets: raises the range of possibilities
  • The end goal: conditional contracts listed by Gemini directly.

Built With

Share this project:

Updates

Submission history