> ## Documentation Index
> Fetch the complete documentation index at: https://pnpprotocol.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a Market

> Create every type of PnP market with pnp-core — parimutuel (P2P) and Pythagorean (AMM) markets, with general, coin, or YouTube resolution and optional custom odds.

Markets vary along two axes — a **liquidity model** and a **resolution kind**. This page has a
copy-pasteable script for each combination the SDK exposes.

| Liquidity model | Namespace | Creator's role |
| - | - | - |
| **Parimutuel (P2P)** | `client.p2p` | Seeds **one side**; others take the opposite side. Winners split the pot. |
| **Pythagorean (AMM)** | `client.amm` | Seeds **liquidity**; traders buy YES/NO against the pool. |

> [!NOTE]
>
> All amounts are in **base units**. Examples use `uiToBaseUnits(100, 6)` → `100_000000n` for
> 100 USDC. `endTime` accepts a `Date`, or unix-seconds as `number` / `bigint` / `BN`. `creator`
> defaults to the signer; `collateralMint` defaults to the network's default (USDC on mainnet).

## Parimutuel (P2P) markets

### General P2P market

The creator backs one side; everyone else takes the other side with [`client.p2p.buy`](https://pnpprotocol.mintlify.site/sdk/trading).
Settlement uses the PnP protocol oracle, and odds default to 1:1.

```ts theme={null}
import { PnpClient, uiToBaseUnits } from "pnp-core";

const client = PnpClient.mainnet({ wallet });

const res = await client.p2p.createMarket({
  question: "Will BTC close above $100k on Dec 31, 2026?",
  initialAmount: uiToBaseUnits(100, 6), // seed 100 USDC on YES
  side: "yes",
  endTime: new Date(Date.now() + 30 * 864e5), // ~30 days
});

console.log("market id:  ", res.marketId.toString());
console.log("market PDA: ", res.market.toBase58());
console.log("YES / NO:   ", res.yesMint.toBase58(), res.noMint.toBase58());
console.log("signature:  ", res.signature);
```

### P2P market with custom odds

Pass `oddsBps` (100–9900) to price the creator's side away from 1:1. `2500` bps sets the
creator's side at 25% implied probability, so takers on the other side earn a larger share of
the pot. Setting odds creates the market **extension PDA** (returned as `res.extension`).

```ts theme={null}
const res = await client.p2p.createMarket({
  question: "Will my team win the hackathon?",
  initialAmount: uiToBaseUnits(50, 6),
  side: "no",
  endTime: new Date(Date.now() + 3 * 864e5),
  oddsBps: 2500, // creator's NO side at 25% implied odds
});
```

### P2P market with a custom oracle

`createMarketCustom` is identical to `createMarket` but you designate the **settler**. See
[Custom Oracles](https://pnpprotocol.mintlify.site/sdk/custom-oracles.md) for the full lifecycle.

```ts theme={null}
const res = await client.p2p.createMarketCustom({
  question: "Will our internal KPI hit target this quarter?",
  initialAmount: uiToBaseUnits(25, 6),
  side: "yes",
  endTime: new Date(Date.now() + 7 * 864e5),
  oracle: mySettlerPubkey, // becomes an authorized settler for THIS market
});
```

> [!WARNING]
>
> Whatever pubkey you pass as `oracle` can `settle()` and `setEndTime()` on this market. Prefer
> the plain `createMarket` (protocol oracle) unless you specifically want your own settler.

### P2P parameters

**question** `string` *required*

Market question / title, stored on-chain.

**initialAmount** `BN | bigint | number` *required*

Collateral the creator deposits to seed their side, in **base units**.

**side** `"yes" | "no"` *required*

Which side the creator backs.

**endTime** `number | bigint | BN | Date` *required*

Market end time. May be in the past for an immediately-settleable market.

**oddsBps** `number`

Creator-side odds in bps (100–9900). Omit for default 1:1 (10000). Creates the extension PDA.

**creator** `PublicKey`

Creator / fee recipient. Defaults to the signer; may differ from the payer.

**collateralMint** `PublicKey`

Override the collateral mint. Defaults to the network default.

**oracle** `PublicKey` *required*

**`createMarketCustom` only.** The market's settler.

**computeUnitLimit** `number` (default: 400000)

CU limit prepended to the tx. Pass `0` to skip the compute-budget instruction.

## Pythagorean (AMM) markets

### General AMM market

The creator seeds liquidity; prices start at 50/50 and move as traders buy. Settlement uses the
PnP protocol oracle.

```ts theme={null}
const res = await client.amm.createMarket({
  question: "Will Solana flip Ethereum by TVL in 2026?",
  initialLiquidity: uiToBaseUnits(200, 6), // seed 200 USDC of liquidity
  endTime: new Date(Date.now() + 60 * 864e5),
});

console.log("market id:", res.marketId.toString(), res.market.toBase58());
```

### AMM market with custom odds / oracle

```ts theme={null}
const res = await client.amm.createMarketCustom({
  question: "Will it rain in SF on launch day?",
  initialLiquidity: uiToBaseUnits(100, 6),
  endTime: new Date(Date.now() + 2 * 864e5),
  oddsBps: 3000, // start YES at 30% (default 5000 = 50/50)
  // oracle: mySettlerPubkey, // optional custom settler
});
```

### Coin market

Resolves on a token's price/metric. The type is encoded in the on-chain question as a suffix —
`"<question>? <chain>:<coinAddress>"` — exactly like the PnP frontend, so the oracle recognizes
it. `createCoinMarket` extends the AMM custom params, so `oddsBps` / `oracle` are also available.

```ts theme={null}
const res = await client.amm.createCoinMarket({
  question: "Will BONK 2x from here by end of month?",
  coinAddress: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", // BONK mint
  chain: "solana", // default
  initialLiquidity: uiToBaseUnits(150, 6),
  endTime: new Date(Date.now() + 30 * 864e5),
});
```

### YouTube market

Resolves on a video's stats. Encoded on-chain as `"<question>? <youtubeLink>"`.

```ts theme={null}
const res = await client.amm.createYoutubeMarket({
  question: "Will this video hit 1M views in 30 days?",
  youtubeLink: "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  initialLiquidity: uiToBaseUnits(100, 6),
  endTime: new Date(Date.now() + 30 * 864e5),
});
```

### AMM parameters

**question** `string` *required*

Market question / title, stored on-chain.

**initialLiquidity** `BN | bigint | number` *required*

Liquidity the creator seeds the AMM with, in **base units**.

**endTime** `number | bigint | BN | Date` *required*

Market end time.

**oddsBps** `number` (default: 5000)

**Custom/coin/youtube paths.** YES-side odds in bps (100–9900). Default 5000 (50/50).

**oracle** `PublicKey`

**Custom/coin/youtube paths.** Optional custom settler.

**coinAddress** `string` *required*

**`createCoinMarket` only.** The coin's contract address (SPL mint on Solana).

**chain** `string` (default: solana)

**`createCoinMarket` only.** Chain prefix stored in the question.

**youtubeLink** `string` *required*

**`createYoutubeMarket` only.** Full YouTube video link.

## What you get back

Both models return a result with the transaction signature and the created addresses:

```ts P2P — CreateMarketResult theme={null}
{
  signature: string;
  marketId: bigint;     // == global_config.global_id at creation
  market: PublicKey;    // MarketV3 PDA
  yesMint: PublicKey;   // YES decision-token mint
  noMint: PublicKey;    // NO decision-token mint
  extension?: PublicKey; // present only with custom odds/oracle
}
```

```ts AMM — AmmCreateMarketResult theme={null}
{
  signature: string;
  marketId: bigint;
  market: PublicKey;    // MarketV2 PDA
  extension?: PublicKey; // present only with custom odds/oracle
}
```

> [!NOTE]
>
> **Other resolution kinds** (Twitter, DefiLlama, Kalshi) are supported at the protocol level but
> have no dedicated SDK helper yet. You can still create them as general markets and attach
> [settlement criteria](https://pnpprotocol.mintlify.site/sdk/custom-oracles.md#settlement-criteria) describing how they resolve.

## Runnable examples

The SDK repo ships a script for every market type in
[`examples/create-markets/`](https://github.com/proxima424/pnp-sdk-v2/tree/main/examples/create-markets)
— clone it, set `PNP_KEYPAIR`, and run any of them with `tsx`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.