Trading & Redemption
This guide covers the full trading lifecycle: finding markets, checking prices, executing trades, and redeeming winnings.How to Fetch Market Addresses
Before trading, you may want to fetch the addresses of available markets.Fetching V2 Market Addresses
Fetching P2P Market Addresses
How to Get Market Prices & Multipliers
For V2 AMM markets, you can fetch real-time prices and multipliers without needing a wallet or private key. This is useful for displaying market data in UIs, calculating potential returns, or building analytics tools.Getting V2 Market Price Data
| Field | Description |
|---|---|
yesPrice | Current price of YES tokens (0-1 range, where 1 = $1) |
noPrice | Current price of NO tokens (0-1 range, where 1 = $1) |
yesMultiplier | Potential return multiplier if YES wins (e.g., 2x = double your money) |
noMultiplier | Potential return multiplier if NO wins |
marketReserves | Total collateral in the market (human-readable units) |
yesTokenSupply | Total YES tokens in circulation (human-readable units) |
noTokenSupply | Total NO tokens in circulation (human-readable units) |
marketReservesRaw | Total collateral in raw base units (e.g., lamports) |
yesTokenSupplyRaw | Total YES tokens in raw base units |
noTokenSupplyRaw | Total NO tokens in raw base units |
- No private key or wallet required - purely read-only operation
- Prices are calculated from the AMM’s constant product formula
- Multipliers show the potential payout ratio (e.g., 2x means 2)
- Raw values are provided for precision when working with on-chain amounts
- Works with any V2 AMM market address
Use Cases
Displaying Market Cards:How to Trade
Once markets are created, users can trade by buying or selling outcome tokens (YES/NO).Trading on V2 AMM Markets
V2 AMM markets allow you to buy YES or NO tokens using USDC as collateral. The AMM automatically determines the price based on the current liquidity pools.- Use
client.trading.buyTokensUsdc()to buy outcome tokens - Set
buyYesToken: truefor YES tokens,falsefor NO tokens - Amount is specified in USDC (e.g.,
1= 1 USDC) - The AMM automatically calculates token price based on liquidity
Trading on P2P Markets
P2P markets work differently - you can fetch available markets and trade directly with the market creator or other participants.Fetching Available P2P Markets
Trading on P2P Markets
- Use
client.fetchV3MarketAddresses()to get all available P2P markets (no auth required) - Use
client.tradeP2PMarket()to execute trades - Specify
sideas'yes'or'no' - Amount is in base units (for USDC: 1_000_000 = 1 USDC)
| Feature | V2 AMM Market | P2P Market |
|---|---|---|
| Trading Method | client.trading.buyTokensUsdc() | client.tradeP2PMarket() |
| Price Discovery | Automated via AMM | Direct peer-to-peer |
| Liquidity | Pool-based | Creator/participant-based |
| Amount Format | USDC amount (e.g., 1 for 1 USDC) | Base units (e.g., 1_000_000n for 1 USDC) |
| Market Discovery | Via client.fetchMarkets() | Via client.fetchV3MarketAddresses() |
How to Redeem Winnings
After a market has been resolved, users holding winning positions (YES or NO tokens) can redeem them for the collateral asset (e.g., USDC).Redeeming from Resolved Markets
This script demonstrates how to check if a market is resolved and redeem winning positions.- Market must be resolved (
marketAccount.resolved === true) - You must hold the winning token (YES or NO)
client.redeemPosition()handles the complexity of burning tokens and transferring collateral- Works for both V2 AMM and P2P markets
