React SDK
@contextwtf/react · v0.1.0 · React 18+ · TanStack Query 5+ · wagmi 2+
Declarative React hooks for Context Markets. Built on @contextwtf/sdk and TanStack Query, with automatic wallet integration through wagmi.
Install
Quick start
Provider setup
Using hooks
Hooks
Market hooks
| Hook | Type | Description |
|---|---|---|
useMarkets | Query | List and filter markets |
useMarket | Query | Get a single market by ID |
useOrderbook | Query | Live orderbook for a market |
useQuotes | Query | Current bid/ask/last prices |
usePriceHistory | Query | Historical price data |
useMarketActivity | Query | Market event feed |
useSimulateTrade | Query | Preview trade execution |
useOracle | Query | Oracle resolution data |
Order hooks
| Hook | Type | Description |
|---|---|---|
useOrders | Query | List orders with filters |
useMyOrders | Query | Your open orders |
useCreateOrder | Mutation | Place a limit order |
useMarketOrder | Mutation | Place a market order |
useCancelOrder | Mutation | Cancel an order |
useCancelReplaceOrder | Mutation | Cancel and replace an order |
Portfolio hooks
| Hook | Type | Description |
|---|---|---|
usePositions | Query | View positions across markets |
useBalance | Query | USDC balance (wallet + settlement) |
useClaimable | Query | Winnings from resolved markets |
usePortfolioStats | Query | Portfolio value and PnL |
Account hooks
| Hook | Type | Description |
|---|---|---|
useAccountStatus | Query | Wallet approvals and balances |
useSetupAccount | Mutation | Approve contracts for trading |
useDeposit | Mutation | Deposit USDC |
useWithdraw | Mutation | Withdraw USDC |
Query keys
UsecontextKeys for manual cache invalidation: