How to Create a Market
This section provides complete working scripts for creating prediction markets using the PNP SDK. There are two types of markets you can create:- V2 AMM Markets: Traditional automated market maker (AMM) pools where liquidity is provided upfront
- P2P Markets: Peer-to-peer markets where the creator takes a position on one side
Creating a V2 AMM Market
V2 markets use an AMM model where you provide initial liquidity that gets split between YES and NO tokens. This script demonstrates how to create a V2 market with USDC as collateral.- Initial liquidity is split equally between YES and NO tokens in the AMM pool
- The creator doesn’t take a position; they provide liquidity for others to trade against
- Use
client.market.createMarket()for V2 markets
Creating a P2P Market
P2P markets are peer-to-peer markets where the creator takes a position on one side (YES or NO) with a specified cap. This script demonstrates how to create a P2P market.- The creator takes a position on one side (YES or NO) with an initial amount
creatorSideCapdefines the maximum amount the creator is willing to bet on their chosen side- Other users can take the opposite position
- Use
client.createP2PMarketGeneral()for P2P markets
| Feature | V2 AMM Market | P2P Market |
|---|---|---|
| Market Type | Automated Market Maker | Peer-to-Peer |
| Creator Position | No position (provides liquidity) | Takes YES or NO position |
| Initial Liquidity | Split equally between YES/NO | Goes to creator’s chosen side |
| SDK Method | client.market.createMarket() | client.createP2PMarketGeneral() |
| Side Selection | N/A | Required (yes/no) |
| Creator Cap | N/A | Required (creatorSideCap) |
| Use Case | Traditional prediction markets | Targeted position markets |
Creating a Twitter Market
Twitter markets are linked to specific tweets. The SDK can automatically detect tweet IDs from URLs and fetch settlement criteria.Creating a V2 Twitter Market
This script demonstrates how to create a V2 AMM market linked to a Twitter post.Creating a P2P Twitter Market
This script demonstrates how to create a P2P market linked to a Twitter post.Creating a YouTube Market
YouTube markets are linked to specific videos. The SDK handles YouTube URL parsing and settlement integration.Creating a V2 YouTube Market
This script demonstrates how to create a V2 AMM market linked to a YouTube video.Creating a P2P YouTube Market
This script demonstrates how to create a P2P market linked to a YouTube video.Creating a Market with Custom Oracle
Custom Oracles allow you to bypass PNP’s AI-powered global oracle and designate your own wallet or service to resolve markets. This is a powerful feature for builders who want full control over market resolution.
New in v0.2.6: The createMarketWithCustomOracle function is now live on both Devnet and Mainnet!
