Skip to Content
Symmio Trading-SDK — the SDK surface for builders on HyperEVM
CoreTP/SLvalidateTpSl

validateTpSl

Validate a candidate TP/SL pair against the handler’s published rules. Pure and framework-agnostic — a Node script or a Vue app can share it with the React form. The SDK does not throw here; the caller decides whether to surface, block, or proceed.

Checks, in order:

  1. Sign rule — TP above/below the reference price per side; SL the opposite.
  2. minPriceDistancePercent|target − open| / open × 100 must clear the floor.
  3. minProfitStopLossSpreadPercent — when both sides are set, the absolute TP↔SL spread as a percent of the reference price must clear the floor.
import { validateTpSl } from "@symmio/trading-core"; const result = validateTpSl({ takeProfitPrice: "150", stopLossPrice: "80", openPrice: "100", positionType: PositionType.LONG, pricePrecision: 4, config: tpslConfig, }); if (!result.ok) { console.log(result.tpError, result.slError); }

Parameters

A single ValidateTpSlInputs object:

openPricestringrequired

Reference price the distance/spread rules are measured against (decimal string).

positionTypePositionTyperequired

Quote direction (LONG / SHORT).

pricePrecisionnumberrequired

Market price precision — used to render the “should be above/below X” hint.

configTpSlConfigrequired

Live handler /configs/ data.

takeProfitPricestringoptional

TP trigger price (decimal string). Omit when only setting an SL.

stopLossPricestringoptional

SL trigger price (decimal string). Omit when only setting a TP.

isOpenPositionbooleanoptional

When true, error text says “current price” instead of “open price”.

Returns

{ ok: true } when every supplied side passes; otherwise { ok: false } with per-side tpError / slError strings.

Last updated on