Skip to Content
Symmio Trading-SDK — the SDK surface for builders on HyperEVM
ReactSolvers hooksInstant Open

Instant Open hooks

React hooks over the core Instant Open flow. The three-function split (prepare / submit / auto) applies here too — pick based on how much control you want.

The page is split into two groups:

  • Reads — pending queue reads (useInstantOpens, useInstantOpenQuoteId).
  • Writes — the three-function open path (useInstantOpenAuto, useInstantOpen), the LIMIT-order variant (useLimitOpenAuto), plus the composed orchestrator (useInstantOpenWithTpSl).

Import

import { useInstantOpen, useInstantOpenAuto, useLimitOpenAuto, useInstantOpenWithTpSl, useInstantOpens, useInstantOpenQuoteId, } from "@symmio/trading-react";

Reads

useInstantOpens

Paginated list of the solver’s pending instant-opens for a SubAccount. useManagedQuotes consumes this internally.

const pending = useInstantOpens({ account: subAccount, offset: 0n, size: 20n });

useInstantOpenQuoteId

Resolve the on-chain quoteId for a given tempQuoteId. useManagedQuotes and the notification handlers use this to link rows.

const quoteId = useInstantOpenQuoteId({ tempQuoteId: -1001 });

Writes

useInstantOpenAuto

The default — one-line orchestrator. Runs prepareInstantOpenParams inline (fetches market metadata, mark price, locked params, fee rates) then signs and POSTs.

const open = useInstantOpenAuto(); <Button disabled={open.isPending} onClick={() => open.mutate({ from: sessionKey, subAccountAddress: subAccount, market: { id: 1 }, positionType: PositionType.LONG, initialMargin: "100", leverage: 5, slippage: 1, }) } > {open.isPending ? "Opening…" : "Open"} </Button>;

Latency: prepare fetches run inline, so click → sign gap includes the network hop. Fine for most flows; see useInstantOpen below for the low-latency variant.

useLimitOpenAuto

The LIMIT-order variant — same one-line shape as useInstantOpenAuto, but the user’s resting price is the trigger and the order writes a pending on-chain quote instead of filling immediately. Majors / Rasa only; throws UNSUPPORTED_BY_SOLVER when the resolved solver has no limit support (gate the UI with useSupportsLimitOrder). Defaults the send deadline to 15 minutes.

const place = useLimitOpenAuto(); place.mutate({ from: sessionKey, subAccountAddress: subAccount, market: { id: 1 }, positionType: PositionType.LONG, initialMargin: "100", leverage: 5, price: "64000", // resting limit price });

On success it invalidates the hedger’s instant-open feed, so the order surfaces immediately as an offchain row in useLimitOrders; the anchor notification then flips it to onchain. Cancel it with useRequestToCancelQuote.

useInstantOpen

Low-latency primitive — the caller supplies the fully-resolved InstantOpenParameters bag. Pair with a pre-resolved prepareInstantOpenParams call staged earlier (on trade-panel mount) so the critical path is just sign + POST.

const prepare = usePrepareInstantOpenParamsCached(uiInputs); // your own hook const open = useInstantOpen(); // user clicks Open — no fetches on the critical path open.mutate(prepare.data);

useInstantOpenWithTpSl

Orchestrator that opens a position and immediately attaches TP/SL against the returned tempQuoteId. Two mutations chained under the hood:

  1. instantOpenAuto → returns tempQuoteId.
  2. setQuoteTpSl with quoteId: tempQuoteId → creates the conditional-order legs.
const open = useInstantOpenWithTpSl(); open.mutate({ ...instantOpenInputs, tpsl: hasTpOrSl ? { from: sessionKey, virtualAccount: predictedVa, subAccount, symbolId, positionType, quantity, pricePrecision, tp: tpInput, sl: slInput, } : undefined, });

virtualAccount is the position’s VA, which does not exist on-chain yet — derive it with usePredictedNextVirtualAccount keyed by isolationTypeForSide(positionType) and symbolId. tpsl: undefined (both legs empty) collapses the call to a plain useInstantOpenAuto. The open and the TP/SL leg fail independently: a rejected TP/SL still resolves the mutation and surfaces data.tpslError rather than throwing away a landed open.

On success, useTpSlStore is populated with the confirming record keyed by tempQuoteId. When the position anchors on-chain, the solver maps tempQuoteId ↔ quoteId and the same TP/SL record is reachable by either id. Confirmation is WebSocket-driven — the record sits in confirming until the handler’s report frame flips it to new; read it with useQuoteTpSl({ quoteId, account }).

See TP/SL for the store + reconciliation model.

  • Core Instant Open — the three-function split explained.
  • TP/SLuseInstantOpenWithTpSl composes over these.
  • Unified QuotesuseManagedQuotes reconciles the pending list with on-chain reads + notifications.
Last updated on