Skip to main content
The matching engine is the core of Likely. Every 500ms, it processes competing bundles, executes trades, and updates orderbooks across all markets.

How It Works

Think of the matching engine as an auction house that runs continuously:
  1. Traders submit bundles during the 500ms window
  2. Engine prioritizes by tip amount and submission time
  3. Top bundles execute atomically (all-or-nothing or configured)
  4. Markets update with new prices and filled orders
  5. Next auction begins immediately

What the Engine Tracks


Bundle Competition

During each auction window, traders can:
  • Submit one bundle (up to 256 operations)
  • Amend their bundle to change operations or tip
  • Bribe to increase their tip and jump ahead
  • Cancel to withdraw from the auction
The twist: Amending or bribing updates your timestamp, so you lose time priority. This creates interesting strategy - do you bribe to get ahead, or keep your early timestamp?

Execution Priority

Bundles execute in order:
  1. Highest tip goes first
  2. Oldest submission breaks ties
  3. One per user - your latest bundle replaces earlier ones
Example auction queue:

Lazy Removal Trick

When you amend or bribe your bundle, the engine doesn’t remove your old entry from the queue (expensive operation). Instead:
  • Your new bundle gets added to the queue
  • Your old bundle stays but becomes a “ghost”
  • During execution, ghosts are skipped
This makes amending/bribing instant, even with thousands of bundles competing.

User State Management

The engine tracks your state across all markets: Your balances:
  • Free USDC (available to trade)
  • Locked USDC (in open buy orders)
Your positions (per market):
  • Free YES shares (available to sell/merge)
  • Locked YES shares (in open sell orders)
  • Free NO shares (available to sell/merge)
  • Locked NO shares (in open sell orders)
Your orders:
  • All active limit orders across markets
  • Updated in real-time as they fill or cancel

Auction Close Process

When the 500ms window ends: 1. Load traders
  • Engine loads all users who have bundles
  • Fast access via Redis cache
  • New traders created automatically
2. Execute by priority
  • Process bundles from highest tip to lowest
  • Each bundle either fully succeeds or fails
  • Tips distributed to market makers who filled orders
  • Failed bundle tips go to protocol liquidity fund
3. Update markets
  • Generate orderbook snapshots
  • Broadcast new prices to all clients
  • Clear auction state for next round

Why This Design?

For traders:
  • Fair competition based on value, not speed
  • Predictable max latency (500ms)
  • Can adjust strategy mid-auction (amend/bribe)
For market makers:
  • Earn tips when filling orders
  • Privacy protection (bundles don’t expose identity)
  • Can’t be picked off by faster traders
For the platform:
  • Failed tips fund liquidity during volatility
  • Sustainable incentive structure
  • Scales to thousands of concurrent traders

Real-Time Updates

After each auction, you receive:
  • Bundle result: Success or failure with details
  • Balance updates: New USDC and share balances
  • Order updates: Which orders filled, canceled, or placed
  • Market data: Latest orderbook snapshots
Everything updates in real-time via WebSocket, so you always know your exact state.

Next Steps