react >= 18, wagmi >= 2, viem >= 2, @tanstack/react-query >= 5.
ParlayProvider
WagmiProvider and QueryClientProvider. All hooks read the client from this context.
useTakerClient
ParlayProvider. Use it for anything the higher-level hooks do not cover, e.g. a debounced preview quote in a slip drawer.
useParlaySlip
toggle semantics: tapping an outcome adds the leg, tapping the same outcome again removes it, tapping the other side flips it. One leg per market by construction.
The underlying pure helpers (toggleLeg, removeLeg, toLegs, legCount) are exported from @parlays-live/taker if you keep slip state in your own store.
useSubmitParlay
status through each stage:
- Chain guard:
cb.ensureChain()if provided, else wagmiswitchChaintoclient.config.chainId(failure swallowed). approving: reads the USDC allowance; if belowstake, sends anapprove(maxUint256)transaction and waits for the receipt (the only gas the taker ever pays, once).quoting:client.quote(legs, stake, address); the relayer prices from live HL mids and signs the maker side. SetslastQuote.signing: the taker signs the identical order via EIP-712.submitting:client.submit(...); the relayer relays on-chain.done:resultholds{txHash, parlayId}.
submit rejects (and sets status: "error" + error) if the wallet is not connected, the quote is refused, the signature is declined, or the relay fails. A failed event carries the exact stage. Options and the event union are documented in Analytics.
useParlayPositions
Poll interval for parlay tuples. Leg data refetches at
max(refetchMs, 30000) since legs are immutable.Gate the reads entirely, e.g. on an
isConfigured flag for networks whose contracts are not deployed yet.nextParlayId, then batches getParlay and getLegs via wagmi useReadContracts (cached, deduplicated). mine and onMarket are memoized selectors over rows; render both surfaces with the same row component (see the positions guide). The pure selector forms (positionsOf, positionsOnMarket, openPositions) and the non-React fetchParlays are exported from @parlays-live/taker.
useCashOut
getQuotefetches the quoter-signed buy-back price (status: quoting -> quoted). Returnsnulland setserroron failure instead of throwing.executeruns the chain guard, sendsParlayEscrow.cashOutfrom the taker’s wallet, and waits for the receipt (status: cashing -> done). Execution errors are truncated to one line, 140 chars.
getQuote if the user waits too long. Full walkthrough in the cash-out guide.
ParlayCallbacks
Both write hooks accept the same callbacks object:ParlayEvent union and a PostHog mapping.
