Five States, One Sequence

Market Lifecycle

Every KangarooDeFi market passes through exactly five states: Pending → TradingOpen → ReadyToClose → Closed (or Cancelled). Understanding this cycle tells you what actions are possible at each stage.

TradersCreatorsDevelopers
Oracle-Free

No external data feed. Markets close on a schedule and archive final sentiment — no oracle dependency, ever.

Dual Liquidity

Virtual KUSD seeds equal initial depth. Backed KUSD from real deposits defines actual exit capacity. The two are always tracked separately.

Hardened Risk Controls

25% max price impact, 50% virtual-seed buy cap, and optional trade cooldowns bound single-actor displacement on-chain.

The Five States

  • Pending — market created but start time has not arrived. No trading.
  • TradingOpen — between start time and end time. Buying and selling are live.
  • ReadyToClose — end time has passed but closeMarket has not been called yet.
  • Closed — closeMarket was called. Virtual KUSD burned, backed KUSD set for redemption. Positions redeemable.
  • Cancelled — creator or owner cancelled the market before meaningful activity. All positions refundable.
Who can close?

closeMarket is permissionless — any wallet can call it once the market's end time has passed. The caller earns a Keeper badge (BADGE_KEEPER = 4) as a reward for performing this service.

Market Creation

A creator calls createMarket on KangarooMarketRouter with: topic, question, answer labels (2–5), startTime, endTime, creatorFeeBps, and virtualLiquidityKusd. The router then:

  • 1. Validates inputs: duration between 5 minutes and 90 days, fee within bounds, virtual liquidity within cap.
  • 2. Calls KangarooTokenFactory to deploy one KangarooSentimentToken per answer.
  • 3. Calls the V2 factory to create one KUSD/answer-token pair per answer.
  • 4. Mints virtual KUSD (floor(L/n) per answer) and seeds each pair with equal amounts of virtual KUSD and 9,000 answer tokens.
  • 5. Marks the router as the pair on KUSD, ensuring all subsequent flows are tracked.
  • 6. Records the market in KangarooCreatorRegistry and mints the creator a BADGE_CREATOR.
Gas note

Creating a 2-answer market costs ~8M gas. A 5-answer market costs ~18M gas due to deploying more tokens and pairs.

Trading Window

Between startTime and endTime the market is in TradingOpen state. All buy and sell operations are active. The state is computed dynamically on read — there is no stored status flag for TradingOpen; the router derives it from block.timestamp vs. startTime and endTime.

Market duration must be at least 5 minutes and at most 90 days. Creators choose any duration within that range.

Closing a Market

After endTime, any wallet can call closeMarket(marketId). The router:

  • 1. Confirms market status is ReadyToClose.
  • 2. For each answer pool, removes LP liquidity from the pair and recovers KUSD + answer tokens.
  • 3. Burns the virtual KUSD seed (min of recovered KUSD and original virtual seed).
  • 4. Settles the remaining real KUSD into redeemableKusd per pool, bounded by backed accounting. This includes real AMM value left in that answer pool after virtual KUSD is burned, including the 0.3% AMM fee retained in the pool.
  • 5. Records closedAt timestamp and marks closed = true.
  • 6. Calls KangarooCreatorRegistry to record market closure with a quality score.
  • 7. Mints BADGE_KEEPER to the caller.

Cancellation

If a market is cancelled before meaningful activity, the protocol marks it as cancelled. Participants can call the cancel-redeem path to recover their KUSD. No closing accounting is performed — the virtual seed is unwound and the market is archived.