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

Solvers hooks

React hooks over @symmio/trading-core’s Solvers slice — market catalog, locked params, notional cap, open interest, plus the instant-open / instant-close mutation orchestrators.

Every hook on this landing page is a read. The writes (instant-open / instant-close) live on their own pages linked at the bottom.

Import

import { useMarkets, useLockedParams, useNotionalCapAll, useNotionalCapBySymbolId, useOpenInterestBySymbolId, useFundingInfo, useEstimatedPrice, calculatePriceImpact, useSolverErrorCodes, useSolverErrorMessage, } from "@symmio/trading-react";

Reads

useMarkets

Solver-side market catalog. Prefer this over useOnchainContractMarkets for UI catalogs — the solver adds precision / tick metadata.

const markets = useMarkets();

Returns SymbolContractSymbol[].

useLockedParams

Fetch the solver’s LockedParams for a market + leverage — the CVA / LF percentages required to open at that leverage. Used inside useInstantOpenAuto internally; expose it to render “at this leverage you lock X collateral” UIs.

const locked = useLockedParams({ symbol: "BTCUSDT", leverage: 5 });

useNotionalCapBySymbolId

Available liquidity — how much notional the solver still permits for a market. Gate order size on this.

const cap = useNotionalCapBySymbolId({ symbolId: 1n });

useNotionalCapAll

Batch — every market’s cap in one call.

const caps = useNotionalCapAll();

useOpenInterestBySymbolId

Used vs capped notional per market.

const oi = useOpenInterestBySymbolId({ symbolId: 1n });

useFundingInfo

Next-epoch funding for every market in one call — pick a row by symbol. Each row is { symbol, nextFundingRateLong, nextFundingRateShort, nextFundingTime, epochDurationSeconds }. The rates are per-epoch decimal fractions (0.0001 = 0.01%, ×100 for a percent); a positive rate receives funding, a negative rate pays. nextFundingTime is a Unix timestamp in milliseconds (guard < 1e12 as seconds). Does not poll by default — pass query.refetchInterval.

const funding = useFundingInfo({ query: { refetchInterval: 30_000 } }); const btc = funding.data?.find((f) => f.symbol === "BTCUSDT"); const pct = (btc?.nextFundingRateLong ?? 0) * 100; // long-side funding %

useEstimatedPrice

Ask the solver what price an open or close would fill at — a read-only simulation of the trade → { estimatedPrice }. Use it to preview the fill price, price impact (calculatePriceImpact) and — for a close — an estimated PnL, before the user submits. Pass the slippage-adjusted request price (what the SDK sends to the solver), not the raw mark; positionType and entry ("open" | "close") pick the direction. Disabled until quantity and price are non-empty. quantity and price are debounced internally (debounceMs, default 350) so typing an amount fires one request once the user settles — pass the raw input, no external debounce needed; set debounceMs: 0 to disable.

const { data } = useEstimatedPrice({ symbolId: Number(market.symbol_id), quantity: tradeParams.quantity, // leveraged quantity to open / amount to close positionType, entry: "open", price: tradeParams.requestedOpenPrice, // slippage-adjusted; use calculateClosePrice for a close }); const impact = data ? calculatePriceImpact({ estimatedPrice: data.estimatedPrice, referencePrice: String(markPrice) }) : 0;

useSolverErrorCodes

Fetch the solver’s error-code registry. Cache once, look up by code.

const codes = useSolverErrorCodes();

useSolverErrorMessage

Composed — takes an error code, returns the human-readable message.

const msg = useSolverErrorMessage({ code: 42 });

Trading flows

Instant Open and Instant Close live on their own pages:

  • Instant OpenuseInstantOpen, useInstantOpenAuto, useInstantOpenWithTpSl, useInstantOpens, useInstantOpenQuoteId.
  • Instant CloseuseInstantClose, useInstantCloseAuto, useInstantCloseBulk, useInstantCloseBulkAuto, useInstantCloses.
  • Core Solvers — the underlying actions.
  • SYMMIO Contract — on-chain analogs where applicable.
  • Errors — solver failures surface as SymmioRequestError kind: "api".
Last updated on