Inspiration
Polymarket has become one of the most infamous and effective platforms for trading real-world events in recent years. It's only problem is that a $1,000 conviction is limited to a $1,000 position. If you want to size up, you need to bring more cash.
Lenders are afraid to touch prediction markets because of how rapidly prices can change. For example, if Donald Trump died today, the market "Trump out as President before 2027?" will see its "Yes" shares skyrocket almost instantaneously. This is a fundamentally different environment for lenders than something like a stock or even meme token market, which is why I built Phoebe with a tailored and backtested risk management strategy.
What it does
Phoebe's smart contract system matches traders who seek to lever up their Polymarket positions with risk tolerant lenders.
Traders:
- Post USDC.e margin, pick a market and an outcome, and choose up to 4x leverage.
- Phoebe borrows the rest from its lending pool and buys real Polymarket outcome shares, which it holds as collateral.
- It tracks each position's loan against the live Polymarket price. When a position's debt passes the market's liquidation limit, it becomes eligible for liquidation.
- Closing sells the shares and repays the loan in one transaction. If the market resolves first, the position settles automatically at Polymarket's payout.
Lenders choose a tranche:
- Senior is paid first and takes losses last.
- Junior takes losses first, and in exchange earns higher interest plus every opening and liquidation fee.
The risk engine adjusts leverage in real time:
- Leverage shrinks as a price nears 0 or 1, as volatility rises, and as resolution approaches.
- By the final day before resolution, no leveraged position is left open for the final jump to 0 or 1.
How we built it
- Contracts (Solidity, Foundry, Polygon):
- LendingPool with ERC-4626 senior and junior vaults;
- PositionManager, which holds the real Polymarket shares;
- RiskEngine, which sets leverage limits from price bands, a time ramp before resolution and a volatility-based cap;
- KeeperOracle, which pushes prices and tracks realized volatility;
- KeeperVenue, where positions buy and sell shares.
- Execution: a transaction can't wait for an order-book fill, so positions trade against a market maker's inventory at the oracle price plus a spread.
- The maker stocks inventory without taking market risk, by splitting USDC.e into matched YES and NO pairs on Polymarket's core contract.
- When a trade leaves it lopsided, it buys the difference back on Polymarket's order book within seconds, so it stays flat.
- Keeper (TypeScript, Bun, viem): our oracle that pushes Polymarket prices on-chain, liquidates, absorbs bad positions into the pool, settles resolved markets and runs the hedger, with order caps, daily limits and a kill switch for the venue.
- Frontend (React, Vite, wagmi): reads everything straight from the chain, with no backend. Live on Polygon mainnet at phoebe.markets, plus an Amoy testnet with a faucet and a local mode that replays real Polymarket price history.
- Validation:
- Every resolved market we replayed was run through the real contracts, not a simulation of them.
- Fork tests deploy the whole protocol against Polymarket's live contracts, resolve a real market by impersonating its UMA oracle, and check that every dollar settles correctly.
Challenges we ran into
- Prices jump instead of moving smoothly. Standard lending assumes you can liquidate before collateral is worth less than the debt. On Polymarket that often isn't true, so we stopped aiming for zero bad debt. The goal became a lender book that's profitable across many markets, which led to the time ramp, the volatility cap and the senior/junior structure.
- No atomic execution. Polymarket's order book is off-chain, so a transaction can't buy shares there. The answer was a market-neutral maker that stocks matched YES/NO pairs and hedges afterwards, plus a kill switch that stops trading if hedging can't keep up.
Accomplishments that we're proud of
- It's live and working on Polygon mainnet against real Polymarket markets!
What we learned
- For binary markets, when you allow leverage matters more than how much. Most of the backtest improvement came from removing leverage before resolution and in turbulent markets, not from a lower overall limit.
- Splitting lenders by risk appetite
What's next for Phoebe
- Security: an audit, a multisig owner, and separate keys for the oracle, the liquidator and the market maker.
- Decentralization:
- a decentralized price feed, for example signed Polymarket prices with fallbacks; the current system still relies on a benevolent offchain keeper.
- Growth:
- more markets, including Polymarket's multi-outcome (neg-risk) markets;
- higher caps as the system proves itself;
- automatic pausing on breaking news.
Built With
- polygon
- solidity
- vite