Documentation Index
Fetch the complete documentation index at: https://docs.context.markets/llms.txt
Use this file to discover all available pages before exploring further.
Hooks reference
All hooks are exported from context-markets-react. Query hooks return TanStack Query results (data, isLoading, error). Mutation hooks return mutate, mutateAsync, isPending, error. Query hooks accept TanStack Query options? as the last argument, and mutation hooks accept mutation options? as the only hook argument.
Markets
useMarkets
const { data, isLoading, error } = useMarkets(params?, options?)
List and filter markets. params matches ctx.markets.list(): query, status, sortBy, sort, limit, cursor, visibility, resolutionStatus, creator, category, createdAfter.
useMarket
const { data, isLoading, error } = useMarket(marketId: string, options?)
Get a single market by ID.
useOrderbook
const { data, isLoading, error } = useOrderbook(marketId: string, params?, options?)
Get one side of a market orderbook. Optional params are depth and outcomeIndex.
useQuotes
const { data, isLoading, error } = useQuotes(marketId: string, options?)
Current bid, ask, and last trade prices for both outcomes.
usePriceHistory
const { data, isLoading, error } = usePriceHistory(marketId: string, params?, options?)
Historical price data. Optional timeframe parameter: "1h", "6h", "1d", "1w", "1M", "all".
useMarketActivity
const { data, isLoading, error } = useMarketActivity(marketId: string, params?, options?)
Market event feed. Optional params are cursor, limit, types, startTime, and endTime.
useSimulateTrade
const { data, isLoading, error } = useSimulateTrade(marketId: string, params: {
side: "yes" | "no"
amount: number
amountType?: "usd" | "contracts"
trader?: string
}, options?)
Preview trade execution including estimated contracts, average price, and slippage.
useOracle
const { data, isLoading, error } = useOracle(marketId: string, options?)
Oracle resolution data including probability estimates, confidence, and reasoning.
useSearchMarkets
const { data, isLoading, error } = useSearchMarkets({
q: string,
limit?: number,
offset?: number,
}, options?)
Search markets by keyword. Returns { markets: Market[], hasMore: boolean }.
useLatestOracleQuote
const { data, isLoading, error } = useLatestOracleQuote(marketId: string, options?)
Get the latest oracle quote for a market.
Market creation
useSubmitQuestion
const { mutate, mutateAsync, isPending, error } = useSubmitQuestion(options?)
Submit a natural-language question. Call with a question string.
useSubmitAndWait
const { mutate, mutateAsync, isPending, data, error } = useSubmitAndWait(options?)
Submit a question and poll until processing completes. Call with:
submitAndWait({
question: "Will X happen by Y?",
options: { pollIntervalMs: 2_000, maxAttempts: 45 },
})
useCreateMarket
const { mutate, mutateAsync, isPending, error } = useCreateMarket(options?)
Create a market from an approved question ID. Call with the questionId string.
useAgentSubmit
const { mutate, mutateAsync, isPending, error } = useAgentSubmit(options?)
Submit a market draft via the agent endpoint. Call with:
agentSubmit({
market: {
formattedQuestion: "Will X happen by Y?",
shortQuestion: "X by Y?",
marketType: "OBJECTIVE",
evidenceMode: "web_enabled",
resolutionCriteria: "Resolves YES if...",
endTime: "2026-06-01 00:00:00",
timezone: "America/New_York",
},
})
useAgentSubmitAndWait
const { mutate, mutateAsync, isPending, data, error } = useAgentSubmitAndWait(options?)
Submit a market draft and poll until processing completes. Call with:
agentSubmitAndWait({
draft: {
market: {
formattedQuestion: "Will X happen by Y?",
shortQuestion: "X by Y?",
marketType: "OBJECTIVE",
evidenceMode: "web_enabled",
resolutionCriteria: "Resolves YES if...",
endTime: "2026-06-01 00:00:00",
},
},
options: { pollIntervalMs: 2_000, maxAttempts: 45 },
})
Orders
useOrders
const { data, isLoading, error } = useOrders(params?, options?)
List orders with filters: trader, marketId, status, limit, cursor.
useOrder
const { data, isLoading, error } = useOrder(orderId: string, options?)
Get a single order by ID.
useCreateOrder
const { mutate, mutateAsync, isPending, error } = useCreateOrder(options?)
Place a limit order. Call with { marketId, outcome, side, priceCents, size, expirySeconds?, inventoryModeConstraint?, makerRoleConstraint?, settlementVersion?, timeInForce? }. Requires a connected wallet.
useCreateMarketOrder
const { mutate, mutateAsync, isPending, error } = useCreateMarketOrder(options?)
Place a market order. Call with { marketId, outcome, side, maxPriceCents, maxSize, expirySeconds? }. Requires a connected wallet.
useCancelOrder
const { mutate, mutateAsync, isPending, error } = useCancelOrder(options?)
Cancel an open order. Call with the order nonce (Hex). Requires a connected wallet.
useCancelReplace
const { mutate, mutateAsync, isPending, error } = useCancelReplace(options?)
Cancel and replace an order atomically. Call with { cancelNonce, newOrder }, where newOrder is a PlaceOrderRequest. Requires a connected wallet.
Portfolio
usePortfolio
const { data, isLoading, error } = usePortfolio(address?, params?, options?)
Get portfolio summary for an address. If address is omitted, the connected wallet address is used.
usePositions
const { data, isLoading, error } = usePositions(address?, params?, options?)
View positions across markets. Optional params are marketId, status, search, cursor, and limit. If address is omitted, the connected wallet address is used.
useBalance
const { data, isLoading, error } = useBalance(address?, options?)
USDC balance including wallet and settlement balances. If address is omitted, the connected wallet address is used.
useClaimable
const { data, isLoading, error } = useClaimable(address?, options?)
Winnings from resolved markets. If address is omitted, the connected wallet address is used.
usePortfolioStats
const { data, isLoading, error } = usePortfolioStats(address?, options?)
Portfolio value and PnL metrics. If address is omitted, the connected wallet address is used.
Account
useAccountStatus
const { data, isLoading, error } = useAccountStatus(options?)
Wallet status including ETH balance, USDC allowance, operator approval, and whether setup is needed.
useAccountSetup
const { mutate, mutateAsync, isPending, error } = useAccountSetup(options?)
Approve contracts for trading. Chain-aware — uses gasless relay on testnet, on-chain transactions on mainnet. Returns SetupResult. Requires connected wallet.
useDeposit
const { mutate, mutateAsync, isPending, error } = useDeposit(options?)
Deposit USDC into the exchange. Chain-aware — gasless on testnet, on-chain on mainnet. Call with amount (number). Returns DepositResult. Requires connected wallet.
useWithdraw
const { mutate, mutateAsync, isPending, error } = useWithdraw(options?)
Withdraw USDC from the exchange. Call with amount (number). Requires connected wallet.
useApproveUsdc
const { mutate, mutateAsync, isPending, error } = useApproveUsdc(options?)
Approve USDC spending for the Holdings contract. Returns the tx hash, or null if already approved. Requires connected wallet.
useApproveOperator
const { mutate, mutateAsync, isPending, error } = useApproveOperator(options?)
Approve the Settlement contract as operator. Returns the tx hash, or null if already approved. Requires connected wallet.
Utilities
useContextClient
const client = useContextClient()
Access the underlying ContextClient instance from the nearest ContextProvider.