Inspiration

I study perpetual futures on stocks and commodities: who trades them and how they are priced. That research is unpublished and none of its findings are used here. It left me with two questions that became this project.

The first is about price. On an order book the price you see is not the price you get. There is a spread, the book thins when the market moves, and a larger order fills worse. Could a venue offer one price to everyone, with no book at all, and survive?

The second is about prediction markets. They have had almost no leverage. Kalshi has asked the CFTC for permission to offer margin. dYdX listed a 20x election market in 2024. Several teams are building leverage for these markets, and most have settled near 1 to 1.5x. The demand is plain. The mechanics are not solved.

I love designing new mechanics for financial products, and with OpenLiquid I designed a new way to trade prediction markets with leverage: a leveraged position wins what the same stake would win outright, and leverage brings that win closer.

OpenLiquid is a live experiment on Arc in how trading with no order book could work at scale. A blockchain is one of the best places to run an experiment like this: you can design a new economic mechanism, make its rules transparent, and test it in the open.

OpenLiquid opening page

What it does

OpenLiquid is a venue for leveraged trading on crypto, stocks, commodities and live prediction markets, on Arc. It is live on Arc testnet. Anyone can trade it with a one-click demo account.

Try it: open pramay2007.github.io/OpenLiquid, click Demo account, and trade.

Trading BTC with an open 100x position

No order book. No slippage in a calm market. Every trade fills at one price taken from a reference venue. A funded vault takes the other side. A position can lose its margin and nothing more, and a winner's maximum payout is locked in the vault before the position opens.

Filling at an outside price has an obvious weakness: anyone who can move that price for a moment can trade against the move. Four rules make it safe to offer.

  • Worse-of fills. Each trade fills at the worse, for the trader, of the live mid and a slow time-averaged price. In a calm market they are the same number. A pushed price moves the mid and not the slow price.
  • Depth-backed capacity. Open interest per side is capped at a fraction of the dollars really resting near the mid on the reference venue: half on crypto, a quarter on prediction markets.
  • Reserved payouts. Winners are paid at close.
  • No fee to open or close, and no funding between traders. Winners pay a share of profit. The larger side of a lopsided market pays a small crowding fee to the vault that is carrying it.
  • OLQ, the token designed to refill the vault. You earn OLQ by losing: the loss goes to the vault and you receive OLQ for it. The rate is boosted while the vault is drawn down, winners are paid first in, first out, and staking OLQ earns 30% of the fees winners pay.

You can read more deeply about the mathematics behind the mechanisms in our whitepaper over here - https://pramay2007.github.io/OpenLiquid/#docs

Leverage on prediction markets. This is the part we think is new.

The problem is the jump. The odds can go from 54 cents to 20 on one headline, and nobody can close a position in the middle of it. A loser at 10x can only lose the stake. A winner paid on the full move is owed several times that.

Our rule is that leverage zooms the odds. A leveraged position wins at most what its stake would win if you simply bought the shares, and never more than the stake. Leverage makes it reach that payout sooner. $100 on Yes at 54 cents wins $85.19 outright. At 10x it wins the same $85.19 when the odds reach 58.6 cents, and is stopped out at 48.6. The vault locks that $85.19 when the position opens, so no jump can leave it short.

Around that rule: leverage falls with the square root of the time to the next scheduled news, to 1x at the event. A 1x position is just the shares and is never liquidated. And Boost lets a trader keep the leveraged win for a daily premium.

You can read more deeply about the mathematics behind the mechanisms in our whitepaper over here - https://pramay2007.github.io/OpenLiquid/#docs

A leveraged position on a live Gemini prediction market

The Predict page: live markets and what leverage does to a bet

How we built it

Six Solidity contracts on Arc testnet: a signed-price oracle, the engine, an ERC-4626 vault, the OLQ token, staking and a test USDC. A keeper reads Hyperliquid and Gemini Prediction Markets, signs a price every second, and carries out liquidations, payouts and settlements. The app is React and viem. Every trade carries its own freshly signed price in the same transaction. Gas is USDC, so a trader never needs a second asset. A Bridge page moves USDC in and out of Arc with Circle's CCTP V2.

