Seer documentation
  • Overview
    • 📘 What is Seer?
    • 📚 Glossary
  • Getting Started
    • 💡 Wallet and network
    • 💰 Deposit tokens
      • On Ethereum
        • Deposit DAI
        • Deposit sDAI
      • On Gnosis
        • Deposit xDAI
        • Deposit wxDAI or sDAI
    • 🧭 Navigate Our Site
      • Create a market
      • Verify market
      • Mint, merge, redeem outcome tokens
      • Buy, sell outcome tokens
      • Report answer
      • Raise a dispute
      • Resolve market
      • Provide Liquidity
      • Conditional Markets
      • Futarchy Markets
  • Developers
    • 📝 Intro
    • 🔄 Diagrams
      • Seer overall interaction
      • Create Market
      • Split, Merge, Redeem
      • Question and Resolve
    • 🔗 Interact with Seer
      • Create a market
      • Resolve a market
      • Split, Merge and Redeem
      • Market example
      • Conditional market
      • Futarchy market
    • 📜 Contracts
      • Core
        • MarketFactory
        • Market
        • MarketView
        • Router
        • GnosisRouter
        • MainnetRouter
        • RealityProxy
        • Interfaces
      • Futarchy (test)
        • FutarchyFactory
        • FutarchyProposal
        • FutarchyRouter
        • FutarchyRealityProxy
      • Token
        • Seer
      • Interaction
        • 1155-to-20
          • Wrapped1155Factory
        • conditional-tokens
          • ERC1155
            • ERC1155
            • ERC1155TokenReceiver
            • IERC1155
            • IERC1155TokenReceiver
          • ConditionalTokens
          • CTHelpers
        • cross-chain-realitio-proxy
          • dependencies
            • IAMB
            • RealitioInterface
          • ArbitrationProxyInterfaces
          • RealitioForeignArbitrationProxyWithAppeals
          • RealitioHomeArbitrationProxy
        • reality
          • RealityETH-3.0
        • sDAI-on-Gnosis
          • interfaces
            • IBridgeInterestReceiver
            • IWXDAI
          • periphery
            • SavingsXDaiAdapter
          • SavingsXDai
      • Deployed contracts
    • 🌐 Subgraph
      • Query Examples
      • GraphQl Query
        • Market
        • Swapr
        • Curate
      • GraphQL Schema
      • Subgraph ID
  • OTHER
    • 🔍 Audit Reports
Powered by GitBook
On this page
  • Create a conditional market
  • Split, merge and redeem a conditional market
  1. Developers
  2. 🔗 Interact with Seer

Conditional market

PreviousMarket exampleNextFutarchy market

Last updated 8 months ago

Conditional markets are markets which based on the outcome of an existing market.

Let's take an example to follow up on the question from the previous section. We could have a market asking If the war in Ukraine ends in 2024, will Russia withdraw all its troops from Ukrainian territory by the end of 2025? This market will be conditional to the market resolving to Yes.

Create a conditional market

To create a conditional market, you must have an address of the parent market and the parent outcome:

await marketFactory.createCategoricalMarket({
  marketName: `If the war in Ukraine ends in 2024, will Russia withdraw all its troops from Ukrainian territory by the end of 2025?`,
  category: "misc",
  lang: "en_US",
  parentOutcome: 0 // 0 is Yes in parent market,
  parentMarket: parentMarketAddress,
  questionStart: "", // only used in multi-scalar
  questionEnd: "", // only used in multi-scalar
  outcomeType: "", // only used in multi-scalar
  outcomes: ["Yes", "No"],
  lowerBound: 0, // only used in scalar
  upperBound: 0, // only used in scalar
  minBond: "1000",
  openingTime: 1767139200, //2025-12-31T00:00:00.000Z
  tokenNames: ["YES", "NO"],
})

Split, merge and redeem a conditional market

To interact with conditional outcome tokens, we have to use Router instead of GnosisRouter.

Splitting

Before splitting a conditional market, you must have enough parent outcome tokens first (by splitting or trading):

await parentToken.approve(router, "1000"); // allow the router to spend your parent outcome tokens
await router.splitPosition(
    collateralToken,
    market, // the conditional market
    "1000", // split amount
);

As you can see, the process is quite similar to splitting a simple market. Under the hood, we used a specific parentCollectionId instead of the default bytes32(0). The market contract has already saved this variable, and can be accessed with:

await market.parentCollectionId()
await conditionalTokens.getCollectionId(
    await parentMarket.parentCollectionId(),
    await parentMarket.conditionId(),
    "0b001",
)

After splitting, you will notice that your parent tokens are no longer present. Instead, you will have multiple sets of conditional outcome tokens at your disposal.

Merging

The process is the exact opposite of splitting. Here, the contract will burn your conditional outcome tokens and return the corresponding parent tokens to you.

Redeeming

The contract will burn the specified conditional outcome tokens. If you are redeeming a winning outcome, it will return the corresponding parent tokens to you in proportion to the payouts.

await router.redeemPositions(
    collateralToken,
    market,
    [0], // array of outcome indexes
    [1000n], // array of redeem amounts
);

Nested conditional markets

In theory, the conditional tokens framework supports infinite nesting levels. You can create a conditional market based on another conditional market and interact with it as you would with any market.

However, conditional markets are dependent on their parent market's outcome. If the parent market resolves to an outcome different from the one assumed by the child market, then the child market and all markets nested under it become obsolete.

If you want to know how a parentCollectionId is generated in detail, you can check out the . In short, it requires the parentCollectionId of the parent market, the conditionId of the parent market and the indexSet of the parent outcome.

Will war in Ukraine stop in 2024?
Conditional Tokens GitHub site