Skip to Content
Symmio Trading-SDK — the SDK surface for builders on Arbitrum
ReactSolvers hooksInstant Close

Instant Close hooks

React hooks over the core Instant Close flow. Same three-function split as Instant Open, plus bulk variants.

Single and bulk market-close hooks inherit core’s solver-specific order types: Enigma signs MARKET_BEST_EFFORT (2), Rasa signs MARKET (1), and limit closes retain LIMIT (0). Callers keep the same hook parameters.

The page is split into two groups:

  • Reads — pending queue reads (useInstantCloses).
  • Writes — single-quote close (useInstantCloseAuto, useLimitCloseAuto, useInstantClose) + bulk variants (useInstantCloseBulk, useInstantCloseBulkAuto).

Import

import { useInstantClose, useInstantCloseAuto, useLimitCloseAuto, useInstantCloseBulk, useInstantCloseBulkAuto, useInstantCloses, } from "@symmio/trading-react";

Reads

useInstantCloses

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

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

Writes

useInstantCloseAuto

One-line orchestrator: prepareInstantCloseParams + instantClose. Runs the market metadata / mark-price fetches inline.

const close = useInstantCloseAuto(); close.mutate({ from: sessionKey, partyA, market: { id: 1 }, positionType: PositionType.LONG, quoteId: 42n, quantityToClose: "0.5", slippage: 1, });

useLimitCloseAuto

The LIMIT-close variant — same one-line shape, but the caller passes a resting price (no slippage) and the close is written as a pending close resting at that price instead of filling at mark. Majors / Rasa only; throws UNSUPPORTED_BY_SOLVER when the resolved solver has no limit support (gate with useSupportsLimitOrder). On success it invalidates the instant-closes feed so the resting close surfaces without a poll.

const close = useLimitCloseAuto(); close.mutate({ from: sessionKey, partyA, market: { id: 1 }, positionType: PositionType.LONG, quoteId: 42n, quantityToClose: "0.5", price: "64000", // resting close price });

useInstantClose

Low-latency primitive — caller supplies the pre-resolved InstantCloseParameters. Pair with a staged prepareInstantCloseParams for fast closes.

const close = useInstantClose(); close.mutate(prepared);

useInstantCloseBulk / useInstantCloseBulkAuto

Atomic close of multiple quotes. Auto fetches metadata per quote; the primitive expects pre-resolved bags.

const bulk = useInstantCloseBulkAuto(); bulk.mutate({ from: sessionKey, subAccount, virtualAccount, closes: [ { quoteId: 42n, quantityToClose: "0.5" }, { quoteId: 43n, quantityToClose: "1.0" }, ], slippage: 1, });

The solver may partially accept — inspect per-quote success flags in mutation.data.

Fees at close

Instant Open defers close fees — the open funds only its open-side legs, so the close fees are charged here, at close, by the contract collecting them from the position. Three legs:

  • Platform close fee — taken from the position’s allocated balance after PnL settlement.
  • Solver close fee — priced by the position’s real holding time (the time-decaying rate that starts at the early rate and decays to the standard rate), and capped by the closeRateCap the quote signed at open. A longer hold pays less.
  • Static close fee — the flat USD close amount from the solver’s useSolverInfo (charged on each partial close too).

Liquidation charges no fees — these close fees are collected only on a user-initiated close, not on liquidation.

Preview these legs with useInstantCloseFees — it prices the platform leg, the holding-time solver leg, and the static leg from cached reads (markets, useFeeForUser, useSolverInfo, the shared price stream), re-stamping the holding time on every refetch so the decaying rate stays honest. Feed it the position’s createTimestamp as openedAt; omit it for the worst case. The low-level pieces it composes (calculateSolverCloseFee, useSolverInfo) stay available, but the hook is the intended surface. Core detail: getInstantCloseFees. The open-side preview (useInstantOpenFees) deliberately covers only the legs the open funds.

Last updated on