How it uses Arc

  • USDC is the collateral, the unit of profit and loss, the vault asset, the staking reward and the gas token. A trader holds one asset.
  • Opening a position costs about a cent of gas and closing one about half a cent.
  • Fast finality is what makes short-lived signed prices workable: each price is valid for 20 seconds.
  • The demo account is a key in the browser. The keeper sends it 0.2 USDC of gas once, so a new user trades with no wallet prompt.
  • USDC moves in and out of Arc through Circle CCTP V2 with the Forwarding Service, in one signature. We sent USDC from Arc to Base Sepolia through it.

The Bridge page: USDC with Circle CCTP

Challenges we ran into

We had a swarm of AI agents try to break it, and they did.

Before deploying the final contracts we handed the rules to a swarm of agents. Seven each took one line of attack on the mechanism: straddles through jumps, harvesting slow drift, gaming the fee, sports, markets that resolve early, thin reference books and the plain no-jump baseline. Each modelled the rules and measured its best strategy with exact enumeration and Monte Carlo at 200,000 to 1,000,000 paths. They reported 58 findings, 13 of them critical. Six more agents reviewed the Solidity, reported 51 findings and wrote failing tests for them.

Some of what they found, and what it changed:

  • Our crowding fee was taken only from winners. An agent closed flat and re-opened, and kept 96% of it. It is now a holding cost on the crowded side.
  • Our cap paid the full outright win on a jump that stopped part of the way. That was worth up to +$1.30 per dollar to the cheap side. The cap is now the smaller of the stake and the outright win. The agent's best strategy against the new cap returns −$0.01 where it returned +$0.55.
  • One deposit, one relayed price and one redemption in a single block took money from liquidity providers. Vault shares now unlock ten minutes after a deposit.

What held: across every run, no position was ever paid more than the amount locked for it.

The Mechanics page

The other challenge was Arc's public RPC, which taught us about stale nonces and about gas estimates made against a block stamped twelve seconds ahead.

Accomplishments that we're proud of

We are experimenting and have designed a completely new way of trading prediction markets that has never been done before.

It works, in public, on Arc, with sixteen live markets and real reference prices. Leverage on live Gemini prediction markets is tradeable today: on 20 November a script opened and closed 14 positions across six markets on Arc through the hosted keeper, and the same trades were placed by hand on the public site. And the record of the stress test is in the repository, with the agents' scripts, including the parts that did not go our way.

What we learned

A position that cannot lose more than its stake always has some pattern of jumps that pays it. No cap fixes every case. The work is choosing which cases are fair and limiting the rest. We also learned that a rule we liked, never adding to a loss, could not survive contact with an adversary.

What's next

We are still working on parts of the mechanics, and we say which. The largest open item is that a trader can choose among the prices signed in the last 20 seconds. The fix is two-step fills: order now, fill at the next signed price. Thin reference books can be manipulated in ways we have measured and not yet closed. The stress test is something we can keep running: more scenarios, and a second round against the changed rules, which have not been re-attacked yet. Each round should make the mechanics safer. Then an audit. The whitepaper has a page called "What we are still working on" with every item and its measured size.

Tracks

DeFi and Onchain Applications. Best use of Arc. Gemini Prediction Markets bounty.

Contracts on Arc testnet: PerpEngine 0xD6D4910E7cACf224c143999186f1a745c22CfdF3, Vault 0x4eDafC142dA2d5299424b5ac0b884A194A20f7E1, PriceOracle 0x3D8931Cc87d1A619546A82569E3B0dcb1535EFd5, OLQ token 0xF22b9D7139D0517DABA57f176Ee25A711601b9a1, Staking 0x40C7E6f03d0B2885976087f1903effD15c691841. The full list, the tests and the stress-test record are in the repository.

OpenLiquid is a testnet prototype. It is unaudited and uses test funds only.

Built With

Share this project:

Updates

Submission